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.
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
ordefinitions
- 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-insensitivedeprecated
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jsonschema_markdown-0.3.11.tar.gz
.
File metadata
- Download URL: jsonschema_markdown-0.3.11.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7485720bfaf3b8df868fdba0b7245d7f4ca2642dbfa74e64b64607a4b693ac83 |
|
MD5 | 5a92542ee42189d8f39a7b9235467469 |
|
BLAKE2b-256 | f00ccf802a177ee71f64e44fd4e008a4729af7053ab5f7bb96d4172b23a9e3d3 |
Provenance
File details
Details for the file jsonschema_markdown-0.3.11-py3-none-any.whl
.
File metadata
- Download URL: jsonschema_markdown-0.3.11-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9ab6215cdc409b21e69ef51275b45e38b7c5410fe0001db6079f7549f306607 |
|
MD5 | a6db4336c7f69c8f1a1b82c52a2bb11b |
|
BLAKE2b-256 | 319b68dd18775e3b3e5d337a94d6049c0bbc16460effd1fbe4def7ab62da671d |