Introducing the WireMock API Templates Library
Please welcome the WireMock API Templates Library! It provides a public catalog of mock API templates for popular services. Find the API that you need and get a running mock server in seconds, on both WireMock or WireMock Cloud.
As Tom Akehurst, the creator of WireMock and the CTO of WireMock Inc said, “Mocking many third party APIs can be a time-consuming process so we launched the WireMock library as a way for the WireMock community to gain access and contribute to ready-made mocks of common APIs”. Now we have a WireMock API template library to help with this use-case! There are many ready-to-fly templates for popular services already included in your integration tests, for example GitHub, GitLab, OpenAI, and of course WireMock and WireMock Cloud administration REST APIs!
At the moment there are more than 2,000 templates published on the website. The catalogue itself is open source and open for reuse and contributions too! https://github.com/wiremock/api-template-library
Using templates
First of all, choose a template you need by using the categorization and search capabilities of the website. Each template has description and usage guidelines on the separate page.
Using templates library with WireMock Cloud
For WireMock Cloud there is the Run in WireMock Cloud button that allows importing the Mock API definition into your project in one click. For your convenience, we also have the same templates library embedded right inside WireMock Cloud.
Using templates library with WireMock
The Mock API Templates are compatible with both WireMock 2.25.0 stable release. and with the WireMocmk 3 beta releases. To obtain the template, click the Download WireMock JSON button and download the JSON file to your local filesystem. Then, you can use this JSON file with every flavour of WireMock: standalone installation as JAR/Docker container, JUnit tests, etc. For each use-case, there is documentation here. For WireMock Docker, you can also find an example in this repository: https://github.com/wiremock/wiremock-templates-demo. Including a template in your Docker image is as simple as…
Then you can build the image and start using its APIs:
With WireMock Standalone running in Docker, you will have a running WireMock instance on port 8080 Now you can use the stubbed GitHub v3 REST API and all WireMock Administrative APIs for test purposes. For GET methods, you can simply invoke them in the browser, for example http://localhost:8080/admin/hook to list Admin hooks on the instance:
The End
Try out the WireMock API Templates Library and let us know what your experiences are. We plan to keep improving this service, and your feedback will be more than welcome!
If you would like to enhance an API Template or to contribute a new one, please checkout the Contributing Guidelines in the repository. For any feedback and suggestions, please use the GitHub issues in this repository. The website is powered by Hugo and open for contributions too!
References:
- Library Website: https://library.wiremock.org (GitHub repo)
- Documentation: https://wiremock.org/docs/mock-api-templates
- Templates metadata repository: https://github.com/wiremock/api-template-library
Also, join the WireMock Community Slack!
/