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 preferably 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 Draft 6
Changed In None
Introduced In Draft 6
Vocabulary Validation
Specification https://json-schema.org/draft-06/draft-wright-json-schema-validation-01#rfc.section.7.4
Metaschema http://json-schema.org/draft-06/schema#
Official Tests None
Default []
Annotation None
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 is merely descriptive and does not affect validation.

Examples

A schema that describes name and age properties and declares top level and nested valid examples Schema
{
  "$schema": "http://json-schema.org/draft-06/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 Instance
{ "name": "Juan Cruz Viotti", "age": 30 }
Valid An object value that omits some properties is valid Instance
{ "age": 50 }
Invalid A value that does not match the schema is invalid Instance
{ "name": 1, "age": true }