-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathschema.json.dot
More file actions
93 lines (93 loc) · 3.05 KB
/
schema.json.dot
File metadata and controls
93 lines (93 loc) · 3.05 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
"id": "http://www.jsonscript.org/schema/schema{{?it.strictSchema}}_strict{{?}}.json#",
"$schema": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json#",
"title": "JSONScript schema",
"description": "JSONScript script with instructions (generated from template)",
"anyOf": [
{{~ it.instructions:inst }}
{ "$ref": "#{{=inst.name}}" },
{{~}}
{{~ it.macros:macro }}
{{~ macro.rules:rule:i }}
{ "$ref": "#macro_{{=macro.name}}_{{=i}}" },
{{~}}
{{~}}
{ "$ref": "#parallel" },
{ "$ref": "#sequential" },
{ "$ref": "#scalar" }
],
"definitions": {
{{~ it.instructions:inst }}
"_{{=inst.name}}": {
"id": "#{{=inst.name}}",
"title": "{{=inst.name}}",
"description": "{{=inst.description}}",
"type": "object",
"properties": {
{{~ inst.keywords:keyword:i }}
{{?i}},{{?}}
{{
var keywordSch = inst.schema && inst.schema[keyword]
, validateScalarType = it.strictSchema && keywordSch && typeof keywordSch.type == 'string' &&
['string', 'number', 'integer', 'boolean', 'null'].indexOf(keywordSch.type) >= 0;
}}
{{? validateScalarType }}
"{{=keyword}}": {
"anyOf": [
{{= JSON.stringify(inst.schema[keyword]) }},
{
"allOf": [
{ "type": [ "object", "array" ] },
{ "$ref": "#" }
]
}
]
}
{{??}}
"{{=keyword}}": { "$ref": "#" }
{{?}}
{{~}}
},
"additionalProperties": false,
"required": {{= JSON.stringify(inst.required) }}
},
{{~}}
{{~ it.macros:macro }}
{{~ macro.rules:rule:i }}
{{ var patternKey = Object.keys(rule.pattern)[0].replace(/\\/g, '\\\\'); }}
"_macro_{{=macro.name}}_{{=i}}": {
"id": "#macro_{{=macro.name}}_{{=i}}",
"description": "{{=macro.description}}",
"type": "object",
"patternProperties": {
"{{= patternKey }}": { "$ref": "#" }
},
"maxProperties": 1,
"minProperties": 1,
"additionalProperties": false,
"patternRequired": [ "{{= patternKey }}" ]
},
{{~}}
{{~}}
"parallel": {
"id": "#parallel",
"description": "scripts in the object are executed in parallel, property names should not start with $",
"type": "object",
"patternProperties": {
"^[^$]": { "$ref": "#" }
},
"additionalProperties": false
},
"sequential": {
"id": "#sequential",
"description": "scripts in array are executed sequentially",
"type": "array",
"items": { "$ref": "#" }
},
"scalar": {
"id": "#scalar",
"description": "scalar values are also valid JSONScript",
"type": [ "string", "number", "integer", "boolean", "null" ]
}
}
}