Skip to content

Commit ff5f34c

Browse files
committed
Add formatted-parts schema
1 parent 7c4353e commit ff5f34c

File tree

3 files changed

+211
-116
lines changed

3 files changed

+211
-116
lines changed

test/.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"fileMatch": [
55
"tests/**/*.json"
66
],
7-
"url": "./schemas/tests-schema-0.0.1.json"
7+
"url": "./schemas/v0-0-1/tests.schema.json"
88
}
99
]
1010
}
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0-0-1/formatted-parts.schema.json",
4+
"title": "Formatted parts",
5+
"description": "The expected result of formatting the message to parts.",
6+
"type": "array",
7+
"items": {
8+
"oneOf": [
9+
{
10+
"$ref": "#/$defs/messageLiteralPart"
11+
},
12+
{
13+
"$ref": "#/$defs/messageMarkupPart"
14+
},
15+
{
16+
"$ref": "#/$defs/messageExpressionPart"
17+
}
18+
]
19+
},
20+
"$defs": {
21+
"messageLiteralPart": {
22+
"type": "object",
23+
"additionalProperties": false,
24+
"required": [
25+
"type",
26+
"value"
27+
],
28+
"properties": {
29+
"type": {
30+
"const": "literal"
31+
},
32+
"value": {
33+
"type": "string"
34+
}
35+
}
36+
},
37+
"messageMarkupPart": {
38+
"type": "object",
39+
"additionalProperties": false,
40+
"required": [
41+
"type",
42+
"kind",
43+
"name"
44+
],
45+
"properties": {
46+
"type": {
47+
"const": "markup"
48+
},
49+
"kind": {
50+
"enum": [
51+
"open",
52+
"standalone",
53+
"close"
54+
]
55+
},
56+
"source": {
57+
"type": "string"
58+
},
59+
"name": {
60+
"type": "string"
61+
},
62+
"options": {
63+
"type": "object"
64+
}
65+
}
66+
},
67+
"messageExpressionPart": {
68+
"type": "object",
69+
"properties": {
70+
"type": {
71+
"enum": [
72+
"datetime",
73+
"fallback",
74+
"number",
75+
"string",
76+
"unknown"
77+
]
78+
}
79+
},
80+
"oneOf": [
81+
{
82+
"$ref": "#/$defs/messageDateTimePart"
83+
},
84+
{
85+
"$ref": "#/$defs/messageFallbackPart"
86+
},
87+
{
88+
"$ref": "#/$defs/messageNumberPart"
89+
},
90+
{
91+
"$ref": "#/$defs/messageStringPart"
92+
},
93+
{
94+
"$ref": "#/$defs/messageUnknownPart"
95+
}
96+
]
97+
},
98+
"messageDateTimePart": {
99+
"type": "object",
100+
"additionalProperties": false,
101+
"required": [
102+
"type",
103+
"source",
104+
"locale",
105+
"parts"
106+
],
107+
"properties": {
108+
"type": {
109+
"const": "datetime"
110+
},
111+
"source": {
112+
"type": "string"
113+
},
114+
"locale": {
115+
"type": "string"
116+
},
117+
"parts": {
118+
"type": "array",
119+
"items": {}
120+
}
121+
}
122+
},
123+
"messageFallbackPart": {
124+
"type": "object",
125+
"required": [
126+
"type",
127+
"source"
128+
],
129+
"properties": {
130+
"type": {
131+
"const": "fallback"
132+
},
133+
"source": {
134+
"type": "string"
135+
}
136+
}
137+
},
138+
"messageNumberPart": {
139+
"type": "object",
140+
"additionalProperties": false,
141+
"required": [
142+
"type",
143+
"source",
144+
"locale",
145+
"parts"
146+
],
147+
"properties": {
148+
"type": {
149+
"const": "number"
150+
},
151+
"source": {
152+
"type": "string"
153+
},
154+
"locale": {
155+
"type": "string"
156+
},
157+
"parts": {
158+
"type": "array",
159+
"items": {}
160+
}
161+
}
162+
},
163+
"messageStringPart": {
164+
"type": "object",
165+
"additionalProperties": false,
166+
"required": [
167+
"type",
168+
"source",
169+
"locale",
170+
"value"
171+
],
172+
"properties": {
173+
"type": {
174+
"const": "string"
175+
},
176+
"source": {
177+
"type": "string"
178+
},
179+
"locale": {
180+
"type": "string"
181+
},
182+
"value": {
183+
"type": "string"
184+
}
185+
}
186+
},
187+
"messageUnknownPart": {
188+
"type": "object",
189+
"additionalProperties": false,
190+
"required": [
191+
"type",
192+
"source",
193+
"value"
194+
],
195+
"properties": {
196+
"type": {
197+
"const": "unknown"
198+
},
199+
"source": {
200+
"type": "string"
201+
},
202+
"value": {}
203+
}
204+
}
205+
}
206+
}

