Un tipo | Palabra (s) clave | Ejemplo / Descripción |
---|
"Palabras clave" para describir el esquema | "$schema" | "$schema": http:
Se utiliza para configurar la versión borrador del esquema. |
"$id"
| "$id": "http://archi-blair.com/schemas/RolesDictionaryDef.json#"
Se usa para indicar un identificador único para un documento o sus subcircuitos. |
"title" "description" "examples" "comment"
| {
"title": "JSON schema for dictionary",
"description": " ",
"examples": ["user", "manager"],
"comment": " ))"
}
|
"Palabras clave de validación" generales independientes del tipo de datos del elemento | "enum" | {"enum": [ "administrator", "superuser" ]}
Se realiza una comprobación para que coincida con al menos 1 valor.
|
"const" | {"const": "user" }
Se realiza una verificación para el cumplimiento exacto del valor establecido.
|
"type" | {"type": ["number", "string", "null", "boolean"]}
{"type": "array"}
Especifica el tipo de datos que usará el esquema. Esta palabra clave es opcional, y el valor de la palabra clave puede ser una cadena que representa un tipo de datos válido o una matriz de cadenas que representan tipos de datos válidos.
|
Keywords, , | "type": "string"
minLength maxLength pattern contentEncoding contentMediaType
| {
"type": "string",
"minLength": 3,
"maxLength": 10,
"pattern": "^test\\/[a-z-]+$",
"contentEncoding": "base64",
"contentMediaType": "application/json"
}
.
|
"type": "number" "type": "integer"
minimum exclusiveMinimum maximum exclusiveMaximum multipleOf
| {
"type": "number",
"minimum": 1.5,
"exclusiveMinimum": true,
"maximum": 12.3,
"exclusiveMaximum": true,
"multipleOf": 0.5
}
.
|
"type": "object"
properties required dependencies minProperties maxProperties propertyNames patternProperties additionalProperties
|
"employees": {
"description": "",
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"enum": ["employee"],
"enumNames": [""]
},
"enabled": {
"type": "boolean",
"default": true
}
},
"additionalProperties": false
}
}
, ( ).
|
"type": "array"
minItems maxItems uniqueItems contains items additionalItems
|
"employees": {
"description": "",
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"enum": ["employee"],
"enumNames": [""]
},
"enabled": {
"type": "boolean",
"default": true
}
},
"additionalProperties": false
}
}
, ( ).
|
"type": "boolean"
| {"type": "boolean"}
boolean (true false).
|
"type": "null"
| {"type": "null"}
null «» .
|
"type": "____" "format": "____"
| {
"type": "string",
"format": "date"
}
format . , .. -, , , .
|
"type": "____" "default": "____"
| {
"enabled": {
"type": "boolean",
"default": true
}
.
, .
|
| "not" "if-then-else"
| {
"not": {
"type": "string"
}
}
, .
|
, | "anyOf" "oneOf" "allOf"
| {
"type": "string",
"anyOf": [
{"const": "user"},
{"const": "manager" }
]
}
, .
|
, | "$id" "$ref" | RolesDictionaryDef.json:
{
"$id": http:
}
1 $ref ( ):
"items": {
"type": "object",
"minLength": 1,
"properties": {
"name": {
"description": " ",
"type": "string"
},
"description": {
"description": " ",
"type": "string"
},
"dictionaryGroup": {
"$ref": "RolesDictionaryDef.json#/definitions/roles"
}
},
"additionalProperties": false
}
2 JSON. , $ref .
|
"$ref" "definitions" | "$ref": "#/definitions/roles" , «definitions»:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": " ",
"type": "object",
"properties": {
"dictionaries": {
"description": "",
"type": "array",
"maxItems": 1,
"items": {
"type": "object",
"minLength": 1,
"properties": {
"name": {
"description": " ",
"type": "string",
"enum": [
"Roles Dictionary"
]
}
"dictionaryGroups": {
"$ref": "#/definitions/roles",
"description": " "
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false,
"definitions": {
"roles": {
"description": "",
"type": "object",
"properties": {
"administrators": {
"description": "",
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"enum": [
"administrator",
"superuser"
],
"enumNames": [
"",
"- "
]
},
"enabled": {
"type": "boolean",
"default": true
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
},
"$id": "http://archi-blair.com/schemas/RolesDictionaryDef.json#"
}
, . $ref definitions.
|
"$ref" .
| "$ref": " #/definitions/roles"
"$ref": "RolesDictionaryDef.json#/definitions/roles"
, . , .
|