20

I have a yaml specification that has been updated from swagger 2.0 to openapi 3.0.0

The file itself is about 7,000 lines so it is challenging to validate by hand.

I need to figure out which tags I have are no longer compatible with openapi 3.0.0. How can I validate my schema? Are there any command line tools I can use?

I do not want to copy/paste this code somewhere online because I don't want to expose all the routes publicly.

William Ross
  • 3,568
  • 7
  • 42
  • 73

6 Answers6

25

Swagger Editor

https://editor.swagger.io performs validation on the client side, meaning your definition is not sent anywhere. You can also run the editor locally, e.g. offline.

Notes:

  • Because of lazy loading you may need to expand all operations and models in the UI panel to see all of the errors.

  • Warnings are displayed as gutter icons, apart from the error list.

Other validators

https://openapi.tools has a list of OpenAPI validation tools, including command-line tools and Node.js modules.

Helen
  • 87,344
  • 17
  • 243
  • 314
3

Vacuum is a nice fast command line tool for openapi spec validation.

Once you have it installed, linting is as simple as:

$ vacuum lint -d my-openapi-specification.yaml 

(-d means details - print out found issues)

Ilya Serbis
  • 21,149
  • 6
  • 87
  • 74
Iizuki
  • 354
  • 1
  • 6
  • 12
3

https://openapi.tools is where I'd go to find OpenAPI validation tools

2

Use openapi-lint extension on visual studio code and remember to name your file as *openapi.json, *openapi.yaml, *openapi.yml, *oas3.json, *oas3.yml, *oas3yaml.

Klement Tan
  • 301
  • 2
  • 7
1

I use swagger-cli. It's a validator and bundler that supports $ref among other things.

Devy
  • 9,655
  • 8
  • 61
  • 59
1

OpenAPI Generator CLI tool, which is widely used, also offers schema validation.

Docker

To validate a schema using Docker, you can run the following command:

docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli validate \
    -i /local/file.yaml

Shellscript

Alternatively, you can use the shell script provided in the OpenAPI Generator repository: https://github.com/OpenAPITools/openapi-generator/blob/master/bin/utils/openapi-generator-cli.sh

./openapi-generator-cli.sh validate -i file.yaml


For more information on how to use OpenAPI Generator CLI, you can refer to the documentation at: https://openapi-generator.tech/docs/usage

Filip Seman
  • 1,252
  • 2
  • 15
  • 22