【发布时间】:2018-04-20 09:30:17
【问题描述】:
在这个doc 中,定义了两个模式:
components:
schemas:
Dog:
type: object
properties:
bark:
type: boolean
breed:
type: string
enum: [Dingo, Husky, Retriever, Shepherd]
Cat:
type: object
properties:
hunts:
type: boolean
age:
type: integer
然后文档说:
以下 JSON 对象对 both 架构有效
{
"bark": true,
"hunts": true,
"breed": "Husky",
"age": 3
}
如果对于出现在实例中以及作为该关键字值中的名称的每个名称,该名称的子实例成功地针对相应的架构进行验证,则验证成功。
如果我理解正确,这个对象对Dog 无效,因为它有一个意外的键hunts,对Cat 无效,因为它有一个意外的键bark。
为什么文档说这个对象对两种模式都有效?
【问题讨论】:
标签: openapi json-schema-validator