Sunday, June 3, 2018

Exercise Swagger APIs against WireMock

Full Stack Software Development Blog


I have all APIs that are defined in Swagger Hub mocked on the WireMock server running on Heroku.

To populate the APIs in WireMock you'll need to run bash script I created to curl WireMock to create the mock APIs. Clone this github repo (https://github.com/gpratte/texastoc-v2-swagger-hub) and run the create-api.sh bash script. You will also see the yml files for the APIs defined in Swagger Hub in this repo.

The WireMock server running on Heroku gets torn down if there is no activity for a 30 minute period. Hence the bash script to create the mock APIs will need to be run each time the server is created by Heroku. You can tell when a server is created because the first call to Heroku takes 20 seconds or more and then subsequent calls take a second or less.

The mock APIs do not verify the request but do return a valid response for all the APIs defined in Swagger Hub. The request verification will come later when it is time to test.

So after populating the mock APIs in WireMock you can run any of the APIs in Swagger Hub.

No comments:

Post a Comment