我搜索了一个允许从两个JSONSchema生成JSONPatch的工具。例子:
JSONSchema A:
{
"$id": "https://example.com/person.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"age": {
"description": "Age in years which must be equal to or greater than zero.",
"type": "integer",
"minimum": 0
}
}
}
JSON对象可以在哪里:
{"firstName": "John", "lastName": "Doe", "age": 42 }
JSONSchema B(无年龄):
{
"$id": "https://example.com/person.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
}
}
}
生成的 JSONPatch 应该是:
[
{ "op": "remove", "path": "/age" }
]
要在应用补丁后获取,对象:
{"firstName": "John", "lastName": "Doe" }
有一些工具吗?