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.

GitHub branch checks state PyPI PyPI - Python Version codecov

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.

If you wish to reference any files on the filesytem (security risk), make sure you enable allow_arbitrary_locations in the config (mkdocs.yml) like so:

plugins:
  - render_swagger:
      allow_arbitrary_locations : true

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.

To specify this use javascript and css in your mkdocs.yaml:

plugins:
  - render_swagger:
      javascript: assets/js/swagger-ui-bundle.js
      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 ".[dev]"

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

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

File metadata

File hashes

Hashes for mkdocs_render_swagger_plugin-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b0f4f92bf69d7e0d56b13f520fdad072ddd1f4ccf031f11706d45d831d4df7b
MD5 2994185b4f0a8f0e75bb5ccc534f881c
BLAKE2b-256 ea2d72373074011cc8b62c2d5a19215e85e05e5014fd21a85c030903d2f030d0

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