blob: 90bb7a59d6a16100fb15b8fda2c83e4f3a72e3bc [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 Geyerf066d842022-06-13 23:37:25 +020025 "binary",
26 "uuid"
Jens Geyerffa255c2014-12-01 02:10:48 +010027 ]
28 },
29 "base-type": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010030 "title": "Base type schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010031 "type": "object",
32 "properties": {
33 "typeId": {
Jens Geyerf066d842022-06-13 23:37:25 +020034 "enum": ["void", "string", "bool", "byte", "i8", "i16", "i32", "i64", "double", "binary", "uuid" ]
Jens Geyerffa255c2014-12-01 02:10:48 +010035 }
36 },
37 "required": [ "typeId" ]
38 },
39 "list-type": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010040 "title": "List and set schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010041 "type": "object",
42 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010043 "typeId": {
44 "enum": [ "list", "set" ]
45 },
46 "elemTypeId": { "$ref": "#/definitions/type-id" },
47 "elemType": { "$ref": "#/definitions/type-desc" }
Jens Geyerffa255c2014-12-01 02:10:48 +010048 },
Stig Bakkenae3775a2014-12-02 09:21:24 +010049 "required": [ "typeId", "elemTypeId" ]
Jens Geyerffa255c2014-12-01 02:10:48 +010050 },
51 "map-type": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010052 "title": "Map schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010053 "type": "object",
54 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010055 "typeId": {
56 "enum": [ "map" ]
57 },
Jens Geyerffa255c2014-12-01 02:10:48 +010058 "keyTypeId": { "$ref": "#/definitions/type-id" },
Stig Bakkenae3775a2014-12-02 09:21:24 +010059 "keyType": { "$ref": "#/definitions/type-desc" },
Jens Geyerffa255c2014-12-01 02:10:48 +010060 "valueTypeId": { "$ref": "#/definitions/type-id" },
Stig Bakkenae3775a2014-12-02 09:21:24 +010061 "valueType": { "$ref": "#/definitions/type-desc" }
Jens Geyerffa255c2014-12-01 02:10:48 +010062 },
63 "required": [ "typeId", "keyTypeId", "valueTypeId" ]
64 },
Stig Bakkenae3775a2014-12-02 09:21:24 +010065 "struct-type": {
66 "title": "Struct, union and exception schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010067 "type": "object",
68 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010069 "typeId": {
70 "enum": [ "union", "struct", "exception" ]
71 }
Jens Geyerffa255c2014-12-01 02:10:48 +010072 },
73 "required": [ "typeId", "class" ]
74 },
Stig Bakkenae3775a2014-12-02 09:21:24 +010075 "type-desc": {
76 "title": "Type descriptor schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010077 "allOf": [
Stig Bakkenae3775a2014-12-02 09:21:24 +010078 {
79 "type": "object",
80 "properties": {
81 "typeId": { "type": "string" },
82 "class": { "type": "string" }
83 }
84 },
Jens Geyerffa255c2014-12-01 02:10:48 +010085 {
86 "oneOf":
87 [
88 { "$ref": "#/definitions/base-type" },
89 { "$ref": "#/definitions/list-type" },
90 { "$ref": "#/definitions/map-type" },
Stig Bakkenae3775a2014-12-02 09:21:24 +010091 { "$ref": "#/definitions/struct-type" }
Jens Geyerffa255c2014-12-01 02:10:48 +010092 ]
93 }
94 ]
95 },
96 "name-and-doc": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010097 "title": "Name and documentation sub-schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010098 "type": "object",
99 "properties": {
100 "name": { "type": "string" },
101 "doc": { "type": "string" }
102 },
103 "required": [ "name" ]
104 },
105 "enum": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100106 "title": "Thrift 'enum' definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100107 "type": "object",
108 "allOf": [
109 { "$ref": "#/definitions/name-and-doc" },
110 {
111 "required": [ "members" ],
112 "properties": {
113 "members": {
114 "type": "array",
115 "items": {
116 "type": "object",
117 "properties": {
118 "name": { "type": "string" },
119 "value": { "type": "integer" }
120 },
121 "required": [ "name", "value" ]
122 }
123 }
124 }
125 }
126 ]
127 },
128 "typedef": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100129 "title": "Thrift typedef definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100130 "type": "object",
131 "allOf": [
132 { "$ref": "#/definitions/name-and-doc" },
133 {
134 "properties": {
135 "typeId": { "$ref": "#/definitions/type-id" },
Stig Bakkenae3775a2014-12-02 09:21:24 +0100136 "type": { "$ref": "#/definitions/type-desc" }
Jens Geyerffa255c2014-12-01 02:10:48 +0100137 },
138 "required": [ "typeId" ]
139 }
140 ]
141 },
142 "constant": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100143 "title": "Thrift constant definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100144 "type": "object",
145 "allOf": [
146 { "$ref": "#/definitions/name-and-doc" },
Stig Bakkenae3775a2014-12-02 09:21:24 +0100147 { "$ref": "#/definitions/type-desc" },
Jens Geyerffa255c2014-12-01 02:10:48 +0100148 {
149 "properties": {
150 "value": {
151 "oneOf": [
152 { "type": "string" },
153 { "type": "number" },
154 { "type": "array" },
155 { "type": "object" }
156 ]
157 }
158 },
159 "required": [ "value" ]
160 }
161 ]
162 },
163 "field": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100164 "title": "Thrift struct field definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100165 "type": "object",
166 "allOf": [
167 { "$ref": "#/definitions/name-and-doc" },
Jens Geyerffa255c2014-12-01 02:10:48 +0100168 {
169 "properties": {
170 "key": {
171 "type": "integer",
172 "minimum": 1,
173 "maximum": 65535
174 },
175 "required": {
176 "enum": [ "required", "optional", "req_out" ]
177 },
Stig Bakkenae3775a2014-12-02 09:21:24 +0100178 "typeId": { "$ref": "#/definitions/type-id" },
179 "type": { "$ref": "#/definitions/type-desc" },
Jens Geyerffa255c2014-12-01 02:10:48 +0100180 "default": {
181 "oneOf": [
182 { "type": "string" },
183 { "type": "number" },
184 { "type": "array" },
185 { "type": "object" }
186 ]
187 }
188 },
189 "required": [ "key", "required" ]
190 }
191 ]
192 },
193 "struct": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100194 "title": "Thrift struct definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100195 "type": "object",
196 "allOf": [
197 { "$ref": "#/definitions/name-and-doc" },
198 {
199 "properties": {
200 "isException": { "type": "boolean" },
201 "isUnion": { "type": "boolean" },
202 "fields": {
203 "type": "array",
204 "items": {
205 "$ref": "#/definitions/field"
206 }
207 }
208 },
209 "required": [ "isException", "isUnion", "fields" ]
210 }
211 ]
212 },
213 "union": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100214 "title": "Thrift union definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100215 "$ref": "#/definitions/struct"
216 },
217 "exception": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100218 "title": "Thrift exception definition schema",
219 "type": "object",
220 "properties": {
221 "key": {
222 "type": "integer",
223 "minimum": 1,
224 "maximum": 65535
225 },
226 "name": { "type": "string" },
227 "typeId": { "enum": [ "exception" ] },
228 "type": { "$ref": "#/definitions/struct-type" }
229 },
230 "required": [ "key", "name", "typeId" ]
Jens Geyerffa255c2014-12-01 02:10:48 +0100231 },
232 "function": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100233 "title": "Thrift service function definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100234 "type": "object",
235 "allOf": [
236 { "$ref": "#/definitions/name-and-doc" },
237 {
Jens Geyerffa255c2014-12-01 02:10:48 +0100238 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100239 "oneway": {
240 "type": "boolean"
241 },
242 "returnType": {
243 "$ref": "#/definitions/type-desc"
244 },
Jens Geyerffa255c2014-12-01 02:10:48 +0100245 "arguments": {
246 "type": "array",
247 "items": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100248 "$ref": "#/definitions/field"
Jens Geyerffa255c2014-12-01 02:10:48 +0100249 }
250 },
251 "exceptions": {
252 "type": "array",
Stig Bakkenae3775a2014-12-02 09:21:24 +0100253 "items": { "$ref": "#/definitions/exception" }
Jens Geyerffa255c2014-12-01 02:10:48 +0100254 }
255 },
256 "required": [ "oneway", "arguments", "exceptions" ]
257 }
258 ]
259 },
260 "service": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100261 "title": "Thrift service definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100262 "type": "object",
263 "allOf": [
264 { "$ref": "#/definitions/name-and-doc" },
265 {
266 "properties": {
267 "functions": {
268 "type": "array",
269 "items": {
270 "$ref": "#/definitions/function"
271 }
272 }
273 },
274 "required": [ "functions" ]
275 }
276 ]
Stig Bakkenc0e35352017-06-27 10:51:37 +0200277 },
278 "annotations": {
279 "title": "Map of annotation names to values",
280 "type": "object",
281 "additionalProperties": {
282 "type": "string"
283 }
Jens Geyerffa255c2014-12-01 02:10:48 +0100284 }
285 },
286
287 "type": "object",
288 "required": [
289 "name",
Jens Geyerffa255c2014-12-01 02:10:48 +0100290 "enums",
291 "typedefs",
292 "structs",
293 "constants",
294 "services"
295 ],
296 "properties": {
297 "name": {
298 "type": "string"
299 },
300 "includes": {
301 "type": "array",
302 "items": {
303 "type": "string"
304 },
305 "uniqueItems": true
306 },
Stig Bakkenc0e35352017-06-27 10:51:37 +0200307 "namespaces": {
308 "type": "object",
309 "additionalProperties": {
310 "type": "string"
311 }
312 },
Jens Geyerffa255c2014-12-01 02:10:48 +0100313 "enums": {
314 "type": "array",
315 "items": {
316 "$ref": "#/definitions/enum"
317 }
318 },
319 "typedefs": {
320 "type": "array",
321 "items": {
322 "$ref": "#/definitions/typedef"
323 }
324 },
325 "structs": {
326 "type": "array",
327 "items": {
328 "$ref": "#/definitions/struct"
329 }
330 },
331 "constants": {
332 "type": "array",
333 "items": {
334 "$ref": "#/definitions/constant"
335 }
336 },
337 "services": {
338 "type": "array",
339 "items": {
340 "$ref": "#/definitions/service"
341 }
342 }
Stig Bakkenc0e35352017-06-27 10:51:37 +0200343 },
344 "additionalProperties": false
Jens Geyerffa255c2014-12-01 02:10:48 +0100345}