A MkDocs plugin supports for add Swagger UI in page.
Project description
MkDocs Swagger UI Tag
A MkDocs plugin supports adding Swagger UI to the page.
Live demo with Material for MkDocs.
Features
- OpenAPI Specification file from online over URL or static file in docs
- All dependencies are using static files handled by the plugin not from CDN, especially suitable for those documents been deployed in the intranet
- Multiple Swagger UI on the same page
- Synchronized dark mode with Material for MkDocs
- Configure Swagger UI configuration through plugin options and tag attributes
- Support multiple OAS in a single Swagger UI with a top bar selector
- Support Swagger UI initOAuth method
Dependency
- Python Package
- beautifulsoup4>=4.11.1
- Swagger UI dist javascript file and CSS file
- swagger-ui-dist==5.17.14
Usage
-
Install the plugin from PyPI
pip install mkdocs-swagger-ui-tag
-
Add
swagger-ui-tag
plugin to your mkdocs.yml plugins sections:plugins: - swagger-ui-tag
-
Add
swagger-ui
tag in markdown to include Swagger UI<swagger-ui src="https://petstore.swagger.io/v2/swagger.json"/>
-
You may customize the plugin by passing options in mkdocs.yml, check more details on options:
plugins: - swagger-ui-tag: background: White docExpansion: none filter: "" syntaxHighlightTheme: monokai tryItOutEnabled: ['get', 'post']
Options Type Description background String Default: "". Swagger UI iframe body background attribute value. You can use any css value for background for example "#74b9ff" or "Gainsboro" or "" for nothing. docExpansion String Default: "list". Controls the default expansion setting for the operations and tags. It can be "list" (expands only the tags), "full" (expands the tags and operations) or "none" (expands nothing). filter String or Boolean Default: False. If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. Can be Boolean to enable or disable, or a string, in which case filtering will be enabled using that string as the filter expression. Filtering is case sensitive matching the filter expression anywhere inside the tag. syntaxHighlightTheme String Default: "agate". Highlight.js syntax coloring theme to use. It can be "agate", "arta", "monokai", "nord", "obsidian" or "tomorrow-night" tryItOutEnabled Boolean Default: False. This setting determines the default editability of the "Try it out" section, including parameters or body. oauth2RedirectUrl String Default: Absolute URL of "/assets/swagger-ui/oauth2-redirect.html" relative with site_url in mkdocs.yml or document root path on site without site_url, e.g. "https://blueswen.github.io/mkdocs-swagger-ui-tag/assets/swagger-ui/oauth2-redirect.html". OAuth redirect URL. supportedSubmitMethods Array Default: All Http Methods. Array=["get", "put", "post", "delete", "options", "head", "patch", "trace"]. List of HTTP methods that have the "Try it out" feature enabled. An empty array disables "Try it out" for all operations. This does not filter the operations from the display. validatorUrl String Default: "https://validator.swagger.io/validator". By default, Swagger UI attempts to validate specs against swagger.io's online validator in multiple OAS Swagger UI. You can use this parameter to set a different validator URL, for example for locally deployed validators (Validator Badge). Setting it "none" to disable validation.
How it works
- Copy the Swagger UI script file into
site/assets/javascripts/
directory, the CSS file intosite/assets/stylesheets/
directory, and the default Oauth2 redirect html intosite/assets/swagger-ui/
directory - Search all swagger-ui tags, then convert them to an iframe tag and generate the iframe target HTML with the given OpenAPI Specification src path and options
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Reference
- Amoenus Swagger Dark Theme: source of dark mode css
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mkdocs_swagger_ui_tag-0.6.11.tar.gz
.
File metadata
- Download URL: mkdocs_swagger_ui_tag-0.6.11.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31681821d7f56a38379eb793abb3e035595df2043732a7db28e357dca2a0d566 |
|
MD5 | d1d3b47b788a520df8d03e089bc4ced1 |
|
BLAKE2b-256 | 6fb74f13d618ded55f35977b26d844e2d488f8a2f14c02803777f0d21a3393b2 |
File details
Details for the file mkdocs_swagger_ui_tag-0.6.11-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_swagger_ui_tag-0.6.11-py3-none-any.whl
- Upload date:
- Size: 2.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb7e0d6e14c793ec3430a6916dff6d8d1a0b3fd88ac6e909fa493f218685d12f |
|
MD5 | 8be64c9df7162dc5d91a51cdca2c73dd |
|
BLAKE2b-256 | 3116908dab5d37715aeea87e3307248a7107b05332e324c1f465907117eb9962 |