example : Any
example
AnyDeclares a single example of an instance that this schema describes, superseded by the examples keyword.
| Value |
This keyword must be set to any value
Hint: Use the jsonschema metaschema and jsonschema lint commands to catch keywords set to invalid values
|
|---|---|
| Kind | Other |
| Applies To | Any |
| Base Dialect | 2020-12 |
| Changed In | None |
| Introduced In | OpenAPI 3.1 |
| Vocabulary | OpenAPI 3.2 |
| Specification | https://spec.openapis.org/oas/v3.2.1.html#schema-example |
| Metaschema | https://spec.openapis.org/oas/3.2/meta/2026-02-26 |
| Official Tests | None |
| Default | None |
| Annotation | None |
| Affected By | None |
| Affects | None |
| Also See |
|
The example keyword declares a
single example instance for the schema it occurs in, typically for
documentation purposes. This keyword does not affect validation and is not an
annotation.
Best Practice
Use the examples keyword instead. The OpenAPI Specification recommends reaching for this
one only if compatibility with OAS v3.0 or earlier is
required.
The dialect meta-schema also annotates this keyword as deprecated. Validating a schema against that
meta-schema therefore reports the deprecation for you.
Digging Deeper
This keyword exists for historical reasons. The OpenAPI 3.0
Schema Object was based on Draft 4, which had no way of declaring
examples, as the examples keyword
only arrived in Draft 6. OpenAPI 3.0 therefore defined one of its
own.
OpenAPI 3.1 re-based the Schema Object on 2020-12. The
Meta-Data vocabulary of that dialect defines
examples, and OpenAPI 3.1
deprecated this keyword in that same release.
Common Pitfall
Do not confuse this keyword with the example and
examples properties that the Parameter, Header, and Media Type Objects
declare. Those are properties of an OpenAPI document rather than JSON Schema
keywords.
Examples
{
"$schema": "https://spec.openapis.org/oas/3.2/dialect/2026-02-26",
"type": "string",
"example": "John Doe"
}"Jane Doe"42{
"$schema": "https://spec.openapis.org/oas/3.2/dialect/2026-02-26",
"type": "string",
"example": 42
}"Jane Doe"