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