Skip to main content

mkdocs-openapi

Generate predictable, native MkDocs API reference pages from an OpenAPI document.

mkdocs-openapi converts an OpenAPI 3.x JSON or YAML document into Markdown pages during the MkDocs build. Because the pages participate in the normal MkDocs pipeline, they work with site navigation, search, tags, Markdown extensions, link validation, and theme customization.

Status

This project is currently alpha software. It supports one or more local OpenAPI 3.x documents per MkDocs site.

See the changelog for release history.

Requirements

  • Python 3.10 or later
  • MkDocs 1.6 or later
  • Material for MkDocs 9.6 or later (recommended and tested theme)

Installation

Install the plugin and Material for MkDocs:

python -m pip install mkdocs-openapi mkdocs-material

If you already have a Material for MkDocs project, install only the plugin:

python -m pip install mkdocs-openapi

Confirm that MkDocs can discover the plugin:

mkdocs get-deps

Quick start

Place your OpenAPI document under the MkDocs docs_dir. With the default docs/ directory, a minimal project might look like this:

.
├── docs
│   ├── index.md
│   └── openapi
│       └── spec.yaml
└── mkdocs.yml

Enable the plugin in mkdocs.yml, then reference the OpenAPI document directly from nav:

site_name: My API

theme:
  name: material

plugins:
  - search
  - openapi

nav:
  - Home: index.md
  - API Reference: openapi/spec.yaml

Build or preview the site normally:

mkdocs serve

The OpenAPI nav entry is replaced with generated API pages:

API Reference
├── Overview
├── First tag
│   ├── Overview
│   ├── GET First operation
│   └── POST Second operation
└── Second tag
    └── ...
Models
├── Overview
└── One page per component schema

The source specification is consumed during the build and is not copied into the published site.

To avoid standalone model files, set models_mode: inline. Every model reachable from an operation, including nested dependencies, is then rendered on that operation's page. Model pages and model navigation are not generated.

plugins:
  - openapi:
      models_mode: inline

Multiple specifications

Use specs when a site contains more than one OpenAPI document. Each entry has a stable ID, a source path matching its nav entry, and an isolated output directory:

plugins:
  - search
  - openapi:
      specs:
        pets:
          source: openapi/pets.yaml
          output_dir: api-reference/pets
        orders:
          source: openapi/orders.yaml
          output_dir: api-reference/orders
          models_dir: api-reference/orders/models
          models_title: Order models

nav:
  - Home: index.md
  - APIs:
      - Pets: openapi/pets.yaml
      - Orders: openapi/orders.yaml

source and output_dir are required for every entry. models_dir defaults to <output_dir>/models. The remaining rendering and navigation options may be set globally and overridden for an individual specification. Every configured source must appear in nav exactly once, and every OpenAPI document in nav must be registered under specs.

Material for MkDocs integration

The plugin automatically:

  • adds its bundled mkdocs-openapi.css stylesheet;
  • adds its bundled interaction script for URL copying and page actions;
  • enables admonition, attr_list, tables, pymdownx.superfences, and pymdownx.tabbed;
  • uses the site's configured Material/PyMdown tab style;
  • generates native Markdown pages that participate in Material search, tags, navigation, and table-of-contents behavior; and
  • displays HTTP method badges in Material's primary navigation.

The method badge colors can be customized with CSS variables:

:root {
  --api-method-get-color: #61affe;
  --api-method-post-color: #49cc90;
  --api-method-put-color: #fca130;
  --api-method-delete-color: #f93e3e;
  --api-method-text-color: #ffffff;
}

Add your override after the plugin stylesheet using the normal MkDocs extra_css setting:

extra_css:
  - stylesheets/extra.css

Configuration

Plugin options are configured below the openapi entry:

plugins:
  - search
  - tags
  - openapi:
      output_dir: api-reference
      models_dir: models
      models_title: Models
      models_in_nav: true
      models_mode: pages
      suppress_tag_overview: false
      suppress_method_badges: false
Option Default Description
output_dir api-reference Virtual source directory for API and operation pages.
models_dir models Virtual source directory for component schema pages.
models_title Models Navigation title inserted beside the API section.
models_in_nav true Include every model below the Models nav item. Set to false for very large schemas.
models_mode pages Use pages for standalone model pages or inline to render reachable models on each operation page.
suppress_tag_overview false Omit each tag's Overview link from generated navigation. The overview pages are still generated.
suppress_method_badges false Hide HTTP method badges in Material's primary navigation.
tag_nav unset Ordered tag navigation containing root-level tag names or titled groups of tag names.
unlisted_tags exclude Handle primary tags omitted from tag_nav with exclude, append, or error.
specs unset Mapping of specification IDs to multi-spec source, output, and optional per-spec overrides.

When specs is set, each entry accepts:

