Ensure OpenAPI specification is generated correctly
Description
Currently the OpenAPI specification generated by the spectacular
management command is not correct, and does not include the API endpoints. This should be fixed so that the API specification can be generated correctly.
Further details
Task list
Acceptance criteria
-
OpenAPI specification generates correctly from
poe manage spectacular
- Add unit test to verify OpenAPI generation produces valid output and includes expected endpoints
Links/references
Designs
- Show closed items
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Mike Knee added issuetypeTask teamIdentity workflowNeeds Refinement labels
added issuetypeTask teamIdentity workflowNeeds Refinement labels
- Mike Knee added to epic uis/devops&205
added to epic uis/devops&205
- Mike Knee marked this issue as blocking #22 (closed)
marked this issue as blocking #22 (closed)
- Mike Knee changed the description
Compare with previous version changed the description
- Mike Knee marked this issue as blocking #24 (closed)
marked this issue as blocking #24 (closed)
- Mike Knee changed the description
Compare with previous version changed the description
- Mike Knee added time estimate of 1d
added time estimate of 1d
- Mike Knee added workflowSprint Ready label and removed workflowNeeds Refinement label
added workflowSprint Ready label and removed workflowNeeds Refinement label
- E. Evstafiev mentioned in epic uis/devops&205
mentioned in epic uis/devops&205
- Ed Kirk changed iteration to IAM Sprint Nov 20, 2024 - Dec 3, 2024
changed iteration to IAM Sprint Nov 20, 2024 - Dec 3, 2024
- E. Evstafiev added workflowIn Progress label and removed workflowSprint Ready label
added workflowIn Progress label and removed workflowSprint Ready label
- E. Evstafiev assigned to @ee345
assigned to @ee345
- E. Evstafiev created branch
21-ensure-openapi-specification-is-generated-correctly
to address this issuecreated branch
21-ensure-openapi-specification-is-generated-correctly
to address this issue - E. Evstafiev mentioned in merge request !52 (merged)
mentioned in merge request !52 (merged)
- Maintainer
Not sure why
Currently the OpenAPI specification generated by the spectacular management command is not correct
, as I have the generated file: Activate_Account__v1alpha1___3_.yaml Collapse replies - Owner
Yup. It looks to me that it has the endpoints in. I suppose this task turns into just:
Add unit test to verify OpenAPI generation produces valid output and includes expected endpoints
Using something like https://pypi.org/project/openapi-spec-validator/.
- Owner
It looks to me that it has the endpoints in.
However, looking carefully I see that the responses are wrong. For example:
paths: /token/: post: operationId: token_create tags: - token requestBody: content: application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/TokenRequest' required: true responses: '200': content: application/json: schema: $ref: '#/components/schemas/TokenRequest' description: ''
The 200 response schema should be something different to the request schema since the response will have
expires_in
andaccess_token
fields, etc. 1 - Owner
It appears from the DRF Spectacular docs that one needs to specify the response schema somehow. The current post method doesn't use any serializer at all to form responses:
def post(self, request, *args, **kwargs): # ... return Response( data={ "expires_in": int(self.get_token_ttl().total_seconds()), "access_token": token, "token_type": "bearer", }, headers={ "Cache-Control": "no-store", "Pragma": "no-cache", }, )
So it looks like you'd need to add something like a
TokenResponseSerializer
and use@extend_schema
.The OpenAPI spec also doesn't include any of the non-200 error responses.
- Owner
E.g https://developer.api.apps.cam.ac.uk/docs/oauth2/1/routes/token/post includes 400 and 403 responses in the schema. And I think we can also generate 401s too?
- Owner
E.g https://developer.api.apps.cam.ac.uk/docs/oauth2/1/routes/token/post includes 400 and 403 responses in the schema. And I think we can also generate 401s too?
Nope. Only 400s.
- E. Evstafiev added workflowReview Required label and removed workflowIn Progress label
added workflowReview Required label and removed workflowIn Progress label
- Dr Rich Wareham added workflowRework label and removed workflowReview Required label
added workflowRework label and removed workflowReview Required label
- E. Evstafiev added workflowReview Required label and removed workflowRework label
added workflowReview Required label and removed workflowRework label
- E. Evstafiev added workflowUnder Review label and removed workflowReview Required label
added workflowUnder Review label and removed workflowReview Required label
- E. Evstafiev mentioned in commit 66f30e41
mentioned in commit 66f30e41
- E. Evstafiev closed with merge request !52 (merged)
closed with merge request !52 (merged)
- E. Evstafiev reopened
reopened
- E. Evstafiev added workflowNeeds Deployment label and removed workflowUnder Review label
added workflowNeeds Deployment label and removed workflowUnder Review label
- E. Evstafiev added workflowDone label and removed workflowNeeds Deployment label
added workflowDone label and removed workflowNeeds Deployment label
- E. Evstafiev closed
closed