Skip to main content

OpenAPI Documentation Generator

This is a Python script that generates API documentation from an OpenAPI specification file.

Usage

pip install openapi-markdown

CLI

You can use openapi2markdown command as follows:

% openapi2markdown --help                
Usage: openapi2markdown [OPTIONS] INPUT_FILE [OUTPUT_FILE]

  Convert OpenAPI spec to Markdown documentation.

  INPUT_FILE: Path to OpenAPI specification file (JSON or YAML) OUTPUT_FILE:
  Path where markdown file will be generated (optional, defaults to INPUT_FILE
  with .md extension)

Options:
  -t, --templates-dir DIRECTORY  Custom templates directory path
  -f, --filter-paths TEXT        Only generate apis that start with the given
                                 path, multiple paths are allowed

Library

from openapi_markdown.generator import to_markdown

apiFile = "./tests/openapi.json"
outputFile = "api_doc.md"
templatesDir = "templates"
options = {
    'filter_paths': ['/client']
}

to_markdown(apiFile, outputFile, templates_dir, options)
  • If you want to use your own template, creates 'templates' directory and put api_doc_template.md.j2 file in it.
  • You can change templates directory by passing it as the 3rd argument of to_markdown.

Default templates

There are internal templates you can use. If not set default is used.

  • templates - default
  • templates/embed - prints objects hierarchially as list in every request/response

Development

Requirements

  • Python 3.x
  • json
  • PyYAML
  • openapi-core
  • Jinja2

pip install -r requirement.txt

install a project in editble mode pip install -e ./

run tests

python -m unittest

Deploy

python3 -m pip install --upgrade twine
./pypi.sh

Metadata

Release files for openapi-markdown 0.4.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 openapi-markdown 0.4.3
File Size Uploaded
openapi_markdown-0.4.3.tar.gz 20.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openapi-markdown 0.4.3
File Interpreter ABI Platform
openapi_markdown-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 30.4 kB

Release files / openapi_markdown-0.4.3.tar.gz

Download URL openapi_markdown-0.4.3.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d9950dab5c1396636b7e36d0b2ed510a6a3ef2d06a1c2717b1454f748cf3b4eb
BLAKE2b-256 checksum
How to use checksums
c4c2626872443d3f163c7329db99df99c77e4636243c5af1aeac7b567ab2edc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / openapi_markdown-0.4.3-py3-none-any.whl

Download URL openapi_markdown-0.4.3-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
435d35693bf2455768bd5c30075681f154cc37fd6db6ea8829e1fb9862f037b8
BLAKE2b-256 checksum
How to use checksums
7b98da02ade1759ff02eec932bc6a812d67daa9ceb70561f1e6d5e9c81e8e2b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.4.3 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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