Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 1 | { |
| 2 | "$schema": "http://json-schema.org/draft-04/schema#", |
| 3 | |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 4 | "id": "http://thrift.apache.org/schema.json#", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 5 | "description": "Schema for Apache Thrift protocol descriptors", |
| 6 | |
| 7 | "definitions": { |
| 8 | "type-id": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 9 | "title": "Any type id (name)", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 10 | "enum": [ |
| 11 | "void", |
| 12 | "string", |
| 13 | "bool", |
| 14 | "byte", |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 15 | "i8", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 16 | "i16", |
| 17 | "i32", |
| 18 | "i64", |
| 19 | "double", |
| 20 | "list", |
| 21 | "set", |
| 22 | "map", |
| 23 | "union", |
| 24 | "struct", |
Jens Geyer | f066d84 | 2022-06-13 23:37:25 +0200 | [diff] [blame] | 25 | "binary", |
| 26 | "uuid" |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 27 | ] |
| 28 | }, |
| 29 | "base-type": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 30 | "title": "Base type schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 31 | "type": "object", |
| 32 | "properties": { |
| 33 | "typeId": { |
Jens Geyer | f066d84 | 2022-06-13 23:37:25 +0200 | [diff] [blame] | 34 | "enum": ["void", "string", "bool", "byte", "i8", "i16", "i32", "i64", "double", "binary", "uuid" ] |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 35 | } |
| 36 | }, |
| 37 | "required": [ "typeId" ] |
| 38 | }, |
| 39 | "list-type": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 40 | "title": "List and set schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 41 | "type": "object", |
| 42 | "properties": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 43 | "typeId": { |
| 44 | "enum": [ "list", "set" ] |
| 45 | }, |
| 46 | "elemTypeId": { "$ref": "#/definitions/type-id" }, |
| 47 | "elemType": { "$ref": "#/definitions/type-desc" } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 48 | }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 49 | "required": [ "typeId", "elemTypeId" ] |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 50 | }, |
| 51 | "map-type": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 52 | "title": "Map schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 53 | "type": "object", |
| 54 | "properties": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 55 | "typeId": { |
| 56 | "enum": [ "map" ] |
| 57 | }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 58 | "keyTypeId": { "$ref": "#/definitions/type-id" }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 59 | "keyType": { "$ref": "#/definitions/type-desc" }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 60 | "valueTypeId": { "$ref": "#/definitions/type-id" }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 61 | "valueType": { "$ref": "#/definitions/type-desc" } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 62 | }, |
| 63 | "required": [ "typeId", "keyTypeId", "valueTypeId" ] |
| 64 | }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 65 | "struct-type": { |
| 66 | "title": "Struct, union and exception schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 67 | "type": "object", |
| 68 | "properties": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 69 | "typeId": { |
| 70 | "enum": [ "union", "struct", "exception" ] |
| 71 | } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 72 | }, |
| 73 | "required": [ "typeId", "class" ] |
| 74 | }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 75 | "type-desc": { |
| 76 | "title": "Type descriptor schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 77 | "allOf": [ |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 78 | { |
| 79 | "type": "object", |
| 80 | "properties": { |
| 81 | "typeId": { "type": "string" }, |
| 82 | "class": { "type": "string" } |
| 83 | } |
| 84 | }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 85 | { |
| 86 | "oneOf": |
| 87 | [ |
| 88 | { "$ref": "#/definitions/base-type" }, |
| 89 | { "$ref": "#/definitions/list-type" }, |
| 90 | { "$ref": "#/definitions/map-type" }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 91 | { "$ref": "#/definitions/struct-type" } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 92 | ] |
| 93 | } |
| 94 | ] |
| 95 | }, |
| 96 | "name-and-doc": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 97 | "title": "Name and documentation sub-schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 98 | "type": "object", |
| 99 | "properties": { |
| 100 | "name": { "type": "string" }, |
| 101 | "doc": { "type": "string" } |
| 102 | }, |
| 103 | "required": [ "name" ] |
| 104 | }, |
| 105 | "enum": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 106 | "title": "Thrift 'enum' definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 107 | "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 Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 129 | "title": "Thrift typedef definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 130 | "type": "object", |
| 131 | "allOf": [ |
| 132 | { "$ref": "#/definitions/name-and-doc" }, |
| 133 | { |
| 134 | "properties": { |
| 135 | "typeId": { "$ref": "#/definitions/type-id" }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 136 | "type": { "$ref": "#/definitions/type-desc" } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 137 | }, |
| 138 | "required": [ "typeId" ] |
| 139 | } |
| 140 | ] |
| 141 | }, |
| 142 | "constant": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 143 | "title": "Thrift constant definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 144 | "type": "object", |
| 145 | "allOf": [ |
| 146 | { "$ref": "#/definitions/name-and-doc" }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 147 | { "$ref": "#/definitions/type-desc" }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 148 | { |
| 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 Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 164 | "title": "Thrift struct field definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 165 | "type": "object", |
| 166 | "allOf": [ |
| 167 | { "$ref": "#/definitions/name-and-doc" }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 168 | { |
| 169 | "properties": { |
| 170 | "key": { |
| 171 | "type": "integer", |
| 172 | "minimum": 1, |
| 173 | "maximum": 65535 |
| 174 | }, |
| 175 | "required": { |
| 176 | "enum": [ "required", "optional", "req_out" ] |
| 177 | }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 178 | "typeId": { "$ref": "#/definitions/type-id" }, |
| 179 | "type": { "$ref": "#/definitions/type-desc" }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 180 | "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 Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 194 | "title": "Thrift struct definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 195 | "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 Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 214 | "title": "Thrift union definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 215 | "$ref": "#/definitions/struct" |
| 216 | }, |
| 217 | "exception": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 218 | "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 Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 231 | }, |
| 232 | "function": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 233 | "title": "Thrift service function definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 234 | "type": "object", |
| 235 | "allOf": [ |
| 236 | { "$ref": "#/definitions/name-and-doc" }, |
| 237 | { |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 238 | "properties": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 239 | "oneway": { |
| 240 | "type": "boolean" |
| 241 | }, |
| 242 | "returnType": { |
| 243 | "$ref": "#/definitions/type-desc" |
| 244 | }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 245 | "arguments": { |
| 246 | "type": "array", |
| 247 | "items": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 248 | "$ref": "#/definitions/field" |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 249 | } |
| 250 | }, |
| 251 | "exceptions": { |
| 252 | "type": "array", |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 253 | "items": { "$ref": "#/definitions/exception" } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 254 | } |
| 255 | }, |
| 256 | "required": [ "oneway", "arguments", "exceptions" ] |
| 257 | } |
| 258 | ] |
| 259 | }, |
| 260 | "service": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 261 | "title": "Thrift service definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 262 | "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 Bakken | c0e3535 | 2017-06-27 10:51:37 +0200 | [diff] [blame] | 277 | }, |
| 278 | "annotations": { |
| 279 | "title": "Map of annotation names to values", |
| 280 | "type": "object", |
| 281 | "additionalProperties": { |
| 282 | "type": "string" |
| 283 | } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 284 | } |
| 285 | }, |
| 286 | |
| 287 | "type": "object", |
| 288 | "required": [ |
| 289 | "name", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 290 | "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 Bakken | c0e3535 | 2017-06-27 10:51:37 +0200 | [diff] [blame] | 307 | "namespaces": { |
| 308 | "type": "object", |
| 309 | "additionalProperties": { |
| 310 | "type": "string" |
| 311 | } |
| 312 | }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 313 | "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 Bakken | c0e3535 | 2017-06-27 10:51:37 +0200 | [diff] [blame] | 343 | }, |
| 344 | "additionalProperties": false |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 345 | } |