Skip to content

Commit 992e16a

Browse files
Initial commit of conditional subschemas based on the component type.
Signed-off-by: Steve Springett <steve@springett.us>
1 parent 6a39e36 commit 992e16a

1 file changed

Lines changed: 74 additions & 17 deletions

File tree

schema/2.0/model/cyclonedx-component-2.0.schema.json

Lines changed: 74 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,6 @@
250250
"title": "Release notes",
251251
"description": "Specifies release notes."
252252
},
253-
"modelCard": {
254-
"$ref": "cyclonedx-ai-modelcard-2.0.schema.json#/$defs/modelCard",
255-
"title": "AI/ML Model Card"
256-
},
257-
"data": {
258-
"type": "array",
259-
"items": {"$ref": "#/$defs/componentData"},
260-
"title": "Data",
261-
"description": "This object SHOULD be specified for any component of type `data` and must not be specified for other component types."
262-
},
263-
"cryptoProperties": {
264-
"$ref": "cyclonedx-cryptography-2.0.schema.json#/$defs/cryptoProperties",
265-
"title": "Cryptographic Properties"
266-
},
267253
"tags": {
268254
"$ref": "cyclonedx-common-2.0.schema.json#/$defs/tags",
269255
"title": "Tags"
@@ -282,20 +268,91 @@
282268
},
283269
"allOf": [
284270
{
271+
"title": "Versioning Requirement",
285272
"description": "Requirement: ensure that `version` and `versionRange` are not present simultaneously.",
286273
"not": {
287274
"required": ["version", "versionRange"]
288275
}
289276
},
290277
{
278+
"title": "Version Range Requirement",
291279
"description": "Requirement: 'versionRange' must not be present when 'isExternal' is `false`.",
292280
"if": {
293-
"properties": { "isExternal": { "const": false } }
281+
"required": ["versionRange"]
294282
},
295283
"then": {
296-
"not": { "required": ["versionRange"] }
284+
"properties": { "isExternal": { "enum": [true] } }
285+
}
286+
},
287+
{
288+
"title": "Hardware Requirement",
289+
"description": "Requirement: Hardware components MUST NOT specify a swid or purl.",
290+
"if": {
291+
"properties": { "type": { "enum": ["device"] } }
297292
},
298-
"else": true
293+
"then": {
294+
"not": {
295+
"anyOf": [
296+
{ "required": ["swid"] },
297+
{ "required": ["purl"] }
298+
]
299+
}
300+
}
301+
},
302+
{
303+
"title": "Cryptography Requirement",
304+
"description": "Requirement: cryptoProperties may only be used for cryptographic-asset.",
305+
"if": {
306+
"properties": { "type": { "enum": ["cryptographic-asset"] } }
307+
},
308+
"then": {
309+
"properties": {
310+
"cryptoProperties": {
311+
"$ref": "cyclonedx-cryptography-2.0.schema.json#/$defs/cryptoProperties",
312+
"title": "Cryptographic Properties"
313+
}
314+
}
315+
},
316+
"else": {
317+
"not": { "required": ["cryptoProperties"] }
318+
}
319+
},
320+
{
321+
"title": "AI/ML Requirement",
322+
"description": "Requirement: modelCard may only be used for machine-learning-model.",
323+
"if": {
324+
"properties": { "type": { "enum": ["machine-learning-model"] } }
325+
},
326+
"then": {
327+
"properties": {
328+
"modelCard": {
329+
"$ref": "cyclonedx-ai-modelcard-2.0.schema.json#/$defs/modelCard",
330+
"title": "AI/ML Model Card"
331+
}
332+
}
333+
},
334+
"else": {
335+
"not": { "required": ["modelCard"] }
336+
}
337+
},
338+
{
339+
"title": "Data Requirement",
340+
"description": "Requirement: data may only be used for components of type data.",
341+
"if": {
342+
"properties": { "type": { "enum": ["data"] } }
343+
},
344+
"then": {
345+
"properties": {
346+
"data": {
347+
"type": "array",
348+
"items": {"$ref": "#/$defs/componentData"},
349+
"title": "Data Properties"
350+
}
351+
}
352+
},
353+
"else": {
354+
"not": { "required": ["data"] }
355+
}
299356
}
300357
]
301358
},

0 commit comments

Comments
 (0)