Configuration
This plugin is compatible with DB-less mode.
Use the
api_specification
config for DB-less or hybrid mode. Attach the spec contents directly instead of uploading to the Dev Portal. 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
string requiredThe name of the plugin, in this case
mocking
. -
instance_name
stringAn optional custom name to identify an instance of the plugin, for example
mocking_my-service
. Useful when running the same plugin in multiple contexts, for example, on multiple services. -
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/SERVICE_NAME|SERVICE_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/ROUTE_NAME|ROUTE_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/CONSUMER_NAME|CONSUMER_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. With this configuration option, you can include the full specification as part of the configuration, instead of referring to a separate file with
api_specification_filename
that lives next to the Kong Gateway. In Kong Manager, you can copy and paste the contents of the spec directly into theConfig.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.
-