[![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
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 `html_static_path`.
The directive supports the following options
* `id`: specifies an unique id for the specifiction 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 used
* `swagger-options`: JSON string which is passed to swagger to enable additional options as described
[here](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md)
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 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 Harder <kai.harder@sap.com>",
"download_url": "https://files.pythonhosted.org/packages/fe/85/181882678f074ad7e9f3ab05c7c591bf34b6e7cca47587af9d8578036131/swagger_plugin_for_sphinx-5.0.1.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## 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 `html_static_path`.\n\nThe directive supports the following options\n\n* `id`: specifies an unique id for the specifiction 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 used\n* `swagger-options`: JSON string which is passed to swagger to enable additional options as described\n [here](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md)\n\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 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": "5.0.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": "",
"digests": {
"blake2b_256": "4c3e130b952134d2f06da3177aada72649f6e30c51ae5d923d26219002696315",
"md5": "10c7d01e75e93bf9a15b0802f85853f3",
"sha256": "3666178764be6d7ef1e45b0d7c1ddf4c7208c36f80a41dbf86ccc93fd788a431"
},
"downloads": -1,
"filename": "swagger_plugin_for_sphinx-5.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "10c7d01e75e93bf9a15b0802f85853f3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.9",
"size": 10801,
"upload_time": "2025-01-13T10:04:24",
"upload_time_iso_8601": "2025-01-13T10:04:24.168781Z",
"url": "https://files.pythonhosted.org/packages/4c/3e/130b952134d2f06da3177aada72649f6e30c51ae5d923d26219002696315/swagger_plugin_for_sphinx-5.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fe85181882678f074ad7e9f3ab05c7c591bf34b6e7cca47587af9d8578036131",
"md5": "dd868a60084d0fd99044252d481eeb1d",
"sha256": "5e21fd14cd8fcb3365fc74246981d72711613eb7133b56a8ca1d89803c3f7e6a"
},
"downloads": -1,
"filename": "swagger_plugin_for_sphinx-5.0.1.tar.gz",
"has_sig": false,
"md5_digest": "dd868a60084d0fd99044252d481eeb1d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.9",
"size": 12328,
"upload_time": "2025-01-13T10:04:26",
"upload_time_iso_8601": "2025-01-13T10:04:26.718189Z",
"url": "https://files.pythonhosted.org/packages/fe/85/181882678f074ad7e9f3ab05c7c591bf34b6e7cca47587af9d8578036131/swagger_plugin_for_sphinx-5.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-13 10:04:26",
"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"
}