отклик отклик для нескольких объектов данных JSON - PullRequest
0 голосов
/ 21 мая 2018

Я разработал node API, теперь я использую swagger для создания Documentation для этого API, но я stuck в response part, пожалуйста, помогите мне написать ответ для этого 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.

1 Ответ

0 голосов
/ 23 мая 2018

Вы можете определить структуру 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, определите его и обратитесь.

...