Configuration
This plugin is compatible with DB-less mode.
Use the
api_specification
config for DB-less or hybrid mode. The API spec is configured directly in the plugin.
Compatible protocols
The Mocking plugin is compatible with the following protocols:
grpc
, grpcs
, http
, https
Parameters
Here's a list of all the parameters which can be used in this plugin's configuration:
-
string required
The name of the plugin, in this case
mocking
.- If using the Kong Admin API, Konnect API, declarative configuration, or decK files, the field is
name
. - If using the KongPlugin object in Kubernetes, the field is
plugin
.
- If using the Kong Admin API, Konnect API, declarative configuration, or decK files, the field is
-
string
An optional custom name to identify an instance of the plugin, for example
mocking_my-service
.The instance name shows up in Kong Manager and in Konnect, so it's useful when running the same plugin in multiple contexts, for example, on multiple services. You can also use it to access a specific plugin instance via the Kong Admin API.
An instance name must be unique within the following context:
- Within a workspace for Kong Gateway Enterprise
- Within a control plane or control plane group for Konnect
- Globally for Kong Gateway (OSS)
-
string
The name or ID of the service the plugin targets. Set one of these parameters if adding the plugin to a service through the top-level
/plugins
endpoint. Not required if using/services/{serviceName|Id}/plugins
. -
string
The name or ID of the route the plugin targets. Set one of these parameters if adding the plugin to a route through the top-level
/plugins
endpoint. Not required if using/routes/{routeName|Id}/plugins
. -
string
The name or ID of the consumer the plugin targets. Set one of these parameters if adding the plugin to a consumer through the top-level
/plugins
endpoint. Not required if using/consumers/{consumerName|Id}/plugins
. -
boolean default:
true
Whether this plugin will be applied.
-
record required
-
string
The path and name of the specification file loaded into Kong Gateway’s database. You cannot use this option for DB-less or hybrid mode.
-
string
The contents of the specification file. You must use this option for hybrid or DB-less mode. You can include the full specification as part of the configuration. In Kong Manager, you can copy and paste the contents of the spec directly into the
Config.Api Specification
text field.
-
boolean default:
false
Enables a random delay in the mocked response. Introduces delays to simulate real-time response times by APIs.
-
number default:
1
The maximum value in seconds of delay time. Set this value when
random_delay
is enabled and you want to adjust the default. The value must be greater than themin_delay_time
.
-
number default:
0.001
The minimum value in seconds of delay time. Set this value when
random_delay
is enabled and you want to adjust the default. The value must be less than themax_delay_time
.
-
boolean default:
false
Randomly selects one example and returns it. This parameter requires the spec to have multiple examples configured.
-
array of type
integer
A global list of the HTTP status codes that can only be selected and returned.
-
boolean required default:
false
Determines whether to randomly select an HTTP status code from the responses of the corresponding API method. The default value is
false
, which means the minimum HTTP status code is always selected and returned.
-
boolean required default:
false
Indicates whether to include the base path when performing path match evaluation.
-
string starts_with:
/
The base path to be used for path match evaluation. This value is ignored if
include_base_path
is set tofalse
.
-