Neoteroi / essentials-openapi

Functions to handle OpenAPI Documentation.
MIT License
23 stars 9 forks source link
documentation documentation-generator openapi swagger

Build pypi versions license codecov

essentials-openapi

Classes to generate OpenAPI Documentation v3 and v2, in JSON and YAML, and to generate other kinds of documents from OpenAPI Documentation files.

pip install essentials-openapi

To install with dependencies to generate other kinds of artifacts from source OpenAPI Documentation files:

pip install essentials-openapi[full]

Useful links

Usage

This library has been originally created to implement generation of OpenAPI Documentation in the BlackSheep web framework. However, this package is abstracted from that web framework and can be reused for other applications. Today this library also offers functions to generate documentation from source OpenAPI Documentation files.

Features to generate artifacts from Open API Documentation

These require the full package: install it using pip install essentials-openapi[full].

To generate output for MkDocs and PyMdown extentions:

oad gen-docs -s example1-openapi.json -d output.md

Example MkDocs documentation

Example of MkDocs documentation generated using Neoteroi/mkdocs-plugins.


To generate a PlantUML class diagram of the components schemas:

oad gen-docs -s source-openapi.json -d schemas.wsd --style "PLANTUML_SCHEMAS"

Example schemas

Example of PlantUML diagram generated from components schemas.


To generate a PlantUML class diagram with an overview of API endpoints:

oad gen-docs -s source-openapi.json -d schemas.wsd --style "PLANTUML_API"

Example api overview

Example of PlantUML diagram generated from path items.

Goals

Non-Goals

Limitations

Styles

Style Int value Description
MKDOCS 1 Markdown for MkDocs and PyMdown extensions.
MARKDOWN 2 Basic Markdown.
HTML 3 Plain HTML (planned, not yet implemented).
PLANTUML_SCHEMAS 100 PlantUML schema for components schemas.
PLANTUML_API 101 PlantUML schema for API endpoints.

Supported sources for OpenAPI Documentation

Source Example
YAML file ./docs/swagger.yaml
JSON file ./docs/swagger.json
URL returning YAML on HTTP GET https://example-domain.net/swagger/v1/swagger.yaml
URL returning JSON on HTTP GET https://example-domain.net/swagger/v1/swagger.json