-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathJTD.format.txt
72 lines (52 loc) · 3.56 KB
/
JTD.format.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
┏━━━━━━━━━┓
┃ JTD ┃
┗━━━━━━━━━┛
ALTERNATIVES ==> #See JSON schema
VERSION ==> #RFC 8927
#"JSON Type Definitions" or "JSON typedefs"
┌────────────────┐
│ SUBSCHEMAS │
└────────────────┘
SCHEMA #OBJ
#If empty, means always valid.
RSCHEMA #Root level of schema
RSCHEMA.definitions.DEF SCHEMA
SCHEMA.ref 'DEF' #Replaced by RSCHEMA.definitions.DEF
#Can be recursive
┌──────────────┐
│ METADATA │
└──────────────┘
SCHEMA.metadata VAL #Can be anything
┌────────────────┐
│ VALIDATION │
└────────────────┘
MIXING ==> #Can only mix keywords if not separated by newline in the following paragraphs
# - e.g. can specify both properties and optionalProperties together, but not type and enum
#Exception: SCHEMA.nullable|metadata can be mixed with any other keywords
SCHEMA.type 'TYPE' #VAL of 'TYPE' among:
# - 'boolean'
# - 'string'
# - 'timestamp': 'YYYY-MM-DDTHH:MM:SS.SSZ' (RFC3339)
# - '[u]int8|16|32'
# - 'float32|64'
#No OBJ|ARR|null
SCHEMA.nullable BOOL #Allow VAL to be null
#Def: false (except if empty SCHEMA)
STR_SCHEMA.enum STR_ARR #Only possible values
#Cannot be empty. Cannot contain duplicates
ARR_SCHEMA.elements SCHEMA #SCHEMA is applied against each ARR element
OBJ_SCHEMA.values SCHEMA #SCHEMA is applied against each OBJ value
OBJ_SCHEMA.optionalProperties.VAR
SCHEMA #SCHEMA is applied against OBJ.VAR
OBJ_SCHEMA.properties.VAR SCHEMA #Same but also required
OBJ_SCHEMA.additionalProperties #Whether OBJ.VAR not specified in OBJ_SCHEMA are allowed (i.e. present in schema but not in OBJ)
BOOL #Def: false
#[optional]properties must be a sibling
OBJ_SCHEMA.discriminator 'VAR' #SCHEMA is applied to OBJ.VAR if its value is a STR with value 'VAL'
OBJ_SCHEMA.mapping.VAL SCHEMA #SCHEMA must use [optional|additional]properties, and not include VAR
┌────────────┐
│ OUTPUT │
└────────────┘
OUTPUT_ARR #Recommendation on how implementation should output validation
OUTPUT.instancePath #'JSON_POINTER': within VAL
OUTPUT.schemaPath #'JSON_POINTER': within SCHEMA