JSON Schema Reference
Mockzilla uses json-schema-faker (JSF) to generate dynamic, realistic data from your JSON Schemas. It provides a bridge between standard JSON Schema validation and data generation libraries like Faker.js.
Supported Specifications
Mockzilla currently uses json-schema-faker v0.5.9, which primarily supports JSON Schema Draft-04. Many common keywords from later drafts (like oneOf, anyOf, allOf) are also supported for generation.
Supported Keywords
JSF supports a wide range of standard JSON Schema keywords to guide data generation:
- Logic:
allOf,anyOf,oneOf,not(partially) - Objects:
properties,required,additionalProperties,minProperties,maxProperties - Arrays:
items(mandatory for validation),minItems,maxItems,uniqueItems - Strings:
minLength,maxLength,pattern(RegExp),format,enum - Numbers:
minimum,maximum,exclusiveMinimum,exclusiveMaximum,multipleOf - Metadata:
default,examples,const
Faker.js Integration (v10)
Mockzilla integrates Faker.js v10 directly into the schema generation process. You can use the faker (or x-faker in OpenAPI) keyword on any schema property.
Passing Arguments to Faker
Modern Faker uses object notation for named parameters. This is the preferred syntax in Mockzilla.
{
"faker": {
"finance.amount": { "min": 100, "max": 1000, "dec": 2, "symbol": "$" }
}
}
Common Faker Fields
| Category | Method Examples |
|---|---|
| 👤 Person | fullName, firstName, lastName, jobTitle |
| 🌐 Internet | email, userName, password, url, ipv4 |
| 💰 Finance | amount, accountNumber, currencyCode, iban |
| 📍 Location | streetAddress, city, zipCode, country |
| 📅 Date | recent, future, past, birthdate |
| 📦 Lorem | word, sentence, paragraph, slug |
| 🔢 System | string.uuid, string.alphanumeric, number.int |
High-Fidelity Patterns
Paginated List Response
{
"type": "object",
"properties": {
"data": {
"type": "array",
"minItems": 5,
"maxItems": 5,
"items": {
"type": "object",
"properties": {
"id": { "type": "string", "faker": "string.uuid" },
"title": { "type": "string", "faker": "lorem.sentence" }
}
}
},
"meta": {
"type": "object",
"properties": {
"page": { "const": 1 },
"total": { "type": "integer", "faker": { "number.int": { "min": 50, "max": 100 } } }
}
}
}
}
Request Context & Interpolation
Mockzilla provides the request context to the schema generator, allowing you to reference request data directly in your schema.
Faker in Templates
You can call Faker methods directly within your templates using {{faker.method.submethod}}.
{
"type": "object",
"properties": {
"randomEmail": { "type": "string", "const": "{{faker.internet.email}}" },
"greeting": { "type": "string", "const": "Hello, {{faker.person.fullName}}!" }
}
}
Referencing Path Captures and Query Parameters
Use double-brace interpolation in a string const to copy request values into a generated response. The first wildcard capture is $.params.[0]; query values use $.query.paramName. Query values are strings.
Interpolation copies a value into the response. It does not convert a query value to
a number or use limit to resize an array; configure array length with minItems
and maxItems. If a query key must exist, require it in Advanced Options →
Query Parameters (for example, page = *).
{
"type": "object",
"properties": {
"meta": {
"type": "object",
"properties": {
"productId": { "type": "string", "const": "{{$.params.[0]}}" },
"page": { "type": "string", "const": "{{$.query.page}}" },
"limit": { "type": "string", "const": "{{$.query.limit}}" }
}
}
}
}
For an end-to-end wildcard and query-parameter example, see Dynamic Wildcard Mocks.
Supported Formats
| Format | Generator |
|---|---|
date-time | ISO timestamp (built in) |
date | ISO date such as 1932-04-12 (built in) |
email | Random address (built in). Use "faker": "internet.email" for realistic names. |
uuid | UUID (built in) |
password | faker.internet.password() |
phone | faker.phone.number() |
uri | faker.internet.url() |
hostname | faker.internet.domainName() |
ipv4 / ipv6 | faker.internet.ipv4() / faker.internet.ipv6() |
country / country-code | faker.location.country() / faker.location.countryCode() |
currency / currency-symbol | faker.finance.currencyCode() / faker.finance.currencySymbol() |
credit-card | faker.finance.creditCardNumber() |
user-agent / mac / color | faker.internet.userAgent() / faker.internet.mac() / faker.color.human() |
byte / binary | 10 random alphanumeric characters |
Faker date methods such as date.past return a JavaScript date string
(Thu Nov 27 2025 09:22:33 GMT…). Add "format": "date-time" next to the faker
keyword to get an ISO timestamp instead.
Best Practices
- Mandatory
items: Fortype: "array", anitemssubschema must be provided. Without it, generation fails and Mockzilla returns the mock's static response instead. - Always set
maxItems: Arrays always generate exactlymaxItemsitems. With nomaxItems, an array generatesMOCKZILLA_MAX_ITEMS(default 1000) items. For an empty array, setminItemsandmaxItemsto0. - Optional fields are generated: Every property in
propertiesappears in the output, whether or not it is inrequired. - Explicit Types: Always specify a
typefor every property to ensure consistent generation. - OpenAPI import cap: OpenAPI import generates its static body with arrays capped at 3 items. The stored schema is not changed, so add
maxItemsbefore you switch an imported mock to Dynamic Response. - Faker arguments: Methods with arguments need object or array notation.
"faker": "string.alphanumeric"returns a single character; use{ "string.alphanumeric": 10 }for ten.
