1{
2  "$schema": "http://json-schema.org/draft-07/schema#",
3  "$id": "https://something/app_schema.json",
4  "definitions": {
5    "app_id": {"type": "string", "enum": ["0F5096E8", "85CDB22F"]}
6  },
7  "type": "object",
8  "properties": {
9    "availability": {
10      "type": "object",
11      "patternProperties": {
12        "[0-9a-fA-F]": {
13          "type": "string",
14          "enum": ["APP_AVAILABLE", "APP_UNAVAILABLE"]
15        }
16      },
17      "additionalProperties": false
18    },
19    "type": {
20      "type": "string",
21      "enum": ["LAUNCH", "STOP", "GET_APP_AVAILABILITY"]
22    },
23    "responseType": {"type": "string", "enum": ["GET_APP_AVAILABILITY"]},
24    "requestId": {"type": "integer", "minimum": 0},
25    "language": {"type": "string", "minLength": 2},
26    "supportedAppTypes": {
27      "type": "array",
28      "items": {"type": "string", "enum": ["ANDROID_TV", "WEB"]}
29    }
30  },
31  "required": ["requestId"],
32  "allOf": [
33    {
34      "if": {
35        "properties": {"type": {"const": "GET_APP_AVAILABILITY"}},
36        "required": ["type"]
37      },
38      "then": {
39        "properties": {
40          "appId": {"type": "array", "items": {"$ref": "#/definitions/app_id"}}
41        },
42        "required": ["appId"]
43      },
44      "else": {"properties": {"appId": {"$ref": "#/definitions/app_id"}}}
45    },
46    {
47      "if": {
48        "properties": {"responseType": {"const": "GET_APP_AVAILABILITY"}},
49        "required": ["responseType"]
50      },
51      "then": {"required": ["availability"]}
52    },
53    {
54      "if": {"properties": {"type": {"const": "LAUNCH"}}, "required": ["type"]},
55      "then": {"required": ["supportedAppTypes", "language", "appId"]}
56    },
57    {
58      "if": {"properties": {"type": {"const": "STOP"}}, "required": ["type"]},
59      "then": {"required": ["sessionId"]}
60    }
61  ]
62}