将JSON Schema转换为可读的Markdown文档
项目描述
jsonschema2md
将JSON Schema转换为简单、可读的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钩子
您可以使用
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.md。
安装pre-commit钩子
pip install pre-commit
pre-commit install --allow-missing-config
变更日志
查看CHANGELOG.md。
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
jsonschema2md-1.3.0.tar.gz (9.8 kB 查看哈希值)
构建分布
jsonschema2md-1.3.0-py3-none-any.whl (10.3 kB 查看哈希值)
关闭
jsonschema2md-1.3.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 5ee8f6674c9fec7303daa24c79023805caf2f2fefb99834813bd746227d146ea |
|
MD5 | 5899953159cd16e9384818da9bbd762b |
|
BLAKE2b-256 | 67bd6c6d5c48a269c13212d1c7aa294e0d1a3948c97e91ee01ce5e4218e4567d |
关闭
jsonschema2md-1.3.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ba089d46a3ac6f43b10caeaf8cd1b3978c7bd15c8e287de78d247666cb8857c0 |
|
MD5 | 337cbfc9a74217bb7137a54148db80d6 |
|
BLAKE2b-256 | a298dc9f7a2d8d1f0625fa19eb65a613e40bbff43d102d92c6802e28f213bb0e |