santhosh-tekuri/jsonschema

GitHub: santhosh-tekuri/jsonschema

一个 Go 语言编写的高合规性 JSON Schema 校验库,同时提供命令行工具,支持从 draft-4 到 2020-12 的全部主流草案。

Stars: 1244 | Forks: 129

# jsonschema v6.0.2 [![许可证](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![GoDoc](https://godoc.org/github.com/santhosh-tekuri/jsonschema?status.svg)](https://pkg.go.dev/github.com/santhosh-tekuri/jsonschema/v6) [![Go Report Card](https://goreportcard.com/badge/github.com/santhosh-tekuri/jsonschema/v6)](https://goreportcard.com/report/github.com/santhosh-tekuri/jsonschema/v6) [![构建状态](https://static.pigsec.cn/wp-content/uploads/repos/cas/55/55031da4fcf4fbfebf9b6ee84230aa91e62ba8b90456affcf409fce4a4e1e6b3.svg)](https://github.com/santhosh-tekuri/jsonschema/actions/workflows/go.yaml) [![codecov](https://codecov.io/gh/santhosh-tekuri/jsonschema/branch/boon/graph/badge.svg?token=JMVj1pFT2l)](https://codecov.io/gh/santhosh-tekuri/jsonschema/tree/boon) 示例请参见 [godoc](https://pkg.go.dev/github.com/santhosh-tekuri/jsonschema/v6) ## 库功能 - [x] 通过 [JSON-Schema-Test-Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite)(不包括可选部分,在 [bowtie](https://bowtie-json-schema.github.io/bowtie/#) 与其他实现进行对比) - [x] [![draft-04](https://img.shields.io/endpoint?url=https://bowtie.report/badges/go-jsonschema/compliance/draft4.json)](https://bowtie.report/#/dialects/draft4) - [x] [![draft-06](https://img.shields.io/endpoint?url=https://bowtie.report/badges/go-jsonschema/compliance/draft6.json)](https://bowtie.report/#/dialects/draft6) - [x] [![draft-07](https://img.shields.io/endpoint?url=https://bowtie.report/badges/go-jsonschema/compliance/draft7.json)](https://bowtie.report/#/dialects/draft7) - [x] [![draft/2019-09](https://img.shields.io/endpoint?url=https://bowtie.report/badges/go-jsonschema/compliance/draft2019-09.json)](https://bowtie.report/#/dialects/draft2019-09) - [x] [![draft/2020-12](https://img.shields.io/endpoint?url=https://bowtie.report/badges/go-jsonschema/compliance/draft2020-12.json)](https://bowtie.report/#/dialects/draft2020-12) - [x] 检测无限循环陷阱 - [x] `$schema` 循环 - [x] 校验循环 - [x] 自定义 `$schema` url - [x] 基于 vocabulary 的校验 - [x] 自定义 regex 引擎 - [x] format 断言 - [x] 在 draft >= 2019-09 中启用的 flag - [x] 自定义 format 注册 - [x] 内置 format - [x] regex, uuid - [x] ipv4, ipv6 - [x] hostname, email - [x] date, time, date-time, duration - [x] json-pointer, relative-json-pointer - [x] uri, uri-reference, uri-template - [x] iri, iri-reference - [x] period, semver - [x] content 断言 - [x] 在 draft >= 7 中启用的 flag - [x] contentEncoding - [x] base64 - [x] 自定义 - [x] contentMediaType - [x] application/json - [x] 自定义 - [x] contentSchema - [x] 错误 - [x] 可内省 - [x] 层级结构 - [x] 使用 `#` 的替代显示方式 - [x] 输出 - [x] flag - [x] basic - [x] detailed - [x] 自定义 vocabulary - draft >=2019-19 通过 `$vocabulary` 启用 - draft <= 7 通过 flag 启用 - [x] 混合 dialect 支持 ## CLI v0.7.0 安装:`go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest` 请注意,CLI 是独立进行版本控制的。你可以在 git 标签 `cmd/jv/v0.7.0` 中看到它。 ``` Usage: jv [OPTIONS] SCHEMA [INSTANCE...] Options: -c, --assert-content Enable content assertions with draft >= 7 -f, --assert-format Enable format assertions with draft >= 2019 --cacert pem-file Use the specified pem-file to verify the peer. The file may contain multiple CA certificates -d, --draft version Draft version used when '$schema' is missing. Valid values 4, 6, 7, 2019, 2020 (default 2020) -h, --help Print help information -k, --insecure Use insecure TLS connection -o, --output format Output format. Valid values simple, alt, flag, basic, detailed (default "simple") -q, --quiet Do not print errors -v, --version Print build information ``` - [x] 校验错误退出码为 `1`,用法错误退出码为 `2` - [x] 同时校验 schema 和多个 instance - [x] 同时支持 json 和 yaml 文件 - [x] 支持标准输入,使用 `-` - [x] 带有可解析输出的静默模式 - [x] 支持 http(s) url - [x] 用于校验的自定义证书,使用 `--cacert` - [x] 跳过证书验证的 flag,使用 `--insecure`
标签:EVTX分析, Go, JSON Schema, Ruby工具, 开发工具库, 数据校验, 日志审计, 正则表达式