【发布时间】:2023-02-09 06:02:42
【问题描述】:
我可以验证两者吗
name: "range_1"
step: 1
start: 0
stop: 10
和
name: "range_2"
step: 1
center: 5
span: 5
用类似的东西
properties:
name:
type: "string"
stop:
type: number
oneOf:
- start:
type: number
step:
type: number
- center:
type: number
span:
type: number
现在我在 Python 中使用jsonschema,但它抱怨jsonschema.exceptions.SchemaError: <the array in oneOf> is not of type 'object', 'boolean'。
仅针对 name 和 step 进行验证或针对所有可能的密钥进行验证显然可行,但它们对我来说似乎都不是最佳选择。
【问题讨论】:
标签: yaml jsonschema