How to create different element types within Swagger 2.0 editor

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

I trying to map below JSON to Swagger YAML in swagger editor 2.0 and I am not sure how to set mixed array types into my schema

{   "obj1": [      "string data",      1     ] } 

Now, my swagger definition has,

schema:   object1:     type: array     items:       type: string 

回答1:

OpenAPI / Swagger 2.0 do not support mixed-type array and parameters. Mixed types will be supported in the next version, OpenAPI 3.0, using the anyOf and oneOf keywords:

definitions:   MyObject:     type: object     properties:       obj1:         type: array         items:           oneOf:             - type: string             - type: integer 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!