Skip to main content

Export a JSON Schema document to Markdown documentation.

Project description

jsonschema-markdown

Generate markdown documentation from JSON Schema files. The main goal is to generate documentation that is easy to read and understand.

Can be used as a command line tool or as a library.

Installation

pipx install jsonschema-markdown

Usage

To use jsonschema-markdown as a CLI, just pass the filename as an argument and redirect the output to a file.

$ jsonschema-markdown --help
Usage: jsonschema-markdown [OPTIONS] FILENAME

  Load FILENAME and output a markdown version.

  Use '-' as FILENAME to read from stdin.

Options:
  -t, --title TEXT          Do not use the title from the schema, use this
                            title instead.
  --footer / --no-footer    Add a footer with a link to the project.
                            [default: footer]
  --resolve / --no-resolve  [Experimental] Resolve $ref pointers.  [default:
                            no-resolve]
  --debug / --no-debug      Enable debug output.  [default: no-debug]
  --version                 Show the version and exit.
  --help                    Show this message and exit.

# Example
$ jsonschema-markdown schema.json > schema.md

Usage with Docker

The jsonschema-markdown command is also available as a Docker image. To use it, you can mount the schema file as a volume.

cat my-schema.json | docker run --rm -i elisiariocouto/jsonschema-markdown - > schema.md

⚠️ Warning: Do not pass the -t flag.

The Docker image is available at:

Usage as a library

To use it as a library, load your JSON schema file as Python dict and pass it to generate. The function will return a string with the markdown.

import jsonschema_markdown

with open('schema.json') as f:
    schema = json.load(f)

markdown = jsonschema_markdown.generate(schema)

Features

Partially inspired by json-schema-for-humans, this project does not currently support all features of JSON Schema, but it should support:

  • Required fields
  • String patterns
  • Enumerations
  • Default values
  • Descriptions and titles
  • Nested objects
  • Basic OneOf, AnyOf, AllOf functionality
  • Arrays
  • Integers with minimum, maximum values and exclusives
  • Boolean values
  • Deprecation notices (searches for case-insensitive deprecated in the field description)

Caveats

  • This project is still in early development, and the output may change in the future.
  • Custom definitions are expected to be in the same file as the schema that uses them, in the definitions or $defs parameter at the root of the document.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

jsonschema_markdown-0.3.3-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file jsonschema_markdown-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: jsonschema_markdown-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1016-azure

File hashes

Hashes for jsonschema_markdown-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 784894592c7b4ff0379483d1a00d1a86866b2de11da804a80098dda2172eaa92
MD5 1aa04ea21d785b84bcb5c09eb00446b3
BLAKE2b-256 2ab0e2cf21f5f9063b0b5a6d83ce069b6adc5ee55813ff43e5edf8e656a03250

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 Pingdom Monitoring Sentry Error logging StatusPage Status page