将JSON Schema转换为可读的Markdown文档
项目描述
jsonschema2md
将JSON Schemas转换为简单、可读的Markdown文档。
例如
{
"$id": "https://example.com/person.schema.json",
"$schema": "https://json-schema.fullstack.org.cn/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."
}
}
}
将被转换为
Person
人的对象的JSON Schema。
属性
firstName
(字符串):人的名字。lastName
(字符串):人的姓氏。
有关更详细的示例,请参阅示例目录。
安装
使用pip安装
pip install jsonschema2md
用法
从命令行界面
jsonschema2md [OPTIONS] <input.json> <output.md>
从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))
选项
examples-as-yaml
:解析YAML格式的示例,而不是JSON。(布尔值
,默认:False
)show-examples
:仅解析主对象、仅属性或所有属性。(字符串
,默认all
,选项:object
,properties
,all
)
pre-commit钩子
您可以使用以下方法使用pre-commit钩子:
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
贡献
有错误、问题或建议?请随意在问题跟踪器中发布问题或创建pull request!有关更多信息,请参阅CONTRIBUTING.md。
安装pre-commit钩子
pip install pre-commit
pre-commit install --allow-missing-config
变更日志
请参阅CHANGELOG.md。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
jsonschema2md2-1.3.0.tar.gz (9.8 kB 查看哈希值)
构建分布
jsonschema2md2-1.3.0-py3-none-any.whl (10.3 kB 查看哈希值)
关闭
jsonschema2md2-1.3.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | bef70345aab7cc084de208d3642a6a94e07d294796e2ca325283e566f3b36805 |
|
MD5 | e2d700e4f4d6f7a2f2834c8733b32dde |
|
BLAKE2b-256 | 3e7b838d832b3a13b7e6514489b16dd7fa62389fccdcc68feaa765ffe38e01c8 |
关闭
jsonschema2md2-1.3.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | abe817c90bb37d1b06159267b6a0a3da055050ebb82e158d89b9d21c9229687a |
|
MD5 | 10d74f0dfd31bff132ff402fdacb330e |
|
BLAKE2b-256 | d917a3768133b0b51980b935988f6d7a364f3ddf22a149005a82bb044564b593 |