Generate static HTML documentation from JSON schemas
Project description
JSON Schema for Humans
Quickly generate a beautiful HTML static page documenting a JSON schema
Documentation (with visual examples)
Installation
pip install json-schema-for-humans
Usage
generate-schema-doc [OPTIONS] SCHEMA_FILE [RESULT_FILE]
SCHEMA_FILE
must be a valid JSON Schema
The default value for RESULT_FILE
is schema_doc.html
Options
--expand-buttons
Off by default
Add an Expand all
and a Collapse all
button at the top of the generated documentation
--link-to-reused-ref/--no-link-to-reused-ref
On by default
If several $ref
points to the same definition, only render the documentation for this definition the first time.
All other occurrences are replaced by an achor link to the first occurrence.
--minify/--no-minify
On by default
Minify the output HTML document
--deprecated-from-description
Off by default
Mark a property as deprecated (with a big red badge) if the description contains the string [Deprecated
--default-from-description
Off by default
Extract the default value of a property from the description like this: [Default `the_default_value`]
The default value from the "default" attribute will be used in priority
--copy-css/--no-copy-css
On by default
Copy schema_doc.css
to the same directory as RESULT_FILE
.
--copy-js/--no-copy-js
On by default.
Copy schema_doc.min.js
to the same directory as RESULT_FILE
.
This file contains the logic for the anchor links
What's supported
See the excellent Understanding JSON Schema to understand what are those checks
The following are supported:
- Types
- Regular expressions
- String length
- Numeric types multiples and range
- Constant and enumerated values
- Required properties
- Pattern properties
- Default values
- Array
minItems
,maxItems
,uniqueItems
,items
(schema that must apply to all of the array items), andcontains
- Combining schema with
oneOf
,allOf
,anyOf
, andnot
- Examples
These are not supported at the moment (PRs welcome!):
- String format
- Property names and size
- Array items at specific index (for example, first item must be a string and second must be an integer)
- Property dependencies
- Media
- Conditional subschemas
References
References from inside a schema and to schemas in other files are supported (for example { $ref: "#/definitions/something" }
will be replaced by the
content of schema["definitions"]["something"]
).
You can have a description
next to a $ref
, it will be displayed in priority to the description from the referenced element.
If you have several attributes using the same definition, the definition will only be rendered once.
All other usages of the same definition will be replaced with an anchor link to the first render of the definition.
This can be turned off using --no-link-to-reused-ref
. See With references
in the examples.
Anchor links
Clicking on a property or tab in the output documentation will set the hash of the current window. Opening this anchor link will expand all needed properties and scroll to this section of the schema. Useful for pointing your users to a specific setting.
For this feature to work, you need to include the Javascript file (schema_doc.min.js
) that is automatically copied next to the output HTML file (schema_doc.html
by default).
Development
Testing
Just run tox
tox
Modifying Javascript
schema_doc.js
is not minified automatically, you are responsible for doing it yourself
Generating doc
The documentation is generated using jekyll and hosted on GitHub Pages
- Change your current working directory to
docs
- Run
python generate_examples.py
. This will get all examples fromtests/cases
, render the resulting HTML and include it in the appropriate folders in the jekyll site. - If you have added an example, add the file name (without
.json
), the display name and description in_data/examples.yaml
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 json-schema-for-humans-0.10.0.tar.gz
.
File metadata
- Download URL: json-schema-for-humans-0.10.0.tar.gz
- Upload date:
- Size: 36.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f21556185ce9a39c168c8a1c0243e42c85c747916f3a34db8322bcd22e96bcb |
|
MD5 | 4c22c425dc7bf15f9a03694ca8ccc3a0 |
|
BLAKE2b-256 | 2fd5411b7b668a9d33a59ead3121485114ede09357e809f13d9310e032cb2e22 |
File details
Details for the file json_schema_for_humans-0.10.0-py3-none-any.whl
.
File metadata
- Download URL: json_schema_for_humans-0.10.0-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | beafe7639f9e88e05088b8787d4e96dc531065874fe8b84416d945be21d4dea2 |
|
MD5 | 0444d4a780e5f53967c38e021759712c |
|
BLAKE2b-256 | 16d22a36f2b9089f7f7bf657005963c3ca39d6cc8e84abe88c459fcb13b5fea3 |