blob: 011b4d37ac48daf12a2c062cda3fd48312f83009 [file] [log] [blame]
Jens Geyerffa255c2014-12-01 02:10:48 +01001{
2 "$schema": "http://json-schema.org/draft-04/schema#",
3
Stig Bakkenae3775a2014-12-02 09:21:24 +01004 "id": "http://thrift.apache.org/schema.json#",
Jens Geyerffa255c2014-12-01 02:10:48 +01005 "description": "Schema for Apache Thrift protocol descriptors",
6
7 "definitions": {
8 "type-id": {
Stig Bakkenae3775a2014-12-02 09:21:24 +01009 "title": "Any type id (name)",
Jens Geyerffa255c2014-12-01 02:10:48 +010010 "enum": [
11 "void",
12 "string",
13 "bool",
14 "byte",
Stig Bakkenae3775a2014-12-02 09:21:24 +010015 "i8",
Jens Geyerffa255c2014-12-01 02:10:48 +010016 "i16",
17 "i32",
18 "i64",
19 "double",
20 "list",
21 "set",
22 "map",
23 "union",
24 "struct",
Jens Geyerffa255c2014-12-01 02:10:48 +010025 "binary"
26 ]
27 },
28 "base-type": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010029 "title": "Base type schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010030 "type": "object",
31 "properties": {
32 "typeId": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010033 "enum": ["void", "string", "bool", "byte", "i8", "i16", "i32", "i64", "double", "binary" ]
Jens Geyerffa255c2014-12-01 02:10:48 +010034 }
35 },
36 "required": [ "typeId" ]
37 },
38 "list-type": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010039 "title": "List and set schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010040 "type": "object",
41 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010042 "typeId": {
43 "enum": [ "list", "set" ]
44 },
45 "elemTypeId": { "$ref": "#/definitions/type-id" },
46 "elemType": { "$ref": "#/definitions/type-desc" }
Jens Geyerffa255c2014-12-01 02:10:48 +010047 },
Stig Bakkenae3775a2014-12-02 09:21:24 +010048 "required": [ "typeId", "elemTypeId" ]
Jens Geyerffa255c2014-12-01 02:10:48 +010049 },
50 "map-type": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010051 "title": "Map schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010052 "type": "object",
53 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010054 "typeId": {
55 "enum": [ "map" ]
56 },
Jens Geyerffa255c2014-12-01 02:10:48 +010057 "keyTypeId": { "$ref": "#/definitions/type-id" },
Stig Bakkenae3775a2014-12-02 09:21:24 +010058 "keyType": { "$ref": "#/definitions/type-desc" },
Jens Geyerffa255c2014-12-01 02:10:48 +010059 "valueTypeId": { "$ref": "#/definitions/type-id" },
Stig Bakkenae3775a2014-12-02 09:21:24 +010060 "valueType": { "$ref": "#/definitions/type-desc" }
Jens Geyerffa255c2014-12-01 02:10:48 +010061 },
62 "required": [ "typeId", "keyTypeId", "valueTypeId" ]
63 },
Stig Bakkenae3775a2014-12-02 09:21:24 +010064 "struct-type": {
65 "title": "Struct, union and exception schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010066 "type": "object",
67 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010068 "typeId": {
69 "enum": [ "union", "struct", "exception" ]
70 }
Jens Geyerffa255c2014-12-01 02:10:48 +010071 },
72 "required": [ "typeId", "class" ]
73 },
Stig Bakkenae3775a2014-12-02 09:21:24 +010074 "type-desc": {
75 "title": "Type descriptor schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010076 "allOf": [
Stig Bakkenae3775a2014-12-02 09:21:24 +010077 {
78 "type": "object",
79 "properties": {
80 "typeId": { "type": "string" },
81 "class": { "type": "string" }
82 }
83 },
Jens Geyerffa255c2014-12-01 02:10:48 +010084 {
85 "oneOf":
86 [
87 { "$ref": "#/definitions/base-type" },
88 { "$ref": "#/definitions/list-type" },
89 { "$ref": "#/definitions/map-type" },
Stig Bakkenae3775a2014-12-02 09:21:24 +010090 { "$ref": "#/definitions/struct-type" }
Jens Geyerffa255c2014-12-01 02:10:48 +010091 ]
92 }
93 ]
94 },
95 "name-and-doc": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010096 "title": "Name and documentation sub-schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010097 "type": "object",
98 "properties": {
99 "name": { "type": "string" },
100 "doc": { "type": "string" }
101 },
102 "required": [ "name" ]
103 },
104 "enum": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100105 "title": "Thrift 'enum' definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100106 "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": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100128 "title": "Thrift typedef definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100129 "type": "object",
130 "allOf": [
131 { "$ref": "#/definitions/name-and-doc" },
132 {
133 "properties": {
134 "typeId": { "$ref": "#/definitions/type-id" },
Stig Bakkenae3775a2014-12-02 09:21:24 +0100135 "type": { "$ref": "#/definitions/type-desc" }
Jens Geyerffa255c2014-12-01 02:10:48 +0100136 },
137 "required": [ "typeId" ]
138 }
139 ]
140 },
141 "constant": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100142 "title": "Thrift constant definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100143 "type": "object",
144 "allOf": [
145 { "$ref": "#/definitions/name-and-doc" },
Stig Bakkenae3775a2014-12-02 09:21:24 +0100146 { "$ref": "#/definitions/type-desc" },
Jens Geyerffa255c2014-12-01 02:10:48 +0100147 {
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": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100163 "title": "Thrift struct field definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100164 "type": "object",
165 "allOf": [
166 { "$ref": "#/definitions/name-and-doc" },
Jens Geyerffa255c2014-12-01 02:10:48 +0100167 {
168 "properties": {
169 "key": {
170 "type": "integer",
171 "minimum": 1,
172 "maximum": 65535
173 },
174 "required": {
175 "enum": [ "required", "optional", "req_out" ]
176 },
Stig Bakkenae3775a2014-12-02 09:21:24 +0100177 "typeId": { "$ref": "#/definitions/type-id" },
178 "type": { "$ref": "#/definitions/type-desc" },
Jens Geyerffa255c2014-12-01 02:10:48 +0100179 "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": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100193 "title": "Thrift struct definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100194 "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": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100213 "title": "Thrift union definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100214 "$ref": "#/definitions/struct"
215 },
216 "exception": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100217 "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" ]
Jens Geyerffa255c2014-12-01 02:10:48 +0100230 },
231 "function": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100232 "title": "Thrift service function definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100233 "type": "object",
234 "allOf": [
235 { "$ref": "#/definitions/name-and-doc" },
236 {
Jens Geyerffa255c2014-12-01 02:10:48 +0100237 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100238 "oneway": {
239 "type": "boolean"
240 },
241 "returnType": {
242 "$ref": "#/definitions/type-desc"
243 },
Jens Geyerffa255c2014-12-01 02:10:48 +0100244 "arguments": {
245 "type": "array",
246 "items": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100247 "$ref": "#/definitions/field"
Jens Geyerffa255c2014-12-01 02:10:48 +0100248 }
249 },
250 "exceptions": {
251 "type": "array",
Stig Bakkenae3775a2014-12-02 09:21:24 +0100252 "items": { "$ref": "#/definitions/exception" }
Jens Geyerffa255c2014-12-01 02:10:48 +0100253 }
254 },
255 "required": [ "oneway", "arguments", "exceptions" ]
256 }
257 ]
258 },
259 "service": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100260 "title": "Thrift service definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100261 "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 },
278
279 "type": "object",
280 "required": [
281 "name",
Jens Geyerffa255c2014-12-01 02:10:48 +0100282 "enums",
283 "typedefs",
284 "structs",
285 "constants",
286 "services"
287 ],
288 "properties": {
289 "name": {
290 "type": "string"
291 },
292 "includes": {
293 "type": "array",
294 "items": {
295 "type": "string"
296 },
297 "uniqueItems": true
298 },
299 "enums": {
300 "type": "array",
301 "items": {
302 "$ref": "#/definitions/enum"
303 }
304 },
305 "typedefs": {
306 "type": "array",
307 "items": {
308 "$ref": "#/definitions/typedef"
309 }
310 },
311 "structs": {
312 "type": "array",
313 "items": {
314 "$ref": "#/definitions/struct"
315 }
316 },
317 "constants": {
318 "type": "array",
319 "items": {
320 "$ref": "#/definitions/constant"
321 }
322 },
323 "services": {
324 "type": "array",
325 "items": {
326 "$ref": "#/definitions/service"
327 }
328 }
329 }
330}