API mocking

You can mock an API by simulating the native API by using the API mocking feature in API Gateway. For example, if you have an API without a native implementation, you can mock that API. The mocked response is returned to the consumer when the API is invoked.

In webMethods API Gateway, when you enable mocking for an API, a default mock response is configured for each combination of resource, operation, status code, and content-type. This mocked response is based on the example and schema that is specified in that API. You can add a condition to the operation in the resource.

Note:
  • You cannot enable or disable mocking for an active API.
  • webMethods API Gateway does not support API Mocking for GraphQL API.

As an API Provider, you can create or modify the default mock response. You can specify conditions and associate an IS service with the mocked API. When an IS service is associated with a mocked API, the associated IS service must adhere to the apigateway.specifications:mockService specification.

At run time, when the mocked API is invoked, instead of calling the native API, webMethods API Gateway returns the mocked response to the consumer based on the following priorities.

  1. If any of the conditions for the invoked operation is satisfied, webMethods API Gateway returns the associated mocked response.
  2. if an IS service is configured and if any of the conditions for the invoked operation is not satisfied, then webMethods API Gateway invokes the IS service. webMethods API Gateway then returns the IS service response.
  3. if an IS service is not configured and if any of the conditions for the invoked operation is not satisfied, then webMethods API Gateway returns the default-mocked response.

API mocking is supported only for SOAP and REST APIs.

Note: You must have the webMethods API Gateway's manage APIs or activate/deactivate APIs functional privilege to perform API mocking.