Skip to main content

MkDocs Swagger UI Tag

PyPI version PyPI downloads Codecov

A MkDocs plugin supports adding Swagger UI to the page.

Live demo with Material for MkDocs.

Features

  1. OpenAPI Specification file from online over URL or static file in docs
  2. All dependencies are using static files handled by the plugin not from CDN, especially suitable for those documents been deployed in the intranet
  3. Multiple Swagger UI on the same page
  4. Synchronized dark mode with Material for MkDocs
  5. Configure Swagger UI configuration through plugin options and tag attributes
  6. Support multiple OAS in a single Swagger UI with a top bar selector
  7. Support Swagger UI initOAuth method

Dependency

  1. Python Package
    1. beautifulsoup4>=4.13.3
  2. Swagger UI dist javascript file and CSS file
    1. swagger-ui-dist==5.32.8

Usage

  1. Install the plugin from PyPI

    pip install mkdocs-swagger-ui-tag
    
  2. Add swagger-ui-tag plugin to your mkdocs.yml plugins sections:

    plugins:
       - swagger-ui-tag
    
  3. Add swagger-ui tag in markdown to include Swagger UI

    <swagger-ui src="https://petstore.swagger.io/v2/swagger.json"/>
    

    Swagger UI Sample Image

  4. 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.
    extra_css Array Default: []. List of additional CSS files to include in Swagger UI iframes.
    dark_scheme_name String Default: "slate". The color scheme name used for dark mode detection with Material for MkDocs theme.
    filter_files Array Default: []. List of file paths to filter processing. If specified, only files in this list will be processed for swagger-ui tags.

How it works

  1. Copies the Swagger UI script file into site/assets/javascripts/ directory, the CSS file into site/assets/stylesheets/ directory, and the default Oauth2 redirect html into site/assets/swagger-ui/ directory
  2. 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

Development

Upgrading the Swagger-UI version

SWAGGER_UI_VERSION=GIVEN_VERSION
./update-swagger-ui.sh $SWAGGER_UI_VERSION

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Reference

  1. Amoenus Swagger Dark Theme: source of dark mode css

Metadata

Release files for mkdocs-swagger-ui-tag 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-swagger-ui-tag 0.8.1
File Size Uploaded
mkdocs_swagger_ui_tag-0.8.1.tar.gz 1.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-swagger-ui-tag 0.8.1
File Interpreter ABI Platform
mkdocs_swagger_ui_tag-0.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 2.6 MB

Release files / mkdocs_swagger_ui_tag-0.8.1.tar.gz

Download URL mkdocs_swagger_ui_tag-0.8.1.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
15f199ca7734c50c088c53bfe9ec806768ad97816badb3a4e72af4e9434252db
BLAKE2b-256 checksum
How to use checksums
e8bac660d28947d1b57a980f7dd5156fb994134c20146a7948c1adb796a80d7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 10, 2026.

Transparency log

Release files / mkdocs_swagger_ui_tag-0.8.1-py3-none-any.whl

Download URL mkdocs_swagger_ui_tag-0.8.1-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f5d6d0558ed6cfafce54a9f0d874d9e24be0a9b02b2429553afefced61c9e55f
BLAKE2b-256 checksum
How to use checksums
28284709ae7156a1326a9530d8a51632a3369d42392588929969b1d0aa221ff5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.8.1 This release

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.11

2 release files

0.6.9

2 release files

0.6.8

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page