Swagger 2.0 任意 [英] Swagger 2.0 Anyof

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

问题描述

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 语法可用于富文本表示)
  • 默认(与 JSON Schema 不同,该值必须符合为 Schema Object 定义的类型)
  • 多个
  • 最大
  • 独家最大
  • 最低
  • 独家最低
  • 最大长度
  • 最小长度
  • 模式
  • 最大项目数
  • 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 任意的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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