definitions : Object<String, Schema>

definitions

Object<String, Schema>

This keyword reserves a location for schema authors to inline reusable JSON Schemas into a more general schema.

Value This keyword must be set to an object where each value is a valid JSON Schema Hint: Use the jsonschema metaschema and jsonschema lint commands to catch keywords set to invalid values
Kind Reserved Location
Applies To Any
Base Dialect Draft 6
Changed In None
Introduced In Draft 4
Vocabulary Validation
Specification https://json-schema.org/draft-06/draft-wright-json-schema-validation-01#rfc.section.7.1
Metaschema http://json-schema.org/draft-06/schema#
Official Tests draft6/definitions.json
Default {}
Annotation None
Affected By None
Affects None
Also See

The definitions keyword is a container for storing reusable schemas within a schema resource, which can be referenced using the $ref keyword. From a software engineering point of view, this keyword is analogous to defining internal helper functions as part of a larger program.

Examples

A schema that declares a helper schema to reduce duplication when defining multiple properties Schema
{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "properties": {
    "firstName": { "$ref": "#/definitions/nonEmptyString" },
    "lastName": { "$ref": "#/definitions/nonEmptyString" }
  },
  "definitions": {
    "nonEmptyString": {
      "type": "string",
      "minLength": 1
    }
  }
}
Valid An object value with non-empty first and last names is valid Instance
{ "firstName": "John", "lastName": "Doe" }
Invalid An object value with empty first and last names is invalid Instance
{ "firstName": "", "lastName": "" }