Skip to content

Commit

Permalink
schemas: Improve graph schema to allow extending
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
robherring committed Dec 2, 2020
1 parent b92867d commit d4edb08
Showing 1 changed file with 39 additions and 18 deletions.
57 changes: 39 additions & 18 deletions schemas/graph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,19 @@ maintainers:

select: false

properties:
port:
$defs:
endpoint-base:
type: object
properties:
reg:
maxItems: 1

remote-endpoint:
description: |
phandle to an 'endpoint' subnode of a remote device node.
$ref: /schemas/types.yaml#/definitions/phandle

port-base:
type: object
description:
If there is more than one endpoint node or 'reg' property present in
Expand All @@ -48,17 +59,30 @@ properties:
"#size-cells":
const: 0

patternProperties:
"^endpoint(@[0-9a-f]+)?$":
reg:
maxItems: 1

endpoint:
type: object
properties:
reg:
maxItems: 1

remote-endpoint:
description: |
phandle to an 'endpoint' subnode of a remote device node.
$ref: /schemas/types.yaml#/definitions/phandle
patternProperties:
"^endpoint@[0-9a-f]+$":
$ref: "#/$defs/endpoint-base"
required:
- reg

properties:
endpoint:
$ref: "#/$defs/endpoint-base"
unevaluatedProperties: false

port:
$ref: "#/$defs/port-base"
unevaluatedProperties: false

patternProperties:
"^endpoint(@[0-9a-f]+)?$":
$ref: "#/properties/endpoint"

ports:
type: object
Expand All @@ -75,15 +99,12 @@ properties:
"#size-cells":
const: 0

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

properties:
reg:
maxItems: 1

patternProperties:
"^port@[0-9a-f]+$":
type: object
required:
- reg

Expand Down

0 comments on commit d4edb08

Please sign in to comment.