title : String
title
StringA preferably short description about the purpose of the instance described by the schema.
Value |
This keyword must be set to a string
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 1 |
Vocabulary | Meta Data |
Specification | https://json-schema.org/draft/2020-12/json-schema-validation.html#section-9.1 |
Metaschema | https://json-schema.org/draft/2020-12/meta/meta-data |
Official Tests | None |
Default | None |
Annotation |
String
The title 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 title
keyword is a placeholder for a concise human-readable string
summary of what a schema or any of its subschemas are about. This keyword does
not affect validation, but the evaluator will collect its value as an
annotation.
Best Practice
We heavily recommend to declare this keyword at the top level of every schema, as a human-readable introduction to what the schema is about.
When doing so, note that the JSON Schema specification does not impose or
recommend a maximum length for this keyword. However, it is common practice to
stick to Git commit message
title
conventions and set it to a capitalised string of 50 characters or less. If
you run out of space, you can move the additional information to the
description
keyword.
Common Pitfall
Tooling makers must be careful when statically traversing schemas in search of occurences of this keyword. It is possible for schemas to make use of this keyword behind conditional operators, references, or any other type of keyword that makes it hard or even impossible to correctly locate these values without fully evaluating the schema against an instance. The only bullet proof method is through annotation collection.
Examples
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Even Number",
"type": "number",
"multipleOf": 2
}
10
{ "keyword": "/title", "instance": "", "value": "Even number" }
7
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Number",
"type": "number",
"if": { "multipleOf": 2 },
"then": { "title": "Even Number" },
"else": { "title": "Odd Number" }
}
10
{ "keyword": "/title", "instance": "", "value": "Number" }
{ "keyword": "/then/title", "instance": "", "value": "Even Number" }
7
{ "keyword": "/title", "instance": "", "value": "Number" }
{ "keyword": "/else/title", "instance": "", "value": "Odd Number" }
"Hello World"