Openapi spec pagination does not match API pagination
Summary
Currently our schema for all the list
responses looks like:
"application/json": {
"schema": {
"type": "object",
"properties": {
"count": {
"type": "integer",
"example": 123
},
"next": {
"type": "string",
"nullable": true
},
"previous": {
"type": "string",
"nullable": true
},
"results": {
"type": "array",
"items": {
"properties": {
...
}
}
}
}
}
}
This is not the format our application returns the data in:
{
"meta": {
"count": 11
},
"links": {
"first": "/api/cloudigrade/api/cloudigrade/v2/instances/?limit=10&offset=0",
"last": "/api/cloudigrade/api/cloudigrade/v2/instances/?limit=10&offset=0",
"next": null,
"previous": null
},
"data": [
{...}
]
}
Steps to Reproduce
Look at API response, look at openapi.json, see difference.
Expected Result
- API response should match schema
Actual Result
- API response does not match schema
Additional context
The auto generated schema is using the drf default pagination format, instead of the drf_insights_pagination
library. It looks like we can update the library to provide custom schema to the schema generator: https://www.django-rest-framework.org/api-guide/pagination/#pagination-schemas
This is currently causing some problems in iqe tests; the autogenerated code expects data of a certain format, and will behave in mysterious ways if the response does not conform to the schema. More specifically for the /concurrent API, IQE is always showing the result of the API call as None even when there is concurrent data. I am very confused as to why this is not failing for other IQE tests, since this should be a problem for all our list
APIs.