examples : Array<Any>

examples

Array<Any>

This keyword is used to provide sample JSON values associated with a particular schema, for the purpose of illustrating usage.

Value This keyword must be set to an array of JSON values that preferrably successfully validates against the corresponding subschema Hint: Use the jsonschema metaschema and jsonschema lint commands to catch keywords set to invalid values
Kind Annotation
Applies To Any
Base Dialect 2020-12
Changed In None
Introduced In Draft 6
Vocabulary Meta Data
Specification https://json-schema.org/draft/2020-12/json-schema-validation.html#section-9.5
Metaschema https://json-schema.org/draft/2020-12/meta/meta-data
Official Tests draft2020-12/optional/refOfUnknownKeyword.json
Default []
Annotation Array The set of examples set by this keyword Hint: Use the jsonschema validate command to collect annotations from the command-line
Affected By None
Affects None
Also See

The examples keyword declares a set of example instances for a schema or any of its subschemas, typically for documentation purposes. This keyword does not affect validation, but the evaluator will collect its set of values as an annotation.

Examples

A schema that describes name and age properties and declares top level and nested valid examples Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "examples": [
    { "name": "John Doe", "age": 23 }
  ],
  "properties": {
    "name": {
      "type": "string",
      "examples": [ "John Doe", "Jane Doe" ]
    },
    "age": {
      "type": "integer",
      "examples": [ 1, 18, 55 ]
    }
  }
}
Valid An object value that defines name and age is valid and the corresponding annotations are emitted Instance
{ "name": "Juan Cruz Viotti", "age": 30 }
Annotations
{ "keyword": "/examples", "instance": "", "value": [ { "name": "John Doe", "age": 23 } ] }
{ "keyword": "/properties/name/examples", "instance": "/name", "value": [ "John Doe", "Jane Doe" ] }
{ "keyword": "/properties/age/examples", "instance": "/age", "value": [ 1, 18, 55 ] }
Valid An object value that omits some properties is valid and only the corresponding annotations are emitted Instance
{ "age": 50 }
Annotations
{ "keyword": "/examples", "instance": "", "value": [ { "name": "John Doe", "age": 23 } ] }
{ "keyword": "/properties/age/examples", "instance": "/age", "value": [ 1, 18, 55 ] }
Invalid A value that does not match the schema is invalid and no annotations are emitted Instance
{ "name": 1, "age": true }