til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Validating OpenAPI Definition

I have found a several tools, which work on the command line for validating a OpenAPI definition.

I need to try them out and see which one works best.

Alternatively there is the SwaggerUI editor and online editor and validator. See the separate TIL on this.

swagger-spec-validator (Javascript)

npm install -g swagger-spec-validator

On file argument:

swagger-spec-validator swagger.yaml
All OpenAPI/Swagger specs are valid.

Works also for the JSON format.

swagger-spec-validator swagger.json
All OpenAPI/Swagger specs are valid.

Via pipe:

cat swagger.yaml | swagger-spec-validator
All OpenAPI/Swagger specs are valid.

openapi-spec-validator (Python)

pip install openapi-spec-validator

On file argument:

openapi-spec-validator openapi.yaml
OK

Works also for the JSON format.

openapi-spec-validator openapi.json
OK

Via pipe (do note the dash):

cat openapi.yaml | openapi-spec-validator -
OK

Resources and References