Skip to main content

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.

Goals

  • Provide an API to generate OpenAPI Documentation files.
  • Providing functions to handle OpenAPI Documentation, like those to generate other kinds of documentation from source OpenAPI Documentation files.
  • Support enough features to be useful for the most common API scenarios, especially for OAD files that are generated automatically from web frameworks.

Non-Goals

  • To implement the whole OAD Specification.
  • For the features that generate artifacts: OpenAPI Documentation files are supposed to be coming from trusted sources. Trying to handle source files from untrusted sources and potentially causing HTML injection is out of the scope of this library.

Limitations

  • Partial support for Parameter properties: style, allow_reserved, explode are not handled.
  • Doesn't implement validation of values, currently it is only concerned in generating code from a higher level API (it might be extended in the future with classes for validation).
  • The features to generate artifacts from OpenAPI Documentation currently support only Version 3 of the specification.

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.

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

essentials-openapi-1.0.0.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

essentials_openapi-1.0.0-py3-none-any.whl (43.2 kB view details)

Uploaded Python 3

File details

Details for the file essentials-openapi-1.0.0.tar.gz.

File metadata

  • Download URL: essentials-openapi-1.0.0.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for essentials-openapi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 40a794a801b5ccbeef631b8a85e8b601517ea987119280c7db052faf9854ac4a
MD5 ba70591b3c369e7efa8ec1eaac72055a
BLAKE2b-256 28d356fe4f2b807169953f3b5f7699bab69b096d95e6103ecd8a499849ed5705

See more details on using hashes here.

File details

Details for the file essentials_openapi-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for essentials_openapi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cff7b14d44cf53c0c54df9d3a511344c4952aa165108c705a92f7777550ec3cd
MD5 05557224d4cb314706dc6f046a13756f
BLAKE2b-256 29dab8f2c5f85421c8f15486519d677bc03dc042841e453cadcf34463dfd9de8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page