Recently I have been working with swagger in a project. Swagger 2.0 has become an open standard and now referred to as OpenAPI Specification (OAS).
I also love medium.com, so when I saw their API doc was hand written in plain text, I thought it would be good exercise to convert it to OpenAPI Specification format. The result is https://github.com/amardeshbd/medium-api-specification
Now, recently I’ve started adding Travis Continuous Integration (CI) script for most of my recent projects. So, I wanted to add CI support for this OAS project.
UPDATE: I have written another article that leverages GitHub actions and node modules to validate different things. Use this article to validate anything including Swagger/OpenAPI specifications.
Adding Travis CI build support for OpenAPI specification
Googling for this specific topic didn’t bring much content. I wanted to keep the script simple and use existing validator provided by swagger-validator-badge web service (NOTE: There are dozens of validators in different languages built by the community — see http://swagger.io/open-source-integrations/).
Here are the key elements used for CI:
* shUnit2 — for writing unit tests in shell script. This is downloaded via Travis build config before the build begins.
.travis.yml — Travis CI build config
* validator-badge — online web-service to validate OpenAPI specification file
api-spec_validation_test.sh — Shell script for unit test
I hope somebody finds this useful for their project.