• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[
2  {
3    "description": "issue656 - Should be valid to one and only one of schema, but more than one are valid error",
4    "schema": {
5      "$id": "someid",
6      "$schema": "https://json-schema.org/draft/2020-12/schema",
7      "description": "JSON Schema for treatments",
8      "oneOf": [
9        {
10          "$ref": "#/$defs/drug-treatment"
11        },
12        {
13          "$ref": "#/$defs/surgery-treatment"
14        }
15      ],
16      "$defs": {
17        "base": {
18          "type": "object",
19          "properties": {
20            "type-tag": {
21              "enum": [
22                "SURGERY",
23                "DRUGTREATMENT",
24                "RADIOLOGY",
25                "PHYSIOTHERAPY"
26              ]
27            },
28            "id": {
29              "type": "string",
30              "format": "uuid"
31            },
32            "patient-id": {
33              "type": "string",
34              "format": "uuid"
35            },
36            "patient-name": {
37              "type": "string"
38            },
39            "provider-id": {
40              "type": "string",
41              "format": "uuid"
42            },
43            "provider-name": {
44              "type": "string"
45            },
46            "diagnosis": {
47              "type": "string"
48            },
49            "followup-treatments": {
50              "type": "array",
51              "items": {
52                "$ref": "#"
53              }
54            }
55          },
56          "required": [
57            "id",
58            "type-tag",
59            "patient-id",
60            "patient-name",
61            "provider-id",
62            "provider-name",
63            "diagnosis",
64            "followup-treatments"
65          ]
66        },
67        "drug-treatment": {
68          "allOf": [
69            {
70              "$ref": "#/$defs/base"
71            }
72          ],
73          "properties": {
74            "drug": {
75              "type": "string"
76            },
77            "dosage": {
78              "type": "number"
79            },
80            "start-date": {
81              "type": "string",
82              "format": "date"
83            },
84            "end-date": {
85              "type": "string",
86              "format": "date"
87            },
88            "frequency": "integer"
89          },
90          "required": [
91            "drug",
92            "dosage",
93            "start-date",
94            "end-date",
95            "frequency"
96          ],
97          "unevaluatedProperties": false
98        },
99        "surgery-treatment": {
100          "allOf": [
101            {
102              "$ref": "#/$defs/base"
103            }
104          ],
105          "properties": {
106            "surgery-date": {
107              "type": "string",
108              "format": "date"
109            },
110            "discharge-instructions": {
111              "type": "string"
112            },
113            "required": [
114              "surgery-date",
115              "discharge-instructions"
116            ],
117            "unevaluatedProperties": false
118          }
119        }
120      }
121    },
122    "tests": [
123      {
124        "description": "Sample 1",
125        "data": {
126            "type-tag": "SURGERY",
127            "surgery-date": "2222-02-12",
128            "discharge-instructions": "dsfdsfdsfds",
129            "id": "12d2e565-8966-4029-840b-1959277b37f6",
130            "patient-id": "ab62420e-0bd8-4e39-8e0b-36e464b7abb2",
131            "patient-name": "Tom",
132            "provider-id": "154523b2-7598-4ed4-aab1-b2ef1692109c",
133            "provider-name": "gdsfdsd",
134            "diagnosis": "fdsfds",
135            "followup-treatments": []
136        },
137        "valid": true
138      },
139      {
140        "description": "Sample 2",
141        "data": {
142            "type-tag": "DRUGTREATMENT",
143            "drug": "fdsds",
144            "dosage": 2.0,
145            "start-date": "2222-02-12",
146            "end-date": "2222-02-12",
147            "frequency": 2,
148            "id": "aa7da984-0252-45b1-b0cd-f1dbe98662e2",
149            "patient-id": "ab62420e-0bd8-4e39-8e0b-36e464b7abb2",
150            "patient-name": "Tom",
151            "provider-id": "154523b2-7598-4ed4-aab1-b2ef1692109c",
152            "provider-name": "gdsfdsd",
153            "diagnosis": "sfdsfds",
154            "followup-treatments": []
155        },
156        "valid": false,
157        "validationMessages": [
158          "$: must be valid to one and only one schema, but 2 are valid with indexes '0, 1'"
159        ]
160      }
161    ]
162  }
163]