Moclojer Configuration Specification
Reference for the Moclojer configuration file format
This reference guide provides details about the YAML syntax for Moclojer configuration files.
Overview
Moclojer uses YAML configuration files to define mock endpoints. Each configuration file contains a list of endpoint definitions that the mock server will respond to.
Example Configuration
Configuration File Structure
A Moclojer configuration file is a YAML file containing an array of endpoint objects.
Endpoint
Each endpoint object has the following structure:
endpoint
Yes
Object
Contains the configuration for this mock endpoint
Endpoint Object
method
No
String
HTTP method for this endpoint. Default: GET
host
No
String
path
Yes
String
URL path pattern with optional parameter types (e.g., /users/:id|int
)
query
No
Object
Query parameter definitions with types
body
No
String/Object
Expected request body schema
response
Yes
Object
Response configuration
rate-limit
No
Object
Rate limiting configuration for this endpoint
webhook
No
Object
Webhook configuration to trigger after handling the request
Path Parameters
Moclojer supports typed path parameters using the syntax :paramName\|type
:
Available types:
string
(default)int
uuid
date
boolean
Query Parameters
Query parameters can be defined and validated:
Response Object
status
No
Integer
HTTP status code. Default: 200
headers
No
Object
HTTP response headers
body
No
String/Object
Response body content
external-body
No
Object
External body configuration for loading response from external source
Templates
Moclojer supports templates in the response body using the Handlebars-like syntax:
Available template variables:
path-params
: URL path parametersquery-params
: URL query parametersjson-params
: JSON body parametersheader-params
: Request headers
Rate Limiting
Rate limiting can be configured per endpoint:
window-ms
No
Integer
Time window in milliseconds. Default: 900000
(15 minutes)
max-requests
No
Integer
Maximum requests per window. Default: 100
key-fn
No
String
Function to determine rate limit key. Default: remote-addr
Webhook
Configure webhooks to be triggered after handling a request:
sleep-time
No
Integer
Delay in seconds before triggering webhook
url
Yes
String
Webhook URL
method
No
String
HTTP method for webhook. Default: POST
body
No
String/Object
Webhook request body
if
No
String
Conditional expression for triggering webhook
External Body
Load response body from external sources:
provider
Yes
String
Provider type (json
, yaml
, xml
, etc.)
path
Yes
String
Path to external resource (file or URL)
Multiple Domains Support
Moclojer can handle multiple domains in a single configuration:
Full Configuration Example
Last updated
Was this helpful?