examples keyword provides an array of sample JSON values that demonstrate valid instances for a schema. These examples help developers understand how to use the schema in practice.
Syntax
The value ofexamples must be an array. There are no restrictions on the values within the array.
Purpose
Theexamples keyword is a metadata annotation that:
- Provides sample JSON values associated with a schema
- Illustrates typical or valid usage patterns
- Helps generate documentation and API explorers
- Can be used by tools to generate test data or mock responses
- Has no effect on validation (it is purely informational)
- Should contain values that are valid against the schema (recommended)
Behavior
When multiple occurrences of theexamples keyword are applicable to a single sub-instance, implementations must provide a flat array of all values rather than an array of arrays.
Implementations may use the value of the default keyword, if present, as an additional example. If examples is absent, default may still be used as an example.
Examples
Basic String Examples
Numeric Examples
Object Examples
age).
Array Examples
Enum with Examples
Complex Nested Object
API Request Body
Date and Time Examples
Pattern Examples
Using Default as an Example
default value (20) can be used as an additional example by implementations.