You are browsing documentation for an outdated plugin version.
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:
-
name or plugin
string requiredThe 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
-
instance_name
stringAn 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)
-
service.name or service.id
stringThe 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
. -
route.name or route.id
stringThe 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
. -
consumer.name or consumer.id
stringThe 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
. -
enabled
boolean default:true
Whether this plugin will be applied.
-
config
record required-
api_specification_filename
stringThe path and name of the specification file loaded into Kong Gateway’s database. You cannot use this option for DB-less or hybrid mode.
-
api_specification
stringThe 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.
-
random_delay
boolean default:false
Enables a random delay in the mocked response. Introduces delays to simulate real-time response times by APIs.
-
max_delay_time
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
.
-
min_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
.
-
random_examples
boolean default:false
Randomly selects one example and returns it. This parameter requires the spec to have multiple examples configured.
-
included_status_codes
array of typeinteger
A global list of the HTTP status codes that can only be selected and returned.
-
random_status_code
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.
-