[](https://api.reuse.software/info/github.com/SAP/swagger-plugin-for-sphinx)
[](https://github.com/psf/black)
[](https://coveralls.io/github/SAP/swagger-plugin-for-sphinx)
# Swagger Plugin for Sphinx
This is a handy plugin to bring [Swagger](https://swagger.io/) and [Sphinx](https://www.sphinx-doc.org/en/master/) 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:
```python
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``:
```python
swagger_present_uri = ""
swagger_bundle_uri = ""
swagger_css_uri = ""
```
These correspond to the modules explained [here](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/installation.md).
By default, the latest release is used from [here](https://cdn.jsdelivr.net/npm/swagger-ui-dist@latest).
### Directive
To include a Swagger API specification into an HTML page specify the `swagger-plugin` directive
and the relative path to the specification:
```code
.. 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)
* `full-page`: if set, all other content on the page is dropped and only the Swagger part is rendered
* `page-title`: the name of the HTML page if `full-page` is specified
* `swagger-options`: JSON string that is passed to Swagger to enable additional options as described
on the [configuration](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/)
page of the Swagger documentation.
By default, the directive creates a `<div>` element with the ID `swagger-ui-container`.
If you put more than one `swagger-plugin` directive in a file, specify unique IDs:
```code
.. swagger-plugin:: path/to/one.yaml
:id: spec-one
.. swagger-plugin:: path/to/two.yaml
:id: spec-two
```
## Build and Publish
This project uses `setuptools` as the dependency management and build tool.
To publish a new release, follow these steps:
* Update the version in the `pyproject.toml`
* Add an entry in the changelog
* Push a new tag like `vX.X.X` to trigger the release
## Support, Feedback, Contributing
This project is open to feature requests/suggestions, bug reports etc., via [GitHub issues](https://github.com/SAP/<your-project>/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).
## Code of Conduct
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](CODE_OF_CONDUCT.md) at all times.
## Licensing
Copyright 2025 SAP SE or an SAP affiliate company and swagger-plugin-for-sphinx contributors.
Please see our [LICENSE](LICENSE) for copyright and license information.
Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/SAP/<your-project>).
Raw data
{
"_id": null,
"home_page": null,
"name": "swagger-plugin-for-sphinx",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.9",
"maintainer_email": null,
"keywords": "sphinx, swagger, plugin, openapi",
"author": null,
"author_email": "Kai Harder <kai.harder@sap.com>",
"download_url": "https://files.pythonhosted.org/packages/7e/57/36e7b17ce1fbac1b3039a10d1638d72de9f6a13e1af47820110f04fb45ba/swagger_plugin_for_sphinx-5.1.1.tar.gz",
"platform": null,
"description": "[](https://api.reuse.software/info/github.com/SAP/swagger-plugin-for-sphinx)\n[](https://github.com/psf/black)\n[](https://coveralls.io/github/SAP/swagger-plugin-for-sphinx)\n\n# Swagger Plugin for Sphinx\n\nThis is a handy plugin to bring [Swagger](https://swagger.io/) and [Sphinx](https://www.sphinx-doc.org/en/master/) together.\n\nIt can generate one or multiple swagger HTML pages with a custom configuration that hosts an OpenAPI specification.\n\n## Install\n\nJust run `pip install swagger-plugin-for-sphinx`\n\n## Usage\n\n### Enable the Plugin\n\nFirst, add the plugin to the extensions list:\n\n```python\nextensions = [\"swagger_plugin_for_sphinx\"]\n```\n\n### Global Configuration\n\nSwagger uses two JavaScript and one CSS file to render the output.\nThese can be set in ``conf.py``:\n\n```python\nswagger_present_uri = \"\"\nswagger_bundle_uri = \"\"\nswagger_css_uri = \"\"\n```\n\nThese correspond to the modules explained [here](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/installation.md).\nBy default, the latest release is used from [here](https://cdn.jsdelivr.net/npm/swagger-ui-dist@latest).\n\n### Directive\n\nTo include a Swagger API specification into an HTML page specify the `swagger-plugin` directive\nand the relative path to the specification:\n\n```code\n.. swagger-plugin:: path/to/spec.yaml\n```\n\nThe spec is automatically copied into the `_static` build output directory.\n\nThe directive supports the following options\n\n* `id`: specifies an unique ID for the specification per page (see below)\n* `full-page`: if set, all other content on the page is dropped and only the Swagger part is rendered\n* `page-title`: the name of the HTML page if `full-page` is specified\n* `swagger-options`: JSON string that is passed to Swagger to enable additional options as described\n on the [configuration](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/)\n page of the Swagger documentation.\n\nBy default, the directive creates a `<div>` element with the ID `swagger-ui-container`.\nIf you put more than one `swagger-plugin` directive in a file, specify unique IDs:\n\n```code\n.. swagger-plugin:: path/to/one.yaml\n :id: spec-one\n\n.. swagger-plugin:: path/to/two.yaml\n :id: spec-two\n```\n\n## Build and Publish\n\nThis project uses `setuptools` as the dependency management and build tool.\nTo publish a new release, follow these steps:\n* Update the version in the `pyproject.toml`\n* Add an entry in the changelog\n* Push a new tag like `vX.X.X` to trigger the release\n\n## Support, Feedback, Contributing\n\nThis project is open to feature requests/suggestions, bug reports etc., via [GitHub issues](https://github.com/SAP/<your-project>/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).\n\n## Code of Conduct\n\nWe as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](CODE_OF_CONDUCT.md) at all times.\n\n## Licensing\n\nCopyright 2025 SAP SE or an SAP affiliate company and swagger-plugin-for-sphinx contributors.\nPlease see our [LICENSE](LICENSE) for copyright and license information.\nDetailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/SAP/<your-project>).\n",
"bugtrack_url": null,
"license": null,
"summary": "Sphinx plugin which renders a OpenAPI specification with Swagger",
"version": "5.1.1",
"project_urls": {
"Changelog": "https://github.com/SAP/swagger-plugin-for-sphinx/blob/main/CHANGELOG.md",
"Issue Tracker": "https://github.com/SAP/swagger-plugin-for-sphinx/issues"
},
"split_keywords": [
"sphinx",
" swagger",
" plugin",
" openapi"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "26e543c8870428202ae27edddc4379756d10c6e718de13acca3ee702354ff42b",
"md5": "aa57645dd4cf4db117b07008eff079d1",
"sha256": "e0418a410a3c5da8c2c32744b6445e3f2fd8e044d91d59866b80b1aed6deb681"
},
"downloads": -1,
"filename": "swagger_plugin_for_sphinx-5.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "aa57645dd4cf4db117b07008eff079d1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 11376,
"upload_time": "2025-07-11T05:41:30",
"upload_time_iso_8601": "2025-07-11T05:41:30.608484Z",
"url": "https://files.pythonhosted.org/packages/26/e5/43c8870428202ae27edddc4379756d10c6e718de13acca3ee702354ff42b/swagger_plugin_for_sphinx-5.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7e5736e7b17ce1fbac1b3039a10d1638d72de9f6a13e1af47820110f04fb45ba",
"md5": "47151037c6174756a8d6269857e98b6f",
"sha256": "7bc909bf867c85faa3adbb5ec0a2ce37a50c2613557bb9cff503ecd98ed24493"
},
"downloads": -1,
"filename": "swagger_plugin_for_sphinx-5.1.1.tar.gz",
"has_sig": false,
"md5_digest": "47151037c6174756a8d6269857e98b6f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 15673,
"upload_time": "2025-07-11T05:41:32",
"upload_time_iso_8601": "2025-07-11T05:41:32.021439Z",
"url": "https://files.pythonhosted.org/packages/7e/57/36e7b17ce1fbac1b3039a10d1638d72de9f6a13e1af47820110f04fb45ba/swagger_plugin_for_sphinx-5.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-11 05:41:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "SAP",
"github_project": "swagger-plugin-for-sphinx",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "swagger-plugin-for-sphinx"
}