Skip to content

Commit d4edb08

Browse files
committed
schemas: Improve graph schema to allow extending
The initial graph schema is not flexible enough to handle cases with additional properties in endpoint nodes. The problem is a $ref plus 'unevaluatedProperties: false' only works on immediate properties and doesn't work for child properties in an endpoint schema. So endpoint nodes must have their own $ref. Rework the to add base definitions 'port-base' and 'endpoint-base' which can be used by graph users to extend the schema. For users without additional properties, they can reference '/properties/port' and 'properties/endpoint'. Signed-off-by: Rob Herring <[email protected]>
1 parent b92867d commit d4edb08

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

schemas/graph.yaml

+39-18
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,19 @@ maintainers:
3333

3434
select: false
3535

36-
properties:
37-
port:
36+
$defs:
37+
endpoint-base:
38+
type: object
39+
properties:
40+
reg:
41+
maxItems: 1
42+
43+
remote-endpoint:
44+
description: |
45+
phandle to an 'endpoint' subnode of a remote device node.
46+
$ref: /schemas/types.yaml#/definitions/phandle
47+
48+
port-base:
3849
type: object
3950
description:
4051
If there is more than one endpoint node or 'reg' property present in
@@ -48,17 +59,30 @@ properties:
4859
"#size-cells":
4960
const: 0
5061

51-
patternProperties:
52-
"^endpoint(@[0-9a-f]+)?$":
62+
reg:
63+
maxItems: 1
64+
65+
endpoint:
5366
type: object
54-
properties:
55-
reg:
56-
maxItems: 1
5767

58-
remote-endpoint:
59-
description: |
60-
phandle to an 'endpoint' subnode of a remote device node.
61-
$ref: /schemas/types.yaml#/definitions/phandle
68+
patternProperties:
69+
"^endpoint@[0-9a-f]+$":
70+
$ref: "#/$defs/endpoint-base"
71+
required:
72+
- reg
73+
74+
properties:
75+
endpoint:
76+
$ref: "#/$defs/endpoint-base"
77+
unevaluatedProperties: false
78+
79+
port:
80+
$ref: "#/$defs/port-base"
81+
unevaluatedProperties: false
82+
83+
patternProperties:
84+
"^endpoint(@[0-9a-f]+)?$":
85+
$ref: "#/properties/endpoint"
6286

6387
ports:
6488
type: object
@@ -75,15 +99,12 @@ properties:
7599
"#size-cells":
76100
const: 0
77101

78-
patternProperties:
79-
"^port(@[0-9a-f]+)?$":
80-
$ref: "#/properties/port"
102+
port:
81103
type: object
82104

83-
properties:
84-
reg:
85-
maxItems: 1
86-
105+
patternProperties:
106+
"^port@[0-9a-f]+$":
107+
type: object
87108
required:
88109
- reg
89110

0 commit comments

Comments
 (0)