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 | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 25 | "binary" |
| 26 | ] |
| 27 | }, |
| 28 | "base-type": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 29 | "title": "Base type schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 30 | "type": "object", |
| 31 | "properties": { |
| 32 | "typeId": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 33 | "enum": ["void", "string", "bool", "byte", "i8", "i16", "i32", "i64", "double", "binary" ] |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 34 | } |
| 35 | }, |
| 36 | "required": [ "typeId" ] |
| 37 | }, |
| 38 | "list-type": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 39 | "title": "List and set schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 40 | "type": "object", |
| 41 | "properties": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 42 | "typeId": { |
| 43 | "enum": [ "list", "set" ] |
| 44 | }, |
| 45 | "elemTypeId": { "$ref": "#/definitions/type-id" }, |
| 46 | "elemType": { "$ref": "#/definitions/type-desc" } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 47 | }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 48 | "required": [ "typeId", "elemTypeId" ] |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 49 | }, |
| 50 | "map-type": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 51 | "title": "Map schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 52 | "type": "object", |
| 53 | "properties": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 54 | "typeId": { |
| 55 | "enum": [ "map" ] |
| 56 | }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 57 | "keyTypeId": { "$ref": "#/definitions/type-id" }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 58 | "keyType": { "$ref": "#/definitions/type-desc" }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 59 | "valueTypeId": { "$ref": "#/definitions/type-id" }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 60 | "valueType": { "$ref": "#/definitions/type-desc" } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 61 | }, |
| 62 | "required": [ "typeId", "keyTypeId", "valueTypeId" ] |
| 63 | }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 64 | "struct-type": { |
| 65 | "title": "Struct, union and exception schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 66 | "type": "object", |
| 67 | "properties": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 68 | "typeId": { |
| 69 | "enum": [ "union", "struct", "exception" ] |
| 70 | } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 71 | }, |
| 72 | "required": [ "typeId", "class" ] |
| 73 | }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 74 | "type-desc": { |
| 75 | "title": "Type descriptor schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 76 | "allOf": [ |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 77 | { |
| 78 | "type": "object", |
| 79 | "properties": { |
| 80 | "typeId": { "type": "string" }, |
| 81 | "class": { "type": "string" } |
| 82 | } |
| 83 | }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 84 | { |
| 85 | "oneOf": |
| 86 | [ |
| 87 | { "$ref": "#/definitions/base-type" }, |
| 88 | { "$ref": "#/definitions/list-type" }, |
| 89 | { "$ref": "#/definitions/map-type" }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 90 | { "$ref": "#/definitions/struct-type" } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 91 | ] |
| 92 | } |
| 93 | ] |
| 94 | }, |
| 95 | "name-and-doc": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 96 | "title": "Name and documentation sub-schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 97 | "type": "object", |
| 98 | "properties": { |
| 99 | "name": { "type": "string" }, |
| 100 | "doc": { "type": "string" } |
| 101 | }, |
| 102 | "required": [ "name" ] |
| 103 | }, |
| 104 | "enum": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 105 | "title": "Thrift 'enum' definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 106 | "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 Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 128 | "title": "Thrift typedef definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 129 | "type": "object", |
| 130 | "allOf": [ |
| 131 | { "$ref": "#/definitions/name-and-doc" }, |
| 132 | { |
| 133 | "properties": { |
| 134 | "typeId": { "$ref": "#/definitions/type-id" }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 135 | "type": { "$ref": "#/definitions/type-desc" } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 136 | }, |
| 137 | "required": [ "typeId" ] |
| 138 | } |
| 139 | ] |
| 140 | }, |
| 141 | "constant": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 142 | "title": "Thrift constant definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 143 | "type": "object", |
| 144 | "allOf": [ |
| 145 | { "$ref": "#/definitions/name-and-doc" }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 146 | { "$ref": "#/definitions/type-desc" }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 147 | { |
| 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 Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 163 | "title": "Thrift struct field definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 164 | "type": "object", |
| 165 | "allOf": [ |
| 166 | { "$ref": "#/definitions/name-and-doc" }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 167 | { |
| 168 | "properties": { |
| 169 | "key": { |
| 170 | "type": "integer", |
| 171 | "minimum": 1, |
| 172 | "maximum": 65535 |
| 173 | }, |
| 174 | "required": { |
| 175 | "enum": [ "required", "optional", "req_out" ] |
| 176 | }, |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 177 | "typeId": { "$ref": "#/definitions/type-id" }, |
| 178 | "type": { "$ref": "#/definitions/type-desc" }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 179 | "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 Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 193 | "title": "Thrift struct definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 194 | "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 Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 213 | "title": "Thrift union definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 214 | "$ref": "#/definitions/struct" |
| 215 | }, |
| 216 | "exception": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 217 | "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 Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 230 | }, |
| 231 | "function": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 232 | "title": "Thrift service function definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 233 | "type": "object", |
| 234 | "allOf": [ |
| 235 | { "$ref": "#/definitions/name-and-doc" }, |
| 236 | { |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 237 | "properties": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 238 | "oneway": { |
| 239 | "type": "boolean" |
| 240 | }, |
| 241 | "returnType": { |
| 242 | "$ref": "#/definitions/type-desc" |
| 243 | }, |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 244 | "arguments": { |
| 245 | "type": "array", |
| 246 | "items": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 247 | "$ref": "#/definitions/field" |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 248 | } |
| 249 | }, |
| 250 | "exceptions": { |
| 251 | "type": "array", |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 252 | "items": { "$ref": "#/definitions/exception" } |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 253 | } |
| 254 | }, |
| 255 | "required": [ "oneway", "arguments", "exceptions" ] |
| 256 | } |
| 257 | ] |
| 258 | }, |
| 259 | "service": { |
Stig Bakken | ae3775a | 2014-12-02 09:21:24 +0100 | [diff] [blame] | 260 | "title": "Thrift service definition schema", |
Jens Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 261 | "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 Geyer | ffa255c | 2014-12-01 02:10:48 +0100 | [diff] [blame] | 282 | "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 | } |