Skip to content

Adds additional rake tasks to validate the OpenAPI/Swagger document

Sean Gregory requested to merge sg/validate-swagger into master

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

  1. checkout this branch sg/validate-swagger
  2. yarn install
  3. Delete the doc/api/openapi/openapi_v2.yaml file.
  4. run rake gitlab:openapi:generate_and_check
  5. it should print the output of swagger-cli to the console (should be successful)
  6. mutate config/open_api.yml to be invalid (can delete the values of metadata.security_definitions.access_token_header)
  7. run rake gitlab:openapi:generate_and_check
  8. 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.

Edited by Sean Gregory

Merge request reports