test/schemas/tests-schema-0.0.1.json renamed to test/schemas/v0-0-1/tests.schema.json

Lines changed: 4 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/tests-schema-0.0.1.json",
4-
"title": "MessageFormat 2 data-driven tests source",
5-
"description": "This documents the format of MessageFormat 2 source test data.",
3+
"$id": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0-0-1/tests.schema.json",
4+
"title": "MessageFormat 2 data-driven tests",
5+
"description": "This is the main schema for MessageFormat 2 test source data.",
66
"type": "object",
77
"additionalProperties": false,
88
"required": [
@@ -276,118 +276,7 @@
276276
}
277277
},
278278
"expParts": {
279-
"description": "The expected result of formatting the message to parts.",
280-
"type": "array",
281-
"items": {
282-
"type": "object",
283-
"required": [
284-
"type"
285-
],
286-
"properties": {
287-
"type": {
288-
"enum": [
289-
"markup",
290-
"literal",
291-
"fallback"
292-
]
293-
},
294-
"kind": {},
295-
"name": {},
296-
"value": {},
297-
"source": {}
298-
},
299-
"oneOf": [
300-
{
301-
"additionalProperties": false,
302-
"required": [
303-
"kind",
304-
"name"
305-
],
306-
"properties": {
307-
"type": {
308-
"const": "markup"
309-
},
310-
"kind": {
311-
"enum": [
312-
"standalone",
313-
"open",
314-
"close"
315-
]
316-
},
317-
"name": {
318-
"type": "string"
319-
},
320-
"options": {
321-
"$ref": "#/$defs/expPartOptions"
322-
}
323-
}
324-
},
325-
{
326-
"additionalProperties": false,
327-
"required": [
328-
"value",
329-
"valueType"
330-
],
331-
"properties": {
332-
"type": {
333-
"const": "literal"
334-
},
335-
"value": {
336-
"type": "number"
337-
},
338-
"valueType": {
339-
"enum": [
340-
"integer"
341-
]
342-
},
343-
"options": {
344-
"$ref": "#/$defs/expPartOptions"
345-
}
346-
}
347-
},
348-
{
349-
"additionalProperties": false,
350-
"required": [
351-
"value"
352-
],
353-
"properties": {
354-
"type": {
355-
"const": "literal"
356-
},
357-
"value": {
358-
"type": "string"
359-
},
360-
"options": {
361-
"$ref": "#/$defs/expPartOptions"
362-
}
363-
}
364-
},
365-
{
366-
"additionalProperties": false,
367-
"required": [
368-
"source"
369-
],
370-
"properties": {
371-
"type": {
372-
"const": "fallback"
373-
},
374-
"source": {
375-
"type": "string"
376-
}
377-
}
378-
}
379-
]
380-
}
381-
},
382-
"expPartOptions": {
383-
"description": "Expected option value within a part.",
384-
"type": "object",
385-
"additionalProperties": {
386-
"type": [
387-
"string",
388-
"number"
389-
]
390-
}
279+
"$ref": "formatted-parts.schema.json"
391280
},
392281
"expErrors": {
393282
"description": "The runtime errors expected to be emitted when formatting the message. If expErrors is either absent or empty, the message must be formatted without errors.",

0 commit comments

Comments
 (0)