mockServer
Configure the mock server in your Redocly-powered API documentation using mockServer
. The mock server allows users to:
- Send requests to the Operations in your API description from Replay, cURL, or any other API client.
- Receive a sample response using information from the API description and input data.
By default, the mock server is enabled for each API description in your project. The path is configured as /_mock/<path-to-description>/
. For example, /_mock/openapi/redocly-museum/
.
Options
Option | Type | Description |
---|---|---|
off | boolean | Turn off ("disable") the mock server. Defaults to false . |
strictExamples | boolean | If If Defaults to |
errorIfForcedExampleNotFound | boolean | Controls the response behavior of the mock server when a forced example is not found. If Defaults to |
position | string | Controls the position of the mock server in the servers dropdown in Redocly Replay. Possible values: Defaults to |
description | string | Set the description of the mock server in the servers dropdown in Redocly Replay. Defaults to Mock Server . |
Examples
This example configures the mock server in the following ways:
- Example response payloads don't substitute values from the request
- Only the mock server is available on Replay's server list
- The mock server is labeled as "Development server"
mockServer:
strictExamples: true
position: 'replace'
description: 'Development Server'
Resources
- Learn to Configure the mock server and modify the behavior or appearance.
- Discover the Replay API explorer used to call the mock server.
- Add OpenAPI descriptions to enable a mock server on the corresponding API reference.