-
-
Notifications
You must be signed in to change notification settings - Fork 546
/
canonical-data.schema.json
163 lines (145 loc) · 5.38 KB
/
canonical-data.schema.json
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
{
"comments": [
" This is a JSON Schema for 'canonical-data.json' files. ",
" ",
" It enforces just a general structure for all exercises, ",
" optimising for the ability to represent example-based tests",
" of the form 'function (input) == output'. Future expansions",
" may allow for other types of tests such as property-based. ",
" ",
" The only thing enforced regarding how test data should be ",
" structured is the error encoding, because it was agreed ",
" and it doesn't restrict flexibility in a significant way. ",
" ",
" Standardized property names may help when automatically ",
" deriving JSON parsers in some languages, so we followed ",
" a few conventions from the 'Google JSON Style Guide'. ",
" ",
" Additionally, this schema strictly enforces letters, in ",
" lowerCamelCase, for naming the 'property' being tested. We ",
" expect this regularity will allow an easier automatic ",
" generation of function's names in test generators, ",
" slightly reducing the amount of manually generated code. "
],
"$schema": "http://json-schema.org/draft-07/schema#",
"self": {
"vendor": "io.exercism",
"name": "canonical-data",
"format": "jsonschema",
"version": "1-1-0"
},
"$ref": "#/definitions/canonicalData",
"definitions": {
"canonicalData": {
"description": "This is the top-level file structure",
"type": "object",
"required": ["exercise", "cases"],
"properties": {
"exercise": { "$ref": "#/definitions/exercise" },
"comments": { "$ref": "#/definitions/comments" },
"cases": { "$ref": "#/definitions/testGroup" }
},
"additionalProperties": false
},
"exercise": {
"description": "Exercise's slug (kebab-case)",
"type": "string",
"pattern": "^[a-z]+(-[a-z]+)*$"
},
"comments": {
"description": "An array of strings to fake multi-line comments",
"type": "array",
"items": { "type": "string" },
"minItems": 1
},
"testGroup": {
"description": "An array of labeled test items",
"type": "array",
"items": { "$ref": "#/definitions/labeledTestItem" },
"minItems": 1
},
"labeledTestItem": {
"description": "A single test or group of tests with a description",
"oneOf": [
{ "$ref": "#/definitions/labeledTest" },
{ "$ref": "#/definitions/labeledTestGroup" }
]
},
"labeledTest": {
"description": "A single test with a description",
"type": "object",
"required": ["uuid", "description", "property", "input", "expected"],
"properties": {
"uuid": { "$ref": "#/definitions/uuid" },
"reimplements": { "$ref": "#/definitions/uuid" },
"description": { "$ref": "#/definitions/description" },
"comments": { "$ref": "#/definitions/comments" },
"scenarios": { "$ref": "#/definitions/scenarios" },
"property": { "$ref": "#/definitions/property" },
"input": { "$ref": "#/definitions/input" },
"expected": { "$ref": "#/definitions/expected" }
},
"additionalProperties": false
},
"labeledTestGroup": {
"description": "A group of tests with a description",
"type": "object",
"required": ["description", "cases"],
"properties": {
"description": { "$ref": "#/definitions/description" },
"comments": { "$ref": "#/definitions/comments" },
"scenarios": { "$ref": "#/definitions/scenarios" },
"cases": { "$ref": "#/definitions/testGroup" }
},
"additionalProperties": false
},
"description": {
"description": "A short, clear, one-line description",
"type": "string"
},
"uuid": {
"description": "A version 4 UUID (compliant with RFC 4122) in the canonical textual representation",
"type": "string",
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
},
"scenario": {
"description": "An identifier for a specific scenario (kebab-case)",
"type": "string",
"enum": [
"big-integer",
"concurrent",
"date",
"datetime",
"floating-point",
"immutable",
"input-validation",
"library-test",
"local-scope",
"random",
"runtime-validation",
"unicode"
]
},
"scenarios": {
"description": "An array of scenarios that can be used to include/exclude test cases",
"type": "array",
"items": { "$ref": "#/definitions/scenario" },
"minItems": 0
},
"property": {
"description": "A letters-only, lowerCamelCase property name",
"type": "string",
"pattern": "^[a-z]+([A-Z][a-z]+)*[A-Z]?$"
},
"input": { "description": "The inputs to a test case", "type": "object" },
"expected": {
"description": "The expected return value of a test case",
"properties": { "error": { "$ref": "#/definitions/error" } },
"dependencies": { "error": { "maxProperties": 1 } }
},
"error": {
"description": "A message describing an error condition",
"type": "string"
}
}
}