Skip to content

Commit d396ad2

Browse files
authored
Merge pull request #679 from package-url/freeze-purl-type-schemas
Freeze purl-type schemas for Ecma standard
2 parents de2ab4b + 4899f15 commit d396ad2

File tree

2 files changed

+338
-0
lines changed

2 files changed

+338
-0
lines changed
Lines changed: 327 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,327 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://packageurl.org/schemas/purl-type-definition.schema-1.0.json",
4+
"title": "Package-URL Type Definition",
5+
"description": "Schema to specify a Package-URL (PURL) type as a structured definition.",
6+
"type": "object",
7+
"additionalProperties": false,
8+
"definitions": {
9+
"optional_requirement": {
10+
"title": "Component optional requirement",
11+
"description": "States that this PURL component is optional for a PURL type.",
12+
"type": "string",
13+
"const": "optional"
14+
},
15+
"required_requirement": {
16+
"title": "Component required requirement",
17+
"description": "States that this PURL component is required for a PURL type.",
18+
"type": "string",
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"
26+
},
27+
"purl_component_definition": {
28+
"title": "PURL component definition",
29+
"description": "PURL component definition properties that apply to most PURL components",
30+
"type": "object",
31+
"properties": {
32+
"permitted_characters": {
33+
"title": "Permitted characters in this PURL component",
34+
"description": "A regular expression (ECMA-262 dialect) defining the 'Permitted characters' for this component of this Package-URL type. If provided, this must be a subset of the 'Permitted characters' defined in the PURL specification.",
35+
"type": "string",
36+
"format": "regex"
37+
},
38+
"case_sensitive": {
39+
"title": "Case sensitive",
40+
"description": "true if this PURL component is case sensitive. If false, the canonical form must be lowercased.",
41+
"type": "boolean",
42+
"default": true
43+
},
44+
"normalization_rules": {
45+
"title": "Normalization rules",
46+
"description": "List of rules to normalize this component for this PURL type. These are plain text, unstructured rules as some require programming and cannot be enforced only with a schema. Tools are expected to apply these rules programmatically.",
47+
"type": "array",
48+
"uniqueItems": true,
49+
"items": {
50+
"type": "string"
51+
}
52+
},
53+
"native_name": {
54+
"title": "Native name",
55+
"description": "The native name of this PURL component in the package ecosystem. For instance, the 'namespace' for the 'maven' type is 'groupId', and 'scope' for the 'npm' PURL type.",
56+
"type": "string"
57+
},
58+
"note": {
59+
"title": "Note",
60+
"description": "Extra note text.",
61+
"type": "string"
62+
}
63+
}
64+
}
65+
},
66+
"required": [
67+
"$id",
68+
"type",
69+
"type_name",
70+
"description",
71+
"repository",
72+
"namespace_definition",
73+
"name_definition",
74+
"examples"
75+
],
76+
"properties": {
77+
"$schema": {
78+
"title": "JSON schema",
79+
"description": "Contains the URL of the JSON schema for Package-URL type definition.",
80+
"const": "https://packageurl.org/schemas/purl-type-definition.schema-1.0.json",
81+
"format": "uri"
82+
},
83+
"$id": {
84+
"title": "PURL type definition id",
85+
"description": "The unique identifier URI for this PURL type definition.",
86+
"type": "string",
87+
"pattern": "^https:\\/\\/packageurl\\.org/types/[a-z0-9-]+-definition\\.json$"
88+
},
89+
"type": {
90+
"title": "PURL type",
91+
"description": "The type string for this Package-URL type.",
92+
"type": "string",
93+
"pattern": "^[a-z][a-z0-9-\\.]+$",
94+
"examples": [
95+
"maven",
96+
"npm",
97+
"pypi"
98+
]
99+
},
100+
"type_name": {
101+
"title": "Type name",
102+
"description": "The name for this PURL type.",
103+
"type": "string",
104+
"examples": [
105+
"Apache Maven",
106+
"Python Package"
107+
]
108+
},
109+
"description": {
110+
"title": "Description",
111+
"description": "The description of this PURL type.",
112+
"type": "string"
113+
},
114+
"repository": {
115+
"title": "Repository",
116+
"description": "The package repository usage for this PURL type.",
117+
"type": "object",
118+
"additionalProperties": false,
119+
"required": [
120+
"use_repository"
121+
],
122+
"properties": {
123+
"use_repository": {
124+
"title": "Use repository",
125+
"description": "true if this PURL type uses a public package repository.",
126+
"type": "boolean",
127+
"default": false
128+
},
129+
"default_repository_url": {
130+
"title": "Default repository URL",
131+
"description": "The default public repository URL for this PURL type",
132+
"type": "string",
133+
"format": "uri"
134+
},
135+
"note": {
136+
"title": "Note",
137+
"description": "Extra note text.",
138+
"type": "string"
139+
}
140+
}
141+
},
142+
"namespace_definition": {
143+
"title": "Namespace definition",
144+
"description": "Definition of the namespace component for this PURL type. The PURL namespace component must be required, optional or prohibited for a specific PURL type definition.",
145+
"type": "object",
146+
"required": [
147+
"requirement"
148+
],
149+
"properties": {
150+
"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+
]
165+
}
166+
},
167+
"allOf": [
168+
{
169+
"$ref": "#/definitions/purl_component_definition"
170+
}
171+
]
172+
},
173+
"name_definition": {
174+
"title": "Name definition",
175+
"description": "Definition of the name component for this PURL type. The PURL name component is required for all PURL type definitions.",
176+
"type": "object",
177+
"required": [
178+
"requirement"
179+
],
180+
"properties": {
181+
"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+
]
190+
}
191+
},
192+
"allOf": [
193+
{
194+
"$ref": "#/definitions/purl_component_definition"
195+
}
196+
]
197+
},
198+
"version_definition": {
199+
"title": "Version definition",
200+
"description": "Definition of the version component for this PURL type. The PURL version component is optional for a specific PURL type definition.",
201+
"type": "object",
202+
"required": [
203+
"requirement"
204+
],
205+
"properties": {
206+
"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+
]
215+
}
216+
},
217+
"allOf": [
218+
{
219+
"$ref": "#/definitions/purl_component_definition"
220+
}
221+
]
222+
},
223+
"qualifiers_definition": {
224+
"title": "Qualifiers definition",
225+
"description": "Definition of the qualifiers specific to this PURL type. The PURL qualifiers component is optional for a specific PURL type, but a qualifiers key or keys may be required for a specific PURL type.",
226+
"type": "array",
227+
"additionalItems": false,
228+
"uniqueItems": true,
229+
"items": {
230+
"title": "Qualifiers definition",
231+
"description": "The definition of a qualifier specific to this PURL type.",
232+
"type": "object",
233+
"additionalProperties": false,
234+
"required": [
235+
"key",
236+
"description"
237+
],
238+
"properties": {
239+
"key": {
240+
"title": "Qualifier key",
241+
"description": "The key for the qualifier.",
242+
"type": "string"
243+
},
244+
"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+
]
256+
},
257+
"description": {
258+
"title": "Description",
259+
"description": "The description of this qualifier.",
260+
"type": "string"
261+
},
262+
"default_value": {
263+
"title": "Default value",
264+
"description": "The optional default value of this qualifier if not provided.",
265+
"type": "string"
266+
},
267+
"native_name": {
268+
"title": "Native name",
269+
"description": "The equivalent native name for this qualifier key.",
270+
"type": "string"
271+
}
272+
}
273+
}
274+
},
275+
"subpath_definition": {
276+
"title": "Subpath definition",
277+
"description": "The definition for the subpath for this PURL type. The PURL subpath component is optional for a specific PURL type definition.",
278+
"type": "object",
279+
"required": [
280+
"requirement"
281+
],
282+
"properties": {
283+
"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+
]
292+
}
293+
},
294+
"allOf": [
295+
{
296+
"$ref": "#/definitions/purl_component_definition"
297+
}
298+
]
299+
},
300+
"examples": {
301+
"title": "PURL examples",
302+
"description": "Example of valid, canonical PURLs for this package type.",
303+
"type": "array",
304+
"uniqueItems": true,
305+
"minItems": 1,
306+
"items": {
307+
"type": "string",
308+
"pattern": "^pkg:[a-z][a-z0-9-\\.]+/.*$"
309+
}
310+
},
311+
"note": {
312+
"title": "Note",
313+
"description": "Note about this PURL type.",
314+
"type": "string"
315+
},
316+
"reference_urls": {
317+
"title": "Reference URLs",
318+
"description": "Optional list of informational reference URLs about this PURL type.",
319+
"type": "array",
320+
"uniqueItems": true,
321+
"items": {
322+
"type": "string",
323+
"format": "uri"
324+
}
325+
}
326+
}
327+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://packageurl.org/schemas/purl-type-index.schema-1.0.json",
4+
"title": "Package-URL types index",
5+
"description": "An index of registered Package-URL types.",
6+
"type": "array",
7+
"additionalItems": false,
8+
"items": {
9+
"type": "string"
10+
}
11+
}

0 commit comments

Comments
 (0)