Skip to content

Commit 3c2195f

Browse files
committed
Use common definitions for requirement
Using an enum for namespace and constants for other was confusing. We now use three constants for requirement: "optional", "required" and "prohibited". And we define a "requirement" property for each component based on choice of "oneOf" these three values. This is explicit and easier to read. Signed-off-by: Philippe Ombredanne <pombredanne@aboutcode.org>
1 parent 700fe1d commit 3c2195f

1 file changed

Lines changed: 58 additions & 23 deletions

File tree

schemas/purl-type-definition.schema.json

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,23 @@
66
"type": "object",
77
"additionalProperties": false,
88
"definitions": {
9-
"requirement": {
10-
"title": "Component requirement",
11-
"description": "States whether this PURL component is required, optional, or prohibited.",
12-
"type": "string",
13-
"enum": [
14-
"required",
15-
"optional",
16-
"prohibited"
17-
],
18-
"meta:enum": {
19-
"required": "This PURL component is required for this PURL type.",
20-
"optional": "This PURL component is optional for this PURL type.",
21-
"prohibited": "This PURL component is prohibited: it must not be present for this PURL type."
22-
}
23-
},
249
"optional_requirement": {
2510
"title": "Component optional requirement",
2611
"description": "States that this PURL component is optional for a PURL type.",
2712
"type": "string",
28-
"constant": "optional"
13+
"const": "optional"
2914
},
3015
"required_requirement": {
3116
"title": "Component required requirement",
3217
"description": "States that this PURL component is required for a PURL type.",
3318
"type": "string",
34-
"constant": "required"
19+
"const": "required"
20+
},
21+
"prohibited_requirement": {
22+
"title": "Component prohibited requirement",
23+
"description": "States that this PURL component is prohibited for a PURL type.",
24+
"type": "string",
25+
"const": "prohibited"
3526
},
3627
"purl_component_definition": {
3728
"title": "PURL component definition",
@@ -86,7 +77,7 @@
8677
"$schema": {
8778
"title": "JSON schema",
8879
"description": "Contains the URL of the JSON schema for Package-URL type definition.",
89-
"constant": "https://packageurl.org/schemas/purl-type.schema-1.0.json",
80+
"const": "https://packageurl.org/schemas/purl-type-definition.schema-1.0.json",
9081
"format": "uri"
9182
},
9283
"$id": {
@@ -157,7 +148,20 @@
157148
],
158149
"properties": {
159150
"requirement": {
160-
"$ref": "#/definitions/requirement"
151+
"title": "Namespace requirement",
152+
"description": "States that the PURL namespace component is optional, required or prohibited for a PURL type.",
153+
"type": "string",
154+
"oneOf": [
155+
{
156+
"$ref": "#/definitions/optional_requirement"
157+
},
158+
{
159+
"$ref": "#/definitions/required_requirement"
160+
},
161+
{
162+
"$ref": "#/definitions/prohibited_requirement"
163+
}
164+
]
161165
}
162166
},
163167
"allOf": [
@@ -175,7 +179,14 @@
175179
],
176180
"properties": {
177181
"requirement": {
178-
"$ref": "#/definitions/required_requirement"
182+
"title": "Name component requirement",
183+
"description": "States that the PURL name component is always required.",
184+
"type": "string",
185+
"oneOf": [
186+
{
187+
"$ref": "#/definitions/required_requirement"
188+
}
189+
]
179190
}
180191
},
181192
"allOf": [
@@ -193,7 +204,14 @@
193204
],
194205
"properties": {
195206
"requirement": {
196-
"$ref": "#/definitions/optional_requirement"
207+
"title": "Version requirement",
208+
"description": "States that the PURL version is optional.",
209+
"type": "string",
210+
"oneOf": [
211+
{
212+
"$ref": "#/definitions/optional_requirement"
213+
}
214+
]
197215
}
198216
},
199217
"allOf": [
@@ -224,7 +242,17 @@
224242
"type": "string"
225243
},
226244
"requirement": {
227-
"$ref": "#/definitions/requirement"
245+
"title": "Qualifier key requirement",
246+
"description": "States that a PURL qualifier key is optional or required for a PURL type.",
247+
"type": "string",
248+
"oneOf": [
249+
{
250+
"$ref": "#/definitions/optional_requirement"
251+
},
252+
{
253+
"$ref": "#/definitions/required_requirement"
254+
}
255+
]
228256
},
229257
"description": {
230258
"title": "Description",
@@ -253,7 +281,14 @@
253281
],
254282
"properties": {
255283
"requirement": {
256-
"$ref": "#/definitions/optional_requirement"
284+
"title": "Subpath requirement",
285+
"description": "States that the PURL subpath is optional.",
286+
"type": "string",
287+
"oneOf": [
288+
{
289+
"$ref": "#/definitions/optional_requirement"
290+
}
291+
]
257292
}
258293
},
259294
"allOf": [

0 commit comments

Comments
 (0)