Skip to main content

Provides the swaggerui directive for reST files to build an interactive HTML page with your OpenAPI specification document.

Project description

https://travis-ci.org/sphinx-contrib/sphinxcontrib-swaggerui.svg?branch=master

Provides the swaggerui directive for reST files to build an interactive driven by Swagger-UI panel presenting your OpenAPI specification document.

Overview

This Sphinx extension is necessary for those who publish an interactive document presenting their API specification compliant with OpenAPI and want to use the well-known Swagger-UI tool for this purpose. The swaggerui directive enables you to embed such interactive panel in an arbitrary place of a reST file.

Sphinx Directive swaggerui

Installation

$ pip install sphinxcontrib-swaggerui

Configuration

In your Sphinx project configuration file config.py, add the installed extension:

extensions = [...,
    'sphinxcontrib.swaggerui',
    ...]

The directive also implies that you use the static content in the _static/ folder and this is configured as:

html_static_path = ['_static']

Directive in reST Files

Use the following sample configuration when testing the directive for the first time:

.. swaggerui:: ../_static/swaggerui/petstore.yaml                                 # *) Required
   :url: https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js               # *) Required
   :css: ../_static/swaggerui/swagger-ui.css                                      # *) Required
   :script: https://unpkg.com/swagger-ui-dist@3/swagger-ui-standalone-preset.js # Optional

An attribute (for example, ../_static/swagger/petstore.yaml) refers to your local YAML or JSON file in the OpenAPI format. The path must be relative to the document containing the directive.

The directive uses the following options:

  • url refers to a CDN-based (Content Delivery Network) Swagger-UI package. For a proper version of the script, refer to the UNPKG CDN. The script name must be swagger-ui-bundle.js.

  • css refers to a local Swagger-UI CSS file. The path must be relative to the document containing the directive. You can find a proper CSS file in the UNPKG CDN.

  • script refers to an additional script (the one in the above example is recommended). For a proper version of the script, refer to the UNPKG CDN. The script name must be swagger-ui-standalone-preset.js. Probably, you will find another script that can work with the main Swagger-UI script specified by the :url: option.

Sample CSS Customization

Avoid the operation block tag to disappear:

h4.opblock-tag a.nostyle {
   opacity: 1
}

Remove the Swagger top-bar:

.swagger-ui .topbar {
   display: none;
}

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

sphinxcontrib-swaggerui-0.0.9.tar.gz (57.8 kB view details)

Uploaded Source

File details

Details for the file sphinxcontrib-swaggerui-0.0.9.tar.gz.

File metadata

  • Download URL: sphinxcontrib-swaggerui-0.0.9.tar.gz
  • Upload date:
  • Size: 57.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.5

File hashes

Hashes for sphinxcontrib-swaggerui-0.0.9.tar.gz
Algorithm Hash digest
SHA256 de24c2ad921e5fc9a881815f39a8c9dc4c1e1b5f11aef2112efe7f3f79d04ce0
MD5 144c71cf10b2d938b26a95f724d587a0
BLAKE2b-256 dc17d28fd55f1b57abcdb6a649ccf8d8ea7364b83b586d3174866e38fb4083b0

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