Sphinx plugin which renders a OpenAPI specification with Swagger
Actively maintained. Last release 2 months ago, commits in 26 of the last 26 weeks. A safe choice.
pip install swagger-plugin-for-sphinxSwagger Plugin for Sphinx
This is a handy plugin to bring Swagger and Sphinx together.
It can generate one or multiple swagger HTML pages with a custom configuration that hosts an OpenAPI specification.
Install
Just run pip install swagger-plugin-for-sphinx
Usage
Enable the Plugin
First, add the plugin to the extensions list:
extensions = ["swagger_plugin_for_sphinx"]
Global Configuration
Swagger uses two JavaScript and one CSS file to render the output.
These can be set in conf.py:
swagger_present_uri = ""
swagger_bundle_uri = ""
swagger_css_uri = ""
These correspond to the modules explained here. By default, the latest release is used from here.
Optionally if you do now want to redirect users to the mirror but prefer local
serving you can mirror the Swagger dependencies into the generated doctree in conf.py via:
swagger_mirror_external_resources = True
Directive
To include a Swagger API specification into an HTML page specify the swagger-plugin directive
and the relative path to the specification:
.. swagger-plugin:: path/to/spec.yaml
The spec is automatically copied into the _static build output directory.
The directive supports the following options
id: specifies an unique ID for the specification per page (see below)