0

i have developed an node API, now im using swagger to create Documentation for this API, but im stuck in the response part, please help me to write response for this json result,

    [
  {
    "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
        }
      }
    ]
  }
]

My current swagger response code is like this,

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

i dont know how to write response with type to each object.

LogaKrishnan
  • 491
  • 1
  • 9
  • 24

1 Answers1

1

You can define the JSON structure in "Definitions" and refer that in the schema

responses:
    # Response code
    200:
      description: Successful response
      schema:
        $ref: '#/definitions/userAuthentication'


definitions:
  -userAuthentication:
    title: User Authentication
    type: array
    items:
      title: token
      type: string

If you want token as a JSON then define it and refer.

senthalan
  • 1,936
  • 3
  • 10
  • 19