【发布时间】:2021-04-29 13:30:10
【问题描述】:
我注意到以下内容:Reusable enum types in json schema,它谈到了在 JSON 模式中定义可重用的枚举类型。
我会假设使用这种可重用的枚举类型是微不足道的,只需为“类型”值指定(在这种情况下)“MyEnum”的值。
我不知道 Oxygen XML 的结果是否权威,但我尝试了类似以下的方法:
{
"$schema": "https://json-schema.org/draft/2019-09/schema#",
"type": "object",
"properties": {
"content": {"$ref": "#/definitions/content_type"}
},
"additionalProperties": false,
"definitions": {
"costCategory_type": {
"type": "object",
"enum": ["VH", "H", "M", "L"]
},
"allowedDevices_type": {
"type": "object",
"properties": {
"costCategory": {
"type": "costCategory_type"
},
在靠近底部的那一行,我引用了“costCategory_type”,Oxygen 给了我一个语法错误,说
#/definitions/allowedDevices_type/properties/costCategory/type:未知类型:[costCategory_type]
我错过了什么?
【问题讨论】:
标签: jsonschema