0

I have an API response which adheres to json-api spec of application/vnd.api+json. The response looks like this:

{
  "jsonapi": {
    "version": "1.0"
  },
  "data": {
    "type": "drawDate",
    "id": "1",
    "attributes": {
      "schoolStartDate": "2019-01-02T00:00:00.000Z"
    }
  }
}

However, in Swagger UI under "Responses", where the model is specified, the response example is displayed as follows, which is different from the actual response:

[
{
  "schoolStartDate": "2019-01-02T00:00:00.000Z"
}
]

I tried adding content type of application/vnd.api+json for the GET content property, but this did not help:

responses:
 *       200:
 *         description: Gets school list
 *         content:
 *           application/vnd.api+json:
 *               schema:
 *                 type: array
 *                 items:
 *                    $ref: '#...'

How to make the response example value in Swagger UI match the actual API response?

Helen
  • 87,344
  • 17
  • 243
  • 314
Shree
  • 59
  • 1
  • 4
  • Do you write the Swagger YAML file manually or generate it from code? If the latter, what language/framework do you use? – Helen Sep 09 '19 at 08:44
  • i am using swagger-jsdocs npm package to write the documentation manually. Within that i am using JSDocs but planning to switch to YAML files – Shree Sep 12 '19 at 06:20

0 Answers0