[![REUSE status](https://api.reuse.software/badge/github.com/SAP/swagger-plugin-for-sphinx)](https://api.reuse.software/info/github.com/SAP/swagger-plugin-for-sphinx)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
# 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
Then add the main configuration for swagger:
```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).
Note, that also file paths can be used.
First, specify your paths in the `html_static_path` config of sphinx.
Then customize the corresponding uri settings like `_static/<myfile>`
### Standalone page
As a last step, define the swagger configuration as follows:
```python
swagger = [
{
"name": "Service API",
"page": "openapi",
"id": "my-page",
"options": {
"url": "openapi.yaml",
},
}
]
```
Each item on the list will generate a new swagger HTML page.
The `name` is the HTML page name and `page` defines the file name without an extension. This needs to be included in the TOC.
The `options` are then used for the `SwaggerUIBundle` as defined [here](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md).
Please don't specify the `dom_id` since it's hardcoded in the HTML page.
If the specification is provided as a file, don't forget to copy it (e.g., by putting it into the `html_static_path`).
To silence the warning `toctree contains reference to nonexisting document`, just put a dummy file with the same name as `page` into the source folder.
## Inline swagger page
To include a swagger page into a sphinx page use the directive ``inline-swagger``:
```rst
.. inline-swagger::
:id: my-page
```
The ``id`` links to an existing configuration in ``conf.py`` as shows above.
In this case, the configuration ``page`` will be ignored.
Behind the scenes, a swagger HTML page is generated and then inserted using the ``.. raw::``
directive.
## 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 2024 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 Mueller <kai.mueller01@sap.com>",
"download_url": "https://files.pythonhosted.org/packages/74/b3/711c930ae61931330cccf779d0c40c9753cba9135894f5e6eb792291a1ec/swagger_plugin_for_sphinx-4.0.0.tar.gz",
"platform": null,
"description": "[![REUSE status](https://api.reuse.software/badge/github.com/SAP/swagger-plugin-for-sphinx)](https://api.reuse.software/info/github.com/SAP/swagger-plugin-for-sphinx)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\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\n## Usage\n\n### Enable the plugin\n\nFirst, add the plugin to the extensions list:\n```python\nextensions = [\"swagger_plugin_for_sphinx\"]\n```\n\n### Global configuration\n\nThen add the main configuration for swagger:\n```python\nswagger_present_uri = \"\"\nswagger_bundle_uri = \"\"\nswagger_css_uri = \"\"\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\nNote, that also file paths can be used.\nFirst, specify your paths in the `html_static_path` config of sphinx.\nThen customize the corresponding uri settings like `_static/<myfile>`\n\n### Standalone page\nAs a last step, define the swagger configuration as follows:\n```python\nswagger = [\n {\n \"name\": \"Service API\",\n \"page\": \"openapi\",\n \"id\": \"my-page\",\n \"options\": {\n \"url\": \"openapi.yaml\",\n },\n }\n]\n```\nEach item on the list will generate a new swagger HTML page.\nThe `name` is the HTML page name and `page` defines the file name without an extension. This needs to be included in the TOC.\nThe `options` are then used for the `SwaggerUIBundle` as defined [here](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md).\nPlease don't specify the `dom_id` since it's hardcoded in the HTML page.\nIf the specification is provided as a file, don't forget to copy it (e.g., by putting it into the `html_static_path`).\nTo silence the warning `toctree contains reference to nonexisting document`, just put a dummy file with the same name as `page` into the source folder.\n\n## Inline swagger page\nTo include a swagger page into a sphinx page use the directive ``inline-swagger``:\n\n```rst\n.. inline-swagger::\n :id: my-page\n```\n\nThe ``id`` links to an existing configuration in ``conf.py`` as shows above.\nIn this case, the configuration ``page`` will be ignored.\nBehind the scenes, a swagger HTML page is generated and then inserted using the ``.. raw::``\ndirective.\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 2024 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": "Apache-2.0",
"summary": "Sphinx plugin which renders a OpenAPI specification with Swagger",
"version": "4.0.0",
"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": "",
"digests": {
"blake2b_256": "3020f19ba0c0d7f067b61b27d25961a013213ce1263f5d190f41abbcec6f8803",
"md5": "bd2e5f77148cb7d8af9518ccf5a1eebf",
"sha256": "66a75add906188d2315843ce2d89893dff0f77fcb73c8fe278c6a6f5ce4c082a"
},
"downloads": -1,
"filename": "swagger_plugin_for_sphinx-4.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bd2e5f77148cb7d8af9518ccf5a1eebf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 10061,
"upload_time": "2024-10-09T05:56:01",
"upload_time_iso_8601": "2024-10-09T05:56:01.526625Z",
"url": "https://files.pythonhosted.org/packages/30/20/f19ba0c0d7f067b61b27d25961a013213ce1263f5d190f41abbcec6f8803/swagger_plugin_for_sphinx-4.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "74b3711c930ae61931330cccf779d0c40c9753cba9135894f5e6eb792291a1ec",
"md5": "d4e18977205acc7f117502638ebc7add",
"sha256": "c511a2e79b306e8a3eafe241a797c23eb7de68287245c539e871e23075e5359c"
},
"downloads": -1,
"filename": "swagger_plugin_for_sphinx-4.0.0.tar.gz",
"has_sig": false,
"md5_digest": "d4e18977205acc7f117502638ebc7add",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 11479,
"upload_time": "2024-10-09T05:56:03",
"upload_time_iso_8601": "2024-10-09T05:56:03.104953Z",
"url": "https://files.pythonhosted.org/packages/74/b3/711c930ae61931330cccf779d0c40c9753cba9135894f5e6eb792291a1ec/swagger_plugin_for_sphinx-4.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-09 05:56:03",
"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"
}