blob: e2b997745c9575df3a7c7c04906bd7ec593537aa [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",
Christian Westbergf223bd32022-12-22 09:39:48 +010026 "uuid",
27 "enum"
Jens Geyerffa255c2014-12-01 02:10:48 +010028 ]
29 },
30 "base-type": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010031 "title": "Base type schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010032 "type": "object",
33 "properties": {
34 "typeId": {
Jens Geyerf066d842022-06-13 23:37:25 +020035 "enum": ["void", "string", "bool", "byte", "i8", "i16", "i32", "i64", "double", "binary", "uuid" ]
Jens Geyerffa255c2014-12-01 02:10:48 +010036 }
37 },
38 "required": [ "typeId" ]
39 },
40 "list-type": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010041 "title": "List and set schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010042 "type": "object",
43 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010044 "typeId": {
45 "enum": [ "list", "set" ]
46 },
47 "elemTypeId": { "$ref": "#/definitions/type-id" },
48 "elemType": { "$ref": "#/definitions/type-desc" }
Jens Geyerffa255c2014-12-01 02:10:48 +010049 },
Stig Bakkenae3775a2014-12-02 09:21:24 +010050 "required": [ "typeId", "elemTypeId" ]
Jens Geyerffa255c2014-12-01 02:10:48 +010051 },
52 "map-type": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010053 "title": "Map schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010054 "type": "object",
55 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010056 "typeId": {
57 "enum": [ "map" ]
58 },
Jens Geyerffa255c2014-12-01 02:10:48 +010059 "keyTypeId": { "$ref": "#/definitions/type-id" },
Stig Bakkenae3775a2014-12-02 09:21:24 +010060 "keyType": { "$ref": "#/definitions/type-desc" },
Jens Geyerffa255c2014-12-01 02:10:48 +010061 "valueTypeId": { "$ref": "#/definitions/type-id" },
Stig Bakkenae3775a2014-12-02 09:21:24 +010062 "valueType": { "$ref": "#/definitions/type-desc" }
Jens Geyerffa255c2014-12-01 02:10:48 +010063 },
64 "required": [ "typeId", "keyTypeId", "valueTypeId" ]
65 },
Stig Bakkenae3775a2014-12-02 09:21:24 +010066 "struct-type": {
Thomasd0bd39c2024-02-25 23:37:35 +090067 "title": "Struct, union, enum and exception schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010068 "type": "object",
69 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010070 "typeId": {
Christian Westbergf223bd32022-12-22 09:39:48 +010071 "enum": [ "union", "struct", "exception", "enum" ]
Stig Bakkenae3775a2014-12-02 09:21:24 +010072 }
Jens Geyerffa255c2014-12-01 02:10:48 +010073 },
74 "required": [ "typeId", "class" ]
75 },
Stig Bakkenae3775a2014-12-02 09:21:24 +010076 "type-desc": {
77 "title": "Type descriptor schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010078 "allOf": [
Stig Bakkenae3775a2014-12-02 09:21:24 +010079 {
80 "type": "object",
81 "properties": {
82 "typeId": { "type": "string" },
83 "class": { "type": "string" }
84 }
85 },
Jens Geyerffa255c2014-12-01 02:10:48 +010086 {
87 "oneOf":
88 [
89 { "$ref": "#/definitions/base-type" },
90 { "$ref": "#/definitions/list-type" },
91 { "$ref": "#/definitions/map-type" },
Stig Bakkenae3775a2014-12-02 09:21:24 +010092 { "$ref": "#/definitions/struct-type" }
Jens Geyerffa255c2014-12-01 02:10:48 +010093 ]
94 }
95 ]
96 },
97 "name-and-doc": {
Stig Bakkenae3775a2014-12-02 09:21:24 +010098 "title": "Name and documentation sub-schema",
Jens Geyerffa255c2014-12-01 02:10:48 +010099 "type": "object",
100 "properties": {
101 "name": { "type": "string" },
102 "doc": { "type": "string" }
103 },
104 "required": [ "name" ]
105 },
106 "enum": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100107 "title": "Thrift 'enum' definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100108 "type": "object",
109 "allOf": [
110 { "$ref": "#/definitions/name-and-doc" },
111 {
112 "required": [ "members" ],
113 "properties": {
114 "members": {
115 "type": "array",
116 "items": {
117 "type": "object",
118 "properties": {
119 "name": { "type": "string" },
120 "value": { "type": "integer" }
121 },
122 "required": [ "name", "value" ]
123 }
124 }
125 }
126 }
127 ]
128 },
129 "typedef": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100130 "title": "Thrift typedef definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100131 "type": "object",
132 "allOf": [
133 { "$ref": "#/definitions/name-and-doc" },
134 {
135 "properties": {
136 "typeId": { "$ref": "#/definitions/type-id" },
Stig Bakkenae3775a2014-12-02 09:21:24 +0100137 "type": { "$ref": "#/definitions/type-desc" }
Jens Geyerffa255c2014-12-01 02:10:48 +0100138 },
139 "required": [ "typeId" ]
140 }
141 ]
142 },
143 "constant": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100144 "title": "Thrift constant definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100145 "type": "object",
146 "allOf": [
147 { "$ref": "#/definitions/name-and-doc" },
Jens Geyerffa255c2014-12-01 02:10:48 +0100148 {
149 "properties": {
Thomasd0bd39c2024-02-25 23:37:35 +0900150 "type": { "$ref": "#/definitions/type-desc" },
Jens Geyerffa255c2014-12-01 02:10:48 +0100151 "value": {
152 "oneOf": [
153 { "type": "string" },
154 { "type": "number" },
155 { "type": "array" },
156 { "type": "object" }
157 ]
158 }
159 },
160 "required": [ "value" ]
161 }
162 ]
163 },
164 "field": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100165 "title": "Thrift struct field definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100166 "type": "object",
167 "allOf": [
168 { "$ref": "#/definitions/name-and-doc" },
Jens Geyerffa255c2014-12-01 02:10:48 +0100169 {
170 "properties": {
171 "key": {
172 "type": "integer",
173 "minimum": 1,
174 "maximum": 65535
175 },
176 "required": {
177 "enum": [ "required", "optional", "req_out" ]
178 },
Stig Bakkenae3775a2014-12-02 09:21:24 +0100179 "typeId": { "$ref": "#/definitions/type-id" },
180 "type": { "$ref": "#/definitions/type-desc" },
Jens Geyerffa255c2014-12-01 02:10:48 +0100181 "default": {
182 "oneOf": [
183 { "type": "string" },
184 { "type": "number" },
185 { "type": "array" },
186 { "type": "object" }
187 ]
188 }
189 },
190 "required": [ "key", "required" ]
191 }
192 ]
193 },
194 "struct": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100195 "title": "Thrift struct definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100196 "type": "object",
197 "allOf": [
198 { "$ref": "#/definitions/name-and-doc" },
199 {
200 "properties": {
201 "isException": { "type": "boolean" },
202 "isUnion": { "type": "boolean" },
203 "fields": {
204 "type": "array",
205 "items": {
206 "$ref": "#/definitions/field"
207 }
208 }
209 },
210 "required": [ "isException", "isUnion", "fields" ]
211 }
212 ]
213 },
214 "union": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100215 "title": "Thrift union definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100216 "$ref": "#/definitions/struct"
217 },
218 "exception": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100219 "title": "Thrift exception definition schema",
220 "type": "object",
221 "properties": {
222 "key": {
223 "type": "integer",
224 "minimum": 1,
225 "maximum": 65535
226 },
227 "name": { "type": "string" },
228 "typeId": { "enum": [ "exception" ] },
229 "type": { "$ref": "#/definitions/struct-type" }
230 },
231 "required": [ "key", "name", "typeId" ]
Jens Geyerffa255c2014-12-01 02:10:48 +0100232 },
233 "function": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100234 "title": "Thrift service function definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100235 "type": "object",
236 "allOf": [
237 { "$ref": "#/definitions/name-and-doc" },
238 {
Jens Geyerffa255c2014-12-01 02:10:48 +0100239 "properties": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100240 "oneway": {
241 "type": "boolean"
242 },
243 "returnType": {
244 "$ref": "#/definitions/type-desc"
245 },
Jens Geyerffa255c2014-12-01 02:10:48 +0100246 "arguments": {
247 "type": "array",
248 "items": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100249 "$ref": "#/definitions/field"
Jens Geyerffa255c2014-12-01 02:10:48 +0100250 }
251 },
252 "exceptions": {
253 "type": "array",
Stig Bakkenae3775a2014-12-02 09:21:24 +0100254 "items": { "$ref": "#/definitions/exception" }
Jens Geyerffa255c2014-12-01 02:10:48 +0100255 }
256 },
257 "required": [ "oneway", "arguments", "exceptions" ]
258 }
259 ]
260 },
261 "service": {
Stig Bakkenae3775a2014-12-02 09:21:24 +0100262 "title": "Thrift service definition schema",
Jens Geyerffa255c2014-12-01 02:10:48 +0100263 "type": "object",
264 "allOf": [
265 { "$ref": "#/definitions/name-and-doc" },
266 {
267 "properties": {
268 "functions": {
269 "type": "array",
270 "items": {
271 "$ref": "#/definitions/function"
272 }
273 }
274 },
275 "required": [ "functions" ]
276 }
277 ]
Stig Bakkenc0e35352017-06-27 10:51:37 +0200278 },
279 "annotations": {
280 "title": "Map of annotation names to values",
281 "type": "object",
282 "additionalProperties": {
283 "type": "string"
284 }
Jens Geyerffa255c2014-12-01 02:10:48 +0100285 }
286 },
287
288 "type": "object",
289 "required": [
290 "name",
Jens Geyerffa255c2014-12-01 02:10:48 +0100291 "enums",
292 "typedefs",
293 "structs",
294 "constants",
295 "services"
296 ],
297 "properties": {
298 "name": {
299 "type": "string"
300 },
301 "includes": {
302 "type": "array",
303 "items": {
304 "type": "string"
305 },
306 "uniqueItems": true
307 },
Stig Bakkenc0e35352017-06-27 10:51:37 +0200308 "namespaces": {
309 "type": "object",
310 "additionalProperties": {
311 "type": "string"
312 }
313 },
Jens Geyerffa255c2014-12-01 02:10:48 +0100314 "enums": {
315 "type": "array",
316 "items": {
317 "$ref": "#/definitions/enum"
318 }
319 },
320 "typedefs": {
321 "type": "array",
322 "items": {
323 "$ref": "#/definitions/typedef"
324 }
325 },
326 "structs": {
327 "type": "array",
328 "items": {
329 "$ref": "#/definitions/struct"
330 }
331 },
332 "constants": {
333 "type": "array",
334 "items": {
335 "$ref": "#/definitions/constant"
336 }
337 },
338 "services": {
339 "type": "array",
340 "items": {
341 "$ref": "#/definitions/service"
342 }
343 }
Stig Bakkenc0e35352017-06-27 10:51:37 +0200344 },
345 "additionalProperties": false
Jens Geyerffa255c2014-12-01 02:10:48 +0100346}