Option Default Description
source required OpenAPI file below docs_dir; must match an entry in nav.
output_dir required Unique virtual source directory for this API.
models_dir <output_dir>/models Unique virtual source directory for this API's schemas when models_mode is pages.
models_title global value Navigation title for this API's schemas.
models_in_nav global value Whether every schema is included in navigation.
models_mode global value Whether models use standalone pages or render inline on operation pages.
suppress_tag_overview global value Whether tag Overview links are omitted for this API.
tag_nav global value Tag navigation for this API.
unlisted_tags global value Handling of primary tags omitted from this API's tag_nav.

Tag navigation

tag_nav controls which primary OpenAPI tags are rendered, their order, and whether they appear below an additional navigation level:

plugins:
  - openapi:
      tag_nav:
        - Phone:
            - Business Hours
            - Call Blocking
            - Call Control
        - SMS and Fax:
            - Fax
            - Message Store
            - SMS
      unlisted_tags: exclude

Plain string entries are rendered directly below the API Reference section. Group mappings create an additional navigation level.

Set unlisted_tags to:

  • exclude to omit tags not listed in tag_nav;
  • append to add unlisted tags after the configured tags; or
  • error to require an exhaustive tag configuration.

Unknown tags, duplicates, and empty groups fail the build. If tag_nav is omitted, all tags retain their default order.

Rendering behavior

  • Operations are grouped by their first OpenAPI tag.
  • Operations without tags are placed under Untagged.
  • Additional operation tags are retained as page metadata for Material's tags plugin.
  • Operations marked with deprecated: true display a Material warning admonition.
  • Operation pages show a scrollable endpoint bar with a URL copy control.
  • Path, query, header, and cookie parameters render in separate sections, with request bodies in their own section.
  • Responses render in status-code tabs and expand response schemas inline without linking them to standalone model pages.
  • Generated pages provide a contextual action menu for copying or viewing their Markdown and opening the current page as context in ChatGPT or Claude.
  • In pages mode, each components.schemas entry generates a model page and local schema $ref values link to it.
  • In inline mode, each operation includes its reachable component schemas and local schema $ref values link to those sections.
  • Inline schemas remain inline in operation documentation.
  • Operation and model slugs are deterministic, with numeric suffixes for collisions.

Current limitations

  • Swagger/OpenAPI 2.0 documents are rejected.
  • External $ref documents are not resolved.
  • Callbacks and webhooks are not rendered as operations.
  • The first tag is the canonical navigation group for a multi-tag operation.
  • Themes other than Material for MkDocs are not currently tested or supported.

Examples

Petstore

The Petstore example demonstrates the standard rendering contract:

.venv/bin/python examples/petstore/verify.py
.venv/bin/mkdocs build --strict -f examples/petstore/mkdocs.yml

Multiple APIs

The multiple-API example generates two isolated references in one build:

.venv/bin/mkdocs build --strict -f examples/multiple/mkdocs.yml

RingCentral

The RingCentral example stress-tests the plugin with 517 operations and 1,481 reusable models:

.venv/bin/python examples/ringcentral/verify.py
.venv/bin/mkdocs build --strict -f examples/ringcentral/mkdocs.yml

Its output is written to site-ringcentral/.

Development

Clone the repository and install it in editable mode with test dependencies:

python -m venv .venv
. .venv/bin/activate
python -m pip install -e '.[test]'

Run the test suite:

pytest

Build the project documentation:

mkdocs build --strict

Or preview it locally:

mkdocs serve

License

mkdocs-openapi is distributed under the MIT License. See LICENSE for details.

Metadata

Release files for mkdocs-openapi 0.3.3

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-openapi 0.3.3
File Size Uploaded Provenance
mkdocs_openapi-0.3.3.tar.gz 257.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-openapi 0.3.3
File Interpreter ABI Platform
mkdocs_openapi-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 288.0 kB

Release files / mkdocs_openapi-0.3.3.tar.gz

Download URL mkdocs_openapi-0.3.3.tar.gz
Size 257.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ff6e213e7d69f7923bd98807eff88a5e2785dbcd5316be502da18b782320c1a2
BLAKE2b-256 checksum
How to use checksums
596b08c881a1ba8d4619868d05a74b02577303ba8e62970baf0263c705c987e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Release files / mkdocs_openapi-0.3.3-py3-none-any.whl

Download URL mkdocs_openapi-0.3.3-py3-none-any.whl
Size 31.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8aedcf0d013dc1b09b75d2c3d2a1ab8f3c34f013c124f1b46332b3155fd8ce26
BLAKE2b-256 checksum
How to use checksums
7b6831a131cd3613ddc7ba7ea07e5069ae31d374517873d61a4e1021e7a4f555
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Security for mkdocs-openapi 0.3.3

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mkdocs_openapi-0.3.3.tar.gz

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 Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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