【问题标题】:swagger response for multiple object json data多对象json数据的招摇响应
【发布时间】:2018-05-21 06:06:53
【问题描述】:

我开发了一个node API,现在我使用swagger 为这个API 创建Documentation,但我在response part 中使用stuck,请帮我为这个json 结果写回复,

    [
  {
    "type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "geometry": {
          "type": "Point",
          "coordinates": [
            -79.90295559,
            36.05593626
          ]
        },
        "properties": {
          "id": "f2e08a02-9be9-468d-9bae-b83118ef5110",
          "esri_id": "518",
          "name": "Greensboro et al, NC",
          "panelCount": 1,
          "tot": 790523
        }
      }
    ]
  }
]

我现在的swagger响应码是这样的,

responses:
        # Response code
        200:
          description: Successful response
          # A schema describing your response object.
          # Use JSON Schema format
          schema:
            title: User Authentication
            type: array
            items:
              title: token
              type: object

我不知道怎么写回复with type to each object

【问题讨论】:

    标签: node.js api swagger swagger-2.0 suppress-warnings


    【解决方案1】:

    您可以在“定义”中定义 JSON 结构并在架构中引用它

    responses:
        # Response code
        200:
          description: Successful response
          schema:
            $ref: '#/definitions/userAuthentication'
    
    
    definitions:
      -userAuthentication:
        title: User Authentication
        type: array
        items:
          title: token
          type: string
    

    如果您想要将令牌作为 JSON,请定义并引用。

    【讨论】:

      猜你喜欢
      • 2017-01-27
      • 2019-04-05
      • 1970-01-01
      • 1970-01-01
      • 2019-04-01
      • 2017-12-24
      • 2022-07-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多