Adds additional rake tasks to validate the OpenAPI/Swagger document
What does this MR do and why?
This MR is a followup to Autogenerate OpenApi using grape-swagger (!98681 - merged), which generates a Swagger document from Grape annotations.
It adds rake tasks to validate that the generated file is valid OpenAPI. It will help ensure that the generated document can be used.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
- checkout this branch
sg/validate-swagger
yarn install
- Delete the
doc/api/openapi/openapi_v2.yaml
file. - run
rake gitlab:openapi:generate_and_check
- it should print the output of
swagger-cli
to the console (should be successful) - mutate
config/open_api.yml
to be invalid (can delete the values ofmetadata.security_definitions.access_token_header
) - run
rake gitlab:openapi:generate_and_check
- it should print the errors produced by
swagger-cli
to stdout, and abort the task.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Sean Gregory