Skip to content

Commit e0c587a

Browse files
committed
meta-schemas: Rework schemas to avoid oneOf
'oneOf' results in ambiguous warning messages as it's not clear which entry is the real error. Rework the meta-schemas to use if/then/else instead which tends to result in more precise warning messages. Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent c6ab0b0 commit e0c587a

File tree

4 files changed

+41
-29
lines changed

4 files changed

+41
-29
lines changed

dtschema/meta-schemas/cell.yaml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,22 @@ array:
3737
description: '"items" can be a list defining each entry or a schema
3838
applying to all items. A list has an implicit size. A schema
3939
requires minItems/maxItems to define the size.'
40-
oneOf:
41-
- type: object
42-
allOf:
43-
- $ref: '#/array'
44-
- type: array
40+
if:
41+
type: object
42+
then:
43+
$ref: '#/array'
44+
else:
45+
type: array
46+
if:
4547
items:
46-
$ref: '#/single'
47-
- type: array
48+
required: [ items ]
49+
then:
4850
maxItems: 1 # for more than 1, outer 'items' should be a schema
4951
items:
50-
allOf:
51-
- $ref: '#/array'
52-
required:
53-
- items
52+
$ref: '#/array'
53+
else:
54+
items:
55+
$ref: '#/single'
5456
additionalItems:
5557
type: boolean
5658
const: true

dtschema/meta-schemas/clocks.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ $schema: https://json-schema.org/draft/2019-09/schema
88

99
properties:
1010
clocks:
11-
oneOf:
12-
- $ref: cell.yaml#/array
13-
- $ref: nodes.yaml
11+
if:
12+
type: object
13+
required: [type]
14+
then:
15+
$ref: nodes.yaml
16+
else:
17+
$ref: cell.yaml#/array
1418
clock-ranges:
1519
$ref: boolean.yaml
1620
clock-indices:

dtschema/meta-schemas/interrupts.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ properties:
1818
interrupt-map-mask:
1919
$ref: cell.yaml#/array
2020
interrupt-controller:
21-
oneOf:
22-
- $ref: boolean.yaml
23-
- $ref: nodes.yaml
21+
if:
22+
type: object
23+
required: [type]
24+
then:
25+
$ref: nodes.yaml
26+
else:
27+
$ref: boolean.yaml
2428

2529
dependentRequired:
2630
interrupt-map: ['#interrupt-cells']

dtschema/meta-schemas/keywords.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,14 @@ properties:
171171
if:
172172
$ref: "#/definitions/sub-schemas"
173173
items:
174-
oneOf:
175-
- type: object
176-
allOf:
177-
- $ref: "#/definitions/sub-schemas"
178-
- type: array
179-
items:
180-
$ref: "#/definitions/sub-schemas"
174+
if:
175+
type: object
176+
then:
177+
$ref: "#/definitions/sub-schemas"
178+
else:
179+
type: array
180+
items:
181+
$ref: "#/definitions/sub-schemas"
181182
maxItems:
182183
minimum: 1
183184
minItems:
@@ -230,11 +231,12 @@ properties:
230231
then:
231232
$ref: "#/definitions/sub-schemas"
232233
unevaluatedProperties:
233-
oneOf:
234-
- type: object
235-
allOf:
236-
- $ref: "#/definitions/sub-schemas"
237-
- type: boolean
234+
if:
235+
type: object
236+
then:
237+
$ref: "#/definitions/sub-schemas"
238+
else:
239+
type: boolean
238240
uniqueItems:
239241
type: boolean
240242

0 commit comments

Comments
 (0)