Json架构"不在"枚举类型?

时间:2015-07-24 12:16:37

标签: json validation schema jsonschema

我想使用oneOf架构,这些架构的区别仅在于xyType属性的值。我想要其中两个:一个xyType设置为"1",另一个xyType 任何其他值。可以使用json模式完成吗?

"oneOf": [
    {
        "properties": {
            "xyType": "enum": ["1"],
            "whatever" : "string"
        },
        "type": "object"
    },
    {
        "properties": {
            "xyType": "enum": [], /// NOT "1"?
            "whatever" : "string"
        },
        "type": "object"
    }
]

1 个答案:

答案 0 :(得分:12)

有一个not运算符和enum关键字,您可以将它们一起使用,例如

{
    "not": {
        "enum": ["1"]
    }
}
相关问题