]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | { |
2 | "$schema": "http://json-schema.org/draft-04/schema#", | |
3 | ||
4 | "id": "http://thrift.apache.org/schema.json#", | |
5 | "description": "Schema for Apache Thrift protocol descriptors", | |
6 | ||
7 | "definitions": { | |
8 | "type-id": { | |
9 | "title": "Any type id (name)", | |
10 | "enum": [ | |
11 | "void", | |
12 | "string", | |
13 | "bool", | |
14 | "byte", | |
15 | "i8", | |
16 | "i16", | |
17 | "i32", | |
18 | "i64", | |
19 | "double", | |
20 | "list", | |
21 | "set", | |
22 | "map", | |
23 | "union", | |
24 | "struct", | |
25 | "binary" | |
26 | ] | |
27 | }, | |
28 | "base-type": { | |
29 | "title": "Base type schema", | |
30 | "type": "object", | |
31 | "properties": { | |
32 | "typeId": { | |
33 | "enum": ["void", "string", "bool", "byte", "i8", "i16", "i32", "i64", "double", "binary" ] | |
34 | } | |
35 | }, | |
36 | "required": [ "typeId" ] | |
37 | }, | |
38 | "list-type": { | |
39 | "title": "List and set schema", | |
40 | "type": "object", | |
41 | "properties": { | |
42 | "typeId": { | |
43 | "enum": [ "list", "set" ] | |
44 | }, | |
45 | "elemTypeId": { "$ref": "#/definitions/type-id" }, | |
46 | "elemType": { "$ref": "#/definitions/type-desc" } | |
47 | }, | |
48 | "required": [ "typeId", "elemTypeId" ] | |
49 | }, | |
50 | "map-type": { | |
51 | "title": "Map schema", | |
52 | "type": "object", | |
53 | "properties": { | |
54 | "typeId": { | |
55 | "enum": [ "map" ] | |
56 | }, | |
57 | "keyTypeId": { "$ref": "#/definitions/type-id" }, | |
58 | "keyType": { "$ref": "#/definitions/type-desc" }, | |
59 | "valueTypeId": { "$ref": "#/definitions/type-id" }, | |
60 | "valueType": { "$ref": "#/definitions/type-desc" } | |
61 | }, | |
62 | "required": [ "typeId", "keyTypeId", "valueTypeId" ] | |
63 | }, | |
64 | "struct-type": { | |
65 | "title": "Struct, union and exception schema", | |
66 | "type": "object", | |
67 | "properties": { | |
68 | "typeId": { | |
69 | "enum": [ "union", "struct", "exception" ] | |
70 | } | |
71 | }, | |
72 | "required": [ "typeId", "class" ] | |
73 | }, | |
74 | "type-desc": { | |
75 | "title": "Type descriptor schema", | |
76 | "allOf": [ | |
77 | { | |
78 | "type": "object", | |
79 | "properties": { | |
80 | "typeId": { "type": "string" }, | |
81 | "class": { "type": "string" } | |
82 | } | |
83 | }, | |
84 | { | |
85 | "oneOf": | |
86 | [ | |
87 | { "$ref": "#/definitions/base-type" }, | |
88 | { "$ref": "#/definitions/list-type" }, | |
89 | { "$ref": "#/definitions/map-type" }, | |
90 | { "$ref": "#/definitions/struct-type" } | |
91 | ] | |
92 | } | |
93 | ] | |
94 | }, | |
95 | "name-and-doc": { | |
96 | "title": "Name and documentation sub-schema", | |
97 | "type": "object", | |
98 | "properties": { | |
99 | "name": { "type": "string" }, | |
100 | "doc": { "type": "string" } | |
101 | }, | |
102 | "required": [ "name" ] | |
103 | }, | |
104 | "enum": { | |
105 | "title": "Thrift 'enum' definition schema", | |
106 | "type": "object", | |
107 | "allOf": [ | |
108 | { "$ref": "#/definitions/name-and-doc" }, | |
109 | { | |
110 | "required": [ "members" ], | |
111 | "properties": { | |
112 | "members": { | |
113 | "type": "array", | |
114 | "items": { | |
115 | "type": "object", | |
116 | "properties": { | |
117 | "name": { "type": "string" }, | |
118 | "value": { "type": "integer" } | |
119 | }, | |
120 | "required": [ "name", "value" ] | |
121 | } | |
122 | } | |
123 | } | |
124 | } | |
125 | ] | |
126 | }, | |
127 | "typedef": { | |
128 | "title": "Thrift typedef definition schema", | |
129 | "type": "object", | |
130 | "allOf": [ | |
131 | { "$ref": "#/definitions/name-and-doc" }, | |
132 | { | |
133 | "properties": { | |
134 | "typeId": { "$ref": "#/definitions/type-id" }, | |
135 | "type": { "$ref": "#/definitions/type-desc" } | |
136 | }, | |
137 | "required": [ "typeId" ] | |
138 | } | |
139 | ] | |
140 | }, | |
141 | "constant": { | |
142 | "title": "Thrift constant definition schema", | |
143 | "type": "object", | |
144 | "allOf": [ | |
145 | { "$ref": "#/definitions/name-and-doc" }, | |
146 | { "$ref": "#/definitions/type-desc" }, | |
147 | { | |
148 | "properties": { | |
149 | "value": { | |
150 | "oneOf": [ | |
151 | { "type": "string" }, | |
152 | { "type": "number" }, | |
153 | { "type": "array" }, | |
154 | { "type": "object" } | |
155 | ] | |
156 | } | |
157 | }, | |
158 | "required": [ "value" ] | |
159 | } | |
160 | ] | |
161 | }, | |
162 | "field": { | |
163 | "title": "Thrift struct field definition schema", | |
164 | "type": "object", | |
165 | "allOf": [ | |
166 | { "$ref": "#/definitions/name-and-doc" }, | |
167 | { | |
168 | "properties": { | |
169 | "key": { | |
170 | "type": "integer", | |
171 | "minimum": 1, | |
172 | "maximum": 65535 | |
173 | }, | |
174 | "required": { | |
175 | "enum": [ "required", "optional", "req_out" ] | |
176 | }, | |
177 | "typeId": { "$ref": "#/definitions/type-id" }, | |
178 | "type": { "$ref": "#/definitions/type-desc" }, | |
179 | "default": { | |
180 | "oneOf": [ | |
181 | { "type": "string" }, | |
182 | { "type": "number" }, | |
183 | { "type": "array" }, | |
184 | { "type": "object" } | |
185 | ] | |
186 | } | |
187 | }, | |
188 | "required": [ "key", "required" ] | |
189 | } | |
190 | ] | |
191 | }, | |
192 | "struct": { | |
193 | "title": "Thrift struct definition schema", | |
194 | "type": "object", | |
195 | "allOf": [ | |
196 | { "$ref": "#/definitions/name-and-doc" }, | |
197 | { | |
198 | "properties": { | |
199 | "isException": { "type": "boolean" }, | |
200 | "isUnion": { "type": "boolean" }, | |
201 | "fields": { | |
202 | "type": "array", | |
203 | "items": { | |
204 | "$ref": "#/definitions/field" | |
205 | } | |
206 | } | |
207 | }, | |
208 | "required": [ "isException", "isUnion", "fields" ] | |
209 | } | |
210 | ] | |
211 | }, | |
212 | "union": { | |
213 | "title": "Thrift union definition schema", | |
214 | "$ref": "#/definitions/struct" | |
215 | }, | |
216 | "exception": { | |
217 | "title": "Thrift exception definition schema", | |
218 | "type": "object", | |
219 | "properties": { | |
220 | "key": { | |
221 | "type": "integer", | |
222 | "minimum": 1, | |
223 | "maximum": 65535 | |
224 | }, | |
225 | "name": { "type": "string" }, | |
226 | "typeId": { "enum": [ "exception" ] }, | |
227 | "type": { "$ref": "#/definitions/struct-type" } | |
228 | }, | |
229 | "required": [ "key", "name", "typeId" ] | |
230 | }, | |
231 | "function": { | |
232 | "title": "Thrift service function definition schema", | |
233 | "type": "object", | |
234 | "allOf": [ | |
235 | { "$ref": "#/definitions/name-and-doc" }, | |
236 | { | |
237 | "properties": { | |
238 | "oneway": { | |
239 | "type": "boolean" | |
240 | }, | |
241 | "returnType": { | |
242 | "$ref": "#/definitions/type-desc" | |
243 | }, | |
244 | "arguments": { | |
245 | "type": "array", | |
246 | "items": { | |
247 | "$ref": "#/definitions/field" | |
248 | } | |
249 | }, | |
250 | "exceptions": { | |
251 | "type": "array", | |
252 | "items": { "$ref": "#/definitions/exception" } | |
253 | } | |
254 | }, | |
255 | "required": [ "oneway", "arguments", "exceptions" ] | |
256 | } | |
257 | ] | |
258 | }, | |
259 | "service": { | |
260 | "title": "Thrift service definition schema", | |
261 | "type": "object", | |
262 | "allOf": [ | |
263 | { "$ref": "#/definitions/name-and-doc" }, | |
264 | { | |
265 | "properties": { | |
266 | "functions": { | |
267 | "type": "array", | |
268 | "items": { | |
269 | "$ref": "#/definitions/function" | |
270 | } | |
271 | } | |
272 | }, | |
273 | "required": [ "functions" ] | |
274 | } | |
275 | ] | |
276 | }, | |
277 | "annotations": { | |
278 | "title": "Map of annotation names to values", | |
279 | "type": "object", | |
280 | "additionalProperties": { | |
281 | "type": "string" | |
282 | } | |
283 | } | |
284 | }, | |
285 | ||
286 | "type": "object", | |
287 | "required": [ | |
288 | "name", | |
289 | "enums", | |
290 | "typedefs", | |
291 | "structs", | |
292 | "constants", | |
293 | "services" | |
294 | ], | |
295 | "properties": { | |
296 | "name": { | |
297 | "type": "string" | |
298 | }, | |
299 | "includes": { | |
300 | "type": "array", | |
301 | "items": { | |
302 | "type": "string" | |
303 | }, | |
304 | "uniqueItems": true | |
305 | }, | |
306 | "namespaces": { | |
307 | "type": "object", | |
308 | "additionalProperties": { | |
309 | "type": "string" | |
310 | } | |
311 | }, | |
312 | "enums": { | |
313 | "type": "array", | |
314 | "items": { | |
315 | "$ref": "#/definitions/enum" | |
316 | } | |
317 | }, | |
318 | "typedefs": { | |
319 | "type": "array", | |
320 | "items": { | |
321 | "$ref": "#/definitions/typedef" | |
322 | } | |
323 | }, | |
324 | "structs": { | |
325 | "type": "array", | |
326 | "items": { | |
327 | "$ref": "#/definitions/struct" | |
328 | } | |
329 | }, | |
330 | "constants": { | |
331 | "type": "array", | |
332 | "items": { | |
333 | "$ref": "#/definitions/constant" | |
334 | } | |
335 | }, | |
336 | "services": { | |
337 | "type": "array", | |
338 | "items": { | |
339 | "$ref": "#/definitions/service" | |
340 | } | |
341 | } | |
342 | }, | |
343 | "additionalProperties": false | |
344 | } |