Swagger 2.0 Anyof [英] Swagger 2.0 Anyof

查看:62
本文介绍了Swagger 2.0 Anyof的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is the equivalent of anyof in Swagger version 2.0, Please tell me how to update my json file because I want to upgrade my documentation from swagger 1.0 to 2.0.

感谢您的帮助.

推荐答案

我认为没有,感觉是一个很大的缺点.规范的架构对象部分中绝对没有提到它.他们调用了从 JSON Schema 中采用的元素,anyOf 不在其中:

I don't think there is one and it feels like a big shortcoming. It's definitely not mentioned in the Schema Object portion of the specification. They call out the elements there that have been adopted from the JSON Schema and anyOf isn't among them:

以下属性直接取自 JSON Schema 定义并遵循相同的规范:

The following properties are taken directly from the JSON Schema definition and follow the same specifications:

  • $ref - 作为 JSON 参考
  • 格式(有关详细信息,请参阅数据类型格式)
  • 标题
  • 描述(GFM 语法可用于富文本表示)
  • default(与 JSON Schema 不同,该值必须符合为 Schema 对象定义的类型)
  • multipleOf
  • 最大
  • exclusiveMaximum
  • 最低
  • exclusiveMinimum
  • 最大长度
  • minLength
  • 模式
  • maxItems
  • minItems
  • 独特的项目
  • 最大属性
  • minProperties
  • 必填
  • 枚举
  • 输入

以下属性取自 JSON 架构定义,但它们的定义已根据 Swagger 规范进行了调整.它们的定义与 JSON Schema 中的定义相同,只是原始定义引用了 JSON Schema 定义,而使用 Schema Object 定义.

The following properties are taken from the JSON Schema definition but their definitions were adjusted to the Swagger Specification. Their definition is the same as the one from JSON Schema, only where the original definition references the JSON Schema definition, the Schema Object definition is used instead.

  • 项目
  • 全部
  • 属性
  • 附加属性

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

I think the closest thing is the discriminator field, but that means you've got to structure your output to accommodate Swagger.

这篇关于Swagger 2.0 Anyof的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