【问题标题】:Define a response object with an array in YAML using Swagger Editor使用 Swagger Editor 在 YAML 中使用数组定义响应对象
【发布时间】:2017-03-20 09:11:25
【问题描述】:

我正在使用 YAML 在 Swagger Editor 中进行 API 定义。我试图代表以下响应正文:

{
    success: true,
    ids: [123456, ...]
}

这就是我的 YAML 的样子:

definitions:
  SuccessfulResponse:
    type: object 
    properties:
      success:
        type: boolean
        description: True if the all operations were successful
      ids:
        type: array
        items: 
          id: 
          type: string 

我尝试了几种不同的方法,但像这样,但似乎没有任何效果

如何正确描述上面给出的返回对象?

【问题讨论】:

    标签: swagger swagger-editor


    【解决方案1】:

    这是一个将属性定义为字符串数组的示例:

      photoUrls:
        type: array
        items:
          type: string
    

    参考:https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml#L661-L667

    【讨论】:

    • 编辑器选项和引用的内容都已更改,不再有效。
    • 更新了参考
    猜你喜欢
    • 1970-01-01
    • 2021-06-15
    • 1970-01-01
    • 1970-01-01
    • 2019-10-28
    • 2016-12-24
    • 1970-01-01
    • 1970-01-01
    • 2019-10-02
    相关资源
    最近更新 更多