| 1 |
# SPDX-License-Identifier: BSD-2-Clause |
| 2 |
# Copyright 2019 Arm Ltd. |
| 3 |
%YAML 1.2 |
| 4 |
--- |
| 5 |
$id: http://devicetree.org/meta-schemas/keywords.yaml# |
| 6 |
$schema: https://json-schema.org/draft/2019-09/schema |
| 7 |
|
| 8 |
description: |
| 9 |
Keywords must be a subset of known json-schema keywords |
| 10 |
|
| 11 |
definitions: |
| 12 |
json-schema-prop-names: |
| 13 |
enum: |
| 14 |
- $ref |
| 15 |
- additionalItems |
| 16 |
- additionalProperties |
| 17 |
- allOf |
| 18 |
- anyOf |
| 19 |
- const |
| 20 |
- contains |
| 21 |
- default |
| 22 |
- dependencies |
| 23 |
- dependentRequired |
| 24 |
- dependentSchemas |
| 25 |
- deprecated |
| 26 |
- description |
| 27 |
- else |
| 28 |
- enum |
| 29 |
- exclusiveMaximum |
| 30 |
- exclusiveMinimum |
| 31 |
- items |
| 32 |
- if |
| 33 |
- minItems |
| 34 |
- minimum |
| 35 |
- maxItems |
| 36 |
- maximum |
| 37 |
- multipleOf |
| 38 |
- not |
| 39 |
- oneOf |
| 40 |
- pattern |
| 41 |
- patternProperties |
| 42 |
- properties |
| 43 |
- required |
| 44 |
- then |
| 45 |
- typeSize |
| 46 |
- unevaluatedProperties |
| 47 |
- uniqueItems |
| 48 |
|
| 49 |
overlapping-json-schema-prop-names: |
| 50 |
# 'type' is also a DT property name |
| 51 |
const: type |
| 52 |
|
| 53 |
sub-schemas: |
| 54 |
allOf: |
| 55 |
- $ref: "#" |
| 56 |
- $ref: items.yaml# |
| 57 |
- $ref: types.yaml# |
| 58 |
propertyNames: |
| 59 |
# The subset of keywords allowed for sub-schema |
| 60 |
anyOf: |
| 61 |
- $ref: "#/definitions/json-schema-prop-names" |
| 62 |
- $ref: "#/definitions/overlapping-json-schema-prop-names" |
| 63 |
|
| 64 |
scalar-prop-list: |
| 65 |
propertyNames: |
| 66 |
description: |
| 67 |
Scalar and array keywords cannot be mixed |
| 68 |
not: |
| 69 |
enum: |
| 70 |
- const |
| 71 |
- enum |
| 72 |
- exclusiveMaximum |
| 73 |
- exclusiveMinimum |
| 74 |
- minimum |
| 75 |
- maximum |
| 76 |
- multipleOf |
| 77 |
- pattern |
| 78 |
|
| 79 |
# Array keywords should not be mixed with scalar keywords |
| 80 |
dependentSchemas: |
| 81 |
contains: |
| 82 |
$ref: "#/definitions/scalar-prop-list" |
| 83 |
items: |
| 84 |
$ref: "#/definitions/scalar-prop-list" |
| 85 |
maxItems: |
| 86 |
$ref: "#/definitions/scalar-prop-list" |
| 87 |
minItems: |
| 88 |
$ref: "#/definitions/scalar-prop-list" |
| 89 |
additionalProperties: |
| 90 |
description: "'additionalProperties' depends on 'properties' or 'patternProperties'" |
| 91 |
if: |
| 92 |
properties: |
| 93 |
additionalProperties: |
| 94 |
type: boolean |
| 95 |
then: |
| 96 |
anyOf: |
| 97 |
- required: [ type ] |
| 98 |
- required: [ properties ] |
| 99 |
- required: [ patternProperties ] |
| 100 |
|
| 101 |
dependentRequired: |
| 102 |
# Ensure only valid combinations of if/then/else are present |
| 103 |
if: |
| 104 |
- then |
| 105 |
then: |
| 106 |
- if |
| 107 |
else: |
| 108 |
- if |
| 109 |
- then |
| 110 |
|
| 111 |
properties: |
| 112 |
$defs: |
| 113 |
propertyNames: |
| 114 |
description: A json-schema keyword was found in $defs key. |
| 115 |
not: |
| 116 |
$ref: "#/definitions/json-schema-prop-names" |
| 117 |
additionalProperties: |
| 118 |
description: $defs entries must contain schemas |
| 119 |
type: object |
| 120 |
$ref: "#/definitions/sub-schemas" |
| 121 |
$ref: |
| 122 |
description: |
| 123 |
References must start with '/schemas' or be relative to current |
| 124 |
schema's path. |
| 125 |
pattern: '^(/schemas/|\.\./|#(/|$)|[a-zA-Z0-9]+)' |
| 126 |
not: |
| 127 |
pattern: '^https?://' |
| 128 |
additionalItems: |
| 129 |
oneOf: |
| 130 |
- type: object |
| 131 |
allOf: |
| 132 |
- $ref: "#/definitions/sub-schemas" |
| 133 |
- type: boolean |
| 134 |
additionalProperties: |
| 135 |
oneOf: |
| 136 |
- type: object |
| 137 |
allOf: |
| 138 |
- $ref: "#/definitions/sub-schemas" |
| 139 |
- type: boolean |
| 140 |
allOf: |
| 141 |
uniqueItems: true |
| 142 |
items: |
| 143 |
$ref: "#/definitions/sub-schemas" |
| 144 |
anyOf: |
| 145 |
uniqueItems: true |
| 146 |
items: |
| 147 |
$ref: "#/definitions/sub-schemas" |
| 148 |
contains: |
| 149 |
$ref: "#/definitions/sub-schemas" |
| 150 |
dependencies: |
| 151 |
additionalProperties: |
| 152 |
$ref: "#/definitions/sub-schemas" |
| 153 |
dependentRequired: |
| 154 |
uniqueItems: true |
| 155 |
dependentSchemas: |
| 156 |
additionalProperties: |
| 157 |
$ref: "#/definitions/sub-schemas" |
| 158 |
else: |
| 159 |
$ref: "#/definitions/sub-schemas" |
| 160 |
const: |
| 161 |
type: [ integer, string ] |
| 162 |
enum: |
| 163 |
description: '"enum" must be an array of either integers or strings' |
| 164 |
type: array |
| 165 |
uniqueItems: true |
| 166 |
oneOf: |
| 167 |
- items: |
| 168 |
type: integer |
| 169 |
- items: |
| 170 |
type: string |
| 171 |
if: |
| 172 |
$ref: "#/definitions/sub-schemas" |
| 173 |
items: |
| 174 |
if: |
| 175 |
type: object |
| 176 |
then: |
| 177 |
$ref: "#/definitions/sub-schemas" |
| 178 |
else: |
| 179 |
type: array |
| 180 |
items: |
| 181 |
$ref: "#/definitions/sub-schemas" |
| 182 |
maxItems: |
| 183 |
minimum: 1 |
| 184 |
minItems: |
| 185 |
description: An array property has at least 1 item or is not present |
| 186 |
minimum: 1 |
| 187 |
not: |
| 188 |
$ref: "#/definitions/sub-schemas" |
| 189 |
oneOf: |
| 190 |
allOf: |
| 191 |
- items: |
| 192 |
$ref: "#/definitions/sub-schemas" |
| 193 |
- description: Use 'enum' rather than 'oneOf' + 'const' entries |
| 194 |
not: |
| 195 |
items: |
| 196 |
propertyNames: |
| 197 |
const: const |
| 198 |
required: |
| 199 |
- const |
| 200 |
patternProperties: |
| 201 |
propertyNames: |
| 202 |
allOf: |
| 203 |
- description: Fixed strings belong in 'properties', not 'patternProperties' |
| 204 |
pattern: '[\^$()*@]' |
| 205 |
not: |
| 206 |
pattern: '^\^[a-zA-Z0-9,\-._#@]+\$$' |
| 207 |
- description: A json-schema keyword was found instead of a DT property name. |
| 208 |
not: |
| 209 |
$ref: "#/definitions/json-schema-prop-names" |
| 210 |
additionalProperties: |
| 211 |
$ref: "#/definitions/sub-schemas" |
| 212 |
properties: |
| 213 |
propertyNames: |
| 214 |
allOf: |
| 215 |
- description: Expected a valid DT property name |
| 216 |
pattern: "^[#$a-zA-Z][a-zA-Z0-9#,+\\-._@]{0,63}$" |
| 217 |
- description: A json-schema keyword was found instead of a DT property name. |
| 218 |
not: |
| 219 |
$ref: "#/definitions/json-schema-prop-names" |
| 220 |
additionalProperties: |
| 221 |
type: [ object, boolean ] |
| 222 |
$ref: "#/definitions/sub-schemas" |
| 223 |
required: |
| 224 |
description: "'required' must be valid DT property or node names" |
| 225 |
type: array |
| 226 |
uniqueItems: true |
| 227 |
items: |
| 228 |
pattern: '^([a-zA-Z#][a-zA-Z0-9#,+\-._@]{0,63}|\$nodename)$' |
| 229 |
select: |
| 230 |
$ref: "#/definitions/sub-schemas" |
| 231 |
then: |
| 232 |
$ref: "#/definitions/sub-schemas" |
| 233 |
unevaluatedProperties: |
| 234 |
if: |
| 235 |
type: object |
| 236 |
then: |
| 237 |
$ref: "#/definitions/sub-schemas" |
| 238 |
else: |
| 239 |
type: boolean |
| 240 |
uniqueItems: |
| 241 |
type: boolean |
| 242 |
|
| 243 |
allOf: |
| 244 |
- description: Scalar properties should not have array keywords |
| 245 |
if: |
| 246 |
properties: |
| 247 |
$ref: |
| 248 |
pattern: '(int[1-8]+|phandle|flag)$' |
| 249 |
required: |
| 250 |
- $ref |
| 251 |
then: |
| 252 |
properties: |
| 253 |
maxItems: false |
| 254 |
minItems: false |
| 255 |
items: false |