首页 文章

Swagger 2.0 Anyof

提问于
浏览
6

什么是Swagger 2.0版本中的任何一个,请告诉我如何更新我的json文件,因为我想将我的文档从swagger 1.0升级到2.0 .

谢谢您的帮助 .

2 回答

  • 4

    现在OpenAPI Specification 3.0(2017年7月26日发布)支持 anyOfoneOf .

  • 4

    我绝不会在the Schema Object portion of the specification中提到't think there is one and it feels like a big shortcoming. It' . 他们调用了那些从JSON Schema中采用的元素,并且 anyOf 不在其中:

    以下属性直接取自JSON Schema定义并遵循相同的规范:$ ref - 作为JSON参考格式(有关更多详细信息,请参阅数据类型格式) Headers 说明(GFM语法可用于富文本表示)默认(与JSON Schema不同,值必须符合Schema Object的定义类型)multipleOf maximum exclusiveMaximum minimum exclusiveMinimum maxLength minLength pattern maxItems minItems uniqueItems maxProperties minProperties required enum type以下属性取自JSON Schema定义,但其定义已调整为Swagger规范 . 它们的定义与JSON Schema中的定义相同,只有在原始定义引用JSON模式定义的情况下,才使用模式对象定义 . items allOf属性additionalProperties

    我认为最接近的是 discriminator 字段,但这意味着您必须构建输出以适应Swagger .

相关问题