Skip to main content

Sphinx plugin which renders a OpenAPI specification with Swagger

Project description

REUSE status Code style: black

Swagger Plugin for Sphinx

This is handy plugin to bring Swagger and Sphinx together.

It is able to generate one or multiple swagger HTML pages with a custom configuration which host an OpenAPI specification.

Install

Just run pip install swagger-plugin-for-sphinx

Usage

First, add the plugin to the extensions list:

extensions = ["swagger_plugin_for_sphinx.plugin"]

Then add the main configuration for swagger:

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.

As a last step, define the swagger configuration as followed:

swagger = [
    {
        "name": "Service API",
        "page": "openapi",
        "options": {
            "url": "openapi.yaml",
        },
    }
]

Each item of 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. Please don't specify the dom_id since it's hardcoded in the HTML page.

In the sphinx build, a HTML page is created and put into the _static directory of the build.

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.

Build and Publish

This project uses poetry 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. 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.

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 at all times.

Licensing

Copyright 2022 SAP SE or an SAP affiliate company and swagger-plugin-for-sphinx contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swagger-plugin-for-sphinx-1.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swagger_plugin_for_sphinx-1.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file swagger-plugin-for-sphinx-1.1.0.tar.gz.

File metadata

  • Download URL: swagger-plugin-for-sphinx-1.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0b1 CPython/3.10.4 Linux/5.13.0-1022-azure

File hashes

Hashes for swagger-plugin-for-sphinx-1.1.0.tar.gz
Algorithm Hash digest
SHA256 bf7a84d38e08602632dbf2ea4f710130cc24c4916226d9628b5402f0500217ff
MD5 1a010554ceb0f621d77e9ccb85ee62df
BLAKE2b-256 1031165201b45e3adf02e4f64aba4116bee8ec0785edd46d68a3694d2ecbeef9

See more details on using hashes here.

File details

Details for the file swagger_plugin_for_sphinx-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for swagger_plugin_for_sphinx-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 704813669571d82b9596fe1548d3d1130130f7715def9ea25409ae6bc8b29a34
MD5 3c3a8a30f71bbd8f4bcd0d59f5665b21
BLAKE2b-256 3cfb98dd493c3471206b7b84538cf55ad9a1f4980e8e51803141e3b6b506dcef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page