Skip to main content

Export a JSON Schema document to Markdown documentation.

Project description

jsonschema-markdown

PyPI Docker

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.

Easy to use in CI/CD pipelines, as a Docker image is available.

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]
  --empty-columns / --no-empty-columns
                                  Remove empty columns from the output, useful
                                  when deprecated or examples are not used.
                                  [default: empty-columns]
  --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

The goal is to support the latest JSON Schema specification, 2020-12. However, this project does not currently support all features, but it should support:

  • Required fields
  • String patterns
  • Enumerations
  • Default values
  • Descriptions and titles
  • Nested objects using $defs or definitions
  • Basic oneOf, anyOf, allOf functionality
  • Arrays
  • Integers with minimum, maximum values and exclusives
  • Boolean values
  • Deprecated fields (using the deprecated option, additionaly 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 Distribution

jsonschema_markdown-0.3.10.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

jsonschema_markdown-0.3.10-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file jsonschema_markdown-0.3.10.tar.gz.

File metadata

  • Download URL: jsonschema_markdown-0.3.10.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for jsonschema_markdown-0.3.10.tar.gz
Algorithm Hash digest
SHA256 232466430dcf2be505f20e9caa8e3f5da946ae06f78941855d13c8706d2aa67c
MD5 4ae5590ad8fa56cc9665b9925cf0900d
BLAKE2b-256 4cd8ec54dd2629aa81889e4264cd83efddba73166617526582504dfc025ebf20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jsonschema_markdown-0.3.10-py3-none-any.whl
Algorithm Hash digest
SHA256 65d3c7f147a8f02f54030d617bad89ddbe6d6ba1b83954713ea666bc324b0f71
MD5 af65907d3c8324997efd1fef601af073
BLAKE2b-256 562ae045857b0670743202fbe5f054c511ba23bd377d6e4d2d4c8f5e5d838e94

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page