# jsonschema2md
[![](https://flat.badgen.net/pypi/v/jsonschema2md?icon=pypi)](https://pypi.org/project/jsonschema2md)
[![](https://flat.badgen.net/github/release/sbrunner/jsonschema2md)](https://github.com/sbrunner/jsonschema2md/releases)
[![](https://flat.badgen.net/github/checks/sbrunner/jsonschema2md/)](https://github.com/sbrunner/jsonschema2md/actions)
![](https://flat.badgen.net/github/last-commit/sbrunner/jsonschema2md)
![](https://flat.badgen.net/github/license/sbrunner/jsonschema2md)
_Convert JSON Schemas to simple, human-readable Markdown documentation._
---
For example:
```json
{
"$id": "https://example.com/person.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person",
"description": "JSON Schema for a person object.",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
}
}
}
```
will be converted to:
> # Person
>
> _JSON Schema for a person object._
>
> ## Properties
>
> - **`firstName`** _(string)_: The person's first name.
> - **`lastName`** _(string)_: The person's last name.
See the [examples](https://github.com/sbrunner/jsonschema2md/tree/master/examples)
directory for more elaborate examples.
---
## Installation
Install with pip
```sh
pip install jsonschema2md
```
## Usage
### From the CLI
```sh
jsonschema2md [OPTIONS] <input.json> <output.md>
```
### From Python
```python
import json
import jsonschema2md
parser = jsonschema2md.Parser(
examples_as_yaml=False,
show_examples="all",
)
with open("./examples/food.json", "r") as json_file:
md_lines = parser.parse_schema(json.load(json_file))
print(''.join(md_lines))
```
### Options
- `examples-as-yaml`: Parse examples in YAML-format instead of JSON. (`bool`, default:
`False`)
- `show-examples`: Parse examples for only the main object, only properties, or all.
(`str`, default `all`, options: `object`, `properties`, `all`)
## pre-commit hook
You can use the pre-commit hook with:
```yaml
repos:
- repo: https://github.com/sbrunner/jsonschema2md
rev: <version> # Use the ref you want to point at
hooks:
- id: jsonschema2md
files: schema.json
args:
- --pre-commit
- schema.json
- schema.md
```
## Contributing
Bugs, questions or suggestions? Feel free to post an issue in the
[issue tracker](https://github.com/sbrunner/jsonschema2md/issues/) or to make a pull
request! See
[Contributing.md](https://github.com/sbrunner/jsonschema2md/blob/master/CONTRIBUTING.md)
for more info.
Install the pre-commit hooks:
```bash
pip install pre-commit
pre-commit install --allow-missing-config
```
## Changelog
See [Changelog.md](https://github.com/sbrunner/jsonschema2md/blob/master/CHANGELOG.md).
Raw data
{
"_id": null,
"home_page": "https://github.com/sbrunner/jsonschema2md",
"name": "jsonschema2md2",
"maintainer": "St\u00e9phane Brunner",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "stephane.brunner@gmail.com",
"keywords": "JSON Schema, Markdown, Converter, Parser, Documentation",
"author": "Ralf Gabriels",
"author_email": "ralfg@hotmail.be",
"download_url": "https://files.pythonhosted.org/packages/3e/7b/838d832b3a13b7e6514489b16dd7fa62389fccdcc68feaa765ffe38e01c8/jsonschema2md2-1.3.0.tar.gz",
"platform": null,
"description": "# jsonschema2md\n\n[![](https://flat.badgen.net/pypi/v/jsonschema2md?icon=pypi)](https://pypi.org/project/jsonschema2md)\n[![](https://flat.badgen.net/github/release/sbrunner/jsonschema2md)](https://github.com/sbrunner/jsonschema2md/releases)\n[![](https://flat.badgen.net/github/checks/sbrunner/jsonschema2md/)](https://github.com/sbrunner/jsonschema2md/actions)\n![](https://flat.badgen.net/github/last-commit/sbrunner/jsonschema2md)\n![](https://flat.badgen.net/github/license/sbrunner/jsonschema2md)\n\n_Convert JSON Schemas to simple, human-readable Markdown documentation._\n\n---\n\nFor example:\n\n```json\n{\n \"$id\": \"https://example.com/person.schema.json\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"title\": \"Person\",\n \"description\": \"JSON Schema for a person object.\",\n \"type\": \"object\",\n \"properties\": {\n \"firstName\": {\n \"type\": \"string\",\n \"description\": \"The person's first name.\"\n },\n \"lastName\": {\n \"type\": \"string\",\n \"description\": \"The person's last name.\"\n }\n }\n}\n```\n\nwill be converted to:\n\n> # Person\n>\n> _JSON Schema for a person object._\n>\n> ## Properties\n>\n> - **`firstName`** _(string)_: The person's first name.\n> - **`lastName`** _(string)_: The person's last name.\n\nSee the [examples](https://github.com/sbrunner/jsonschema2md/tree/master/examples)\ndirectory for more elaborate examples.\n\n---\n\n## Installation\n\nInstall with pip\n\n```sh\npip install jsonschema2md\n```\n\n## Usage\n\n### From the CLI\n\n```sh\njsonschema2md [OPTIONS] <input.json> <output.md>\n```\n\n### From Python\n\n```python\nimport json\nimport jsonschema2md\n\nparser = jsonschema2md.Parser(\n examples_as_yaml=False,\n show_examples=\"all\",\n)\nwith open(\"./examples/food.json\", \"r\") as json_file:\n md_lines = parser.parse_schema(json.load(json_file))\nprint(''.join(md_lines))\n```\n\n### Options\n\n- `examples-as-yaml`: Parse examples in YAML-format instead of JSON. (`bool`, default:\n `False`)\n- `show-examples`: Parse examples for only the main object, only properties, or all.\n (`str`, default `all`, options: `object`, `properties`, `all`)\n\n## pre-commit hook\n\nYou can use the pre-commit hook with:\n\n```yaml\nrepos:\n - repo: https://github.com/sbrunner/jsonschema2md\n rev: <version> # Use the ref you want to point at\n hooks:\n - id: jsonschema2md\n files: schema.json\n args:\n - --pre-commit\n - schema.json\n - schema.md\n```\n\n## Contributing\n\nBugs, questions or suggestions? Feel free to post an issue in the\n[issue tracker](https://github.com/sbrunner/jsonschema2md/issues/) or to make a pull\nrequest! See\n[Contributing.md](https://github.com/sbrunner/jsonschema2md/blob/master/CONTRIBUTING.md)\nfor more info.\n\nInstall the pre-commit hooks:\n\n```bash\npip install pre-commit\npre-commit install --allow-missing-config\n```\n\n## Changelog\n\nSee [Changelog.md](https://github.com/sbrunner/jsonschema2md/blob/master/CHANGELOG.md).\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Convert JSON Schema to human-readable Markdown documentation",
"version": "1.3.0",
"project_urls": {
"Homepage": "https://github.com/sbrunner/jsonschema2md",
"Repository": "https://github.com/sbrunner/jsonschema2md"
},
"split_keywords": [
"json schema",
" markdown",
" converter",
" parser",
" documentation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d917a3768133b0b51980b935988f6d7a364f3ddf22a149005a82bb044564b593",
"md5": "10d74f0dfd31bff132ff402fdacb330e",
"sha256": "abe817c90bb37d1b06159267b6a0a3da055050ebb82e158d89b9d21c9229687a"
},
"downloads": -1,
"filename": "jsonschema2md2-1.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "10d74f0dfd31bff132ff402fdacb330e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 10280,
"upload_time": "2024-08-07T10:10:46",
"upload_time_iso_8601": "2024-08-07T10:10:46.282219Z",
"url": "https://files.pythonhosted.org/packages/d9/17/a3768133b0b51980b935988f6d7a364f3ddf22a149005a82bb044564b593/jsonschema2md2-1.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3e7b838d832b3a13b7e6514489b16dd7fa62389fccdcc68feaa765ffe38e01c8",
"md5": "e2d700e4f4d6f7a2f2834c8733b32dde",
"sha256": "bef70345aab7cc084de208d3642a6a94e07d294796e2ca325283e566f3b36805"
},
"downloads": -1,
"filename": "jsonschema2md2-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "e2d700e4f4d6f7a2f2834c8733b32dde",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 9789,
"upload_time": "2024-08-07T10:10:47",
"upload_time_iso_8601": "2024-08-07T10:10:47.548218Z",
"url": "https://files.pythonhosted.org/packages/3e/7b/838d832b3a13b7e6514489b16dd7fa62389fccdcc68feaa765ffe38e01c8/jsonschema2md2-1.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-07 10:10:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sbrunner",
"github_project": "jsonschema2md",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "jsonschema2md2"
}