简体   繁体   English

json-schema附加元数据

[英]json-schema additional metadata

It is possible to add additional or custom metadata (other than title and description) to a json schema property? 是否可以向json架构属性添加其他元素或自定义元数据(标题和描述除外)?

Ideally I'd like to add some metadata like so: 理想情况下,我想添加一些元数据,如下所示:

//...
"properties": {
  "contactFullName": {
    "$ref": "#/definitions/fullName",
    "custom": "my custom metadata here"
  }
}
//...

Can you add something to definitions to allow that? 你能为definitions添加一些内容吗?

You don't have to do anything special to use additional metadata keywords. 您无需执行任何特殊操作即可使用其他元数据关键字。 You can just use them. 你可以使用它们。 In JSON Schema it is not an error to include undefined keywords. 在JSON Schema中,包含未定义的关键字不是错误。 Anything that doesn't have JSON Schema semantics should be quietly ignored. 任何没有JSON Schema语义的东西都应该被忽略。 So, the following schema is completely valid and should not conflict with any validator implementation. 因此,以下模式完全有效,不应与任何验证器实现冲突。

{
  "title": "Foo",
  "description": "All the foo you can GET",
  "version": "1.0.3",
  "author": "Jason Desrosiers",
  "type": "object",
  "properties": {
    "id": { "type": "string" }
  }
}

您可以使用description属性并在其中放置某个结构,然后可以根据需要进行解释和应用(比如JSON模式中的JSON,可以这么说)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM