API Mocking
webMethods API Gateway supports mocking ability for both REST and SOAP APIs. This example explains how you can use the mocking functions for a REST API. In this example, you enable mocking for a REST API PetStore, modify the mocking details, and verify the mocked response as per the configured mocked response.
About this task
During API development, you might have the following concerns:
- How can you test your API while your native API is still under development?
- How can you continuously test your APIs on an ongoing basis, for example, CI-CD pipelines, without any external dependencies, especially under circumstances where the backend is subjected to downtimes or requires access credentials that are changed frequently?
Mocking is the capability that helps you accelerate your development lifecycles by reducing the dependencies between your development teams, especially the API consumer, and the backend. API Gateway helps mock an API. The mocked API provides realistic native API responses to requests. You can mock an API by simulating the native API, by using the API mocking capability in webMethods API Gateway. For example, if you have an API without a native implementation, you can mock that API. When the API is started, the mock API server returns the mocked response to the client that started the API.
With webMethods API Gateway, you can modify the default-mocked response and configure it as needed. You can customize it for each combination of resource, operation, status code, and content type based on the examples and schemas specified in the API. In addition, you can add a condition to the operation in the resource.
The following figure shows the high-level steps for mocking an API.