Skip to main content

MKDocs plugin for rendering swagger & openapi files.

Project description

mkdocs-render-swagger-plugin

This is the Mkdocs plugin for rendering swagger & openapi schemas using Swagger UI. It is written in Python.

Usage

Install the plugin using pip install mkdocs-render-swagger-plugin.

Add the following lines to your mkdocs.yml:

plugins:
  - render_swagger

Example

Here's an example (courtesy of Scarf) of how the plugin renders swagger.

Referencing a local json

Place an OpenAPI json file in the same folder as the .md file.

Enter !!swagger FILENAME!! at the appropriate location inside the markdown file.

Referencing an external json

You may reference an external OpenAPI json using the following syntax: !!swagger-http URL!!.

Explicit declaration of the Swagger JS library

You can explicitly specify the swagger-ui css and js dependencies if you wish to not use the unpkg CDN.

Keep in mind, the filename has to be swagger-ui.css for the CSS and swagger-ui-bundle.js for the JS.

To specify this use extra_javascript and extra_css in your mkdocs.yaml:

extra_javascript:
  - assets/js/swagger-ui-bundle.js

extra_css:
  - assets/css/swagger-ui.css

Contributing & Developing Locally

After downloading and extracting the .tar.gz, install this package locally using pip and the --editable flag:

pip install --editable .

You'll then have the render-swagger package available to use in Mkdocs and pip will point the dependency to this folder. You are then able to run the docs using mkdocs serve. Make sure you restart the process between code changes as the plugin is loaded on startup.

MkDocs plugins and Swagger api

The Render Swagger MkDocs plugin uses a set of extensions and plugin APIs that MkDocs and Swagger UI supports. You can find more info about MkDocs plugins and Swagger UI on the official website of MkDocs and SwaggerUI.

The input OpenAPI files processed by the plugin should conform to the OpenAPI specification. It is generated by a few projects such as pydantic, FastAPI and others.


Disclaimer: This plugin is unofficial, and is not sponsored, owned or endorsed by mkdocs, swagger, or any other 3rd party.
Credits to @aviramha for starting this project.

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

mkdocs-render-swagger-plugin-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file mkdocs-render-swagger-plugin-0.1.0.tar.gz.

File metadata

File hashes

Hashes for mkdocs-render-swagger-plugin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 50fe52b362f55483584bb6ca40e14aa3f83097d9a982e60169df0e9631256c15
MD5 df016dec0dc303caba2f1097fcddc36e
BLAKE2b-256 3fc2bd66195fcf45e64bebf9f061f0652237a7165707ce879e9895b9cc1df3a2

See more details on using hashes here.

File details

Details for the file mkdocs_render_swagger_plugin-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_render_swagger_plugin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df3565008a1319f953669efafb1e14e6571cad43a4264de0c3b1b83fa7900cd8
MD5 6af6bded140cff219dc489ec5bab9471
BLAKE2b-256 1a1aaea91b8b044ed2857b80cc82943c971a078cfdef72bc62f010282ece2dcc

See more details on using hashes here.

Supported by

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