Skip to content

Commit 3f4569c

Browse files
committed
Implement v2 Spec JSON Scheam
Based on pgxn/rfcs#3. As with the v1 schemas, use JSON Schema v2020 for the v2 schemas. Fix a few minor issues with the v1 schema, as well. Add full test suite in Rust; move code shared between the v1 and v2 tests to `tests/common/mod.rs`. This includes custom format functions not required for v1, including spdx version expression validation with the `spdx` crate, and path validation to ensure no `..` is included in paths.
1 parent e32058b commit 3f4569c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5037
-324
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
- id: fmt
2020
- id: check
2121
- id: clippy
22-
- id: test
22+
# - id: test
2323

2424
- repo: https://github.com/pre-commit/mirrors-prettier
2525
rev: v3.1.0

Cargo.lock

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ serde_json = "1.0"
1818

1919
[dependencies]
2020
serde = { version = "1", features = ["derive"] }
21+
spdx = "0.10.6"

schema/v1/bugtracker.schema.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
}
1818
},
1919
"anyOf": [{ "required": ["web"] }, { "required": ["mailto"] }],
20-
"patternProperties": {
21-
"^[xX]_.": {
22-
"description": "Custom key"
23-
}
24-
},
20+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
2521
"additionalProperties": false,
2622
"examples": [
2723
{

schema/v1/distribution.schema.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@
5050
},
5151
"resources": { "$ref": "resources.schema.json" }
5252
},
53-
"patternProperties": {
54-
"^[xX]_.": {
55-
"description": "Custom key"
56-
}
57-
},
53+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
5854
"additionalProperties": false,
5955
"required": [
6056
"name",

schema/v1/extension.schema.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626
}
2727
},
2828
"required": ["file", "version"],
29-
"patternProperties": {
30-
"^[xX]_.": {
31-
"description": "Custom key"
32-
}
33-
},
29+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
3430
"additionalProperties": false,
3531
"examples": [
3632
{

schema/v1/license.schema.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"items": { "$ref": "#/$defs/validLicense" },
1515
"description": "A list of shortcuts to identify well-known licenses for the distribution.",
1616
"minItems": 1,
17+
"uniqueItems": true,
1718
"examples": [["apache_2_0", "postgresql"], ["mit"]]
1819
},
1920
{

schema/v1/maintainer.schema.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"type": "string",
1515
"minLength": 1
1616
},
17+
"uniqueItems": true,
1718
"minItems": 1
1819
}
1920
],

schema/v1/meta-spec.schema.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
}
1818
},
1919
"required": ["version"],
20-
"patternProperties": {
21-
"^[xX]_.": {
22-
"description": "Custom key"
23-
}
24-
},
20+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
2521
"additionalProperties": false,
2622
"examples": [
2723
{ "version": "1.0.0" },

schema/v1/no_index.schema.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
}
1616
},
1717
"anyOf": [{ "required": ["file"] }, { "required": ["directory"] }],
18-
"patternProperties": {
19-
"^[xX]_.": {
20-
"description": "Custom key"
21-
}
22-
},
18+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
2319
"additionalProperties": false,
2420
"examples": [
2521
{
@@ -33,6 +29,7 @@
3329
{
3430
"type": "array",
3531
"minItems": 1,
32+
"uniqueItems": true,
3633
"items": {
3734
"type": "string",
3835
"description": "Relative path in unix convention to a file to ignore.",

schema/v1/prereq_phase.schema.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
"description": "These dependencies cannot be installed when the phase is in operation. This is a very rare situation, and the conflicts relationship should be used with great caution, or not at all."
2323
}
2424
},
25-
"patternProperties": {
26-
"^[xX]_.": {
27-
"description": "Custom key"
28-
}
29-
},
25+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
3026
"additionalProperties": false,
3127
"anyOf": [
3228
{ "required": ["requires"] },

schema/v1/prereqs.schema.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@
3333
{ "required": ["runtime"] },
3434
{ "required": ["develop"] }
3535
],
36-
"patternProperties": {
37-
"^[xX]_.": {
38-
"description": "Custom key"
39-
}
40-
},
36+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
4137
"additionalProperties": false,
4238
"examples": [
4339
{

schema/v1/repository.schema.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
}
2323
},
2424
"anyOf": [{ "required": ["url", "type"] }, { "required": ["web"] }],
25-
"patternProperties": {
26-
"^[xX]_.": {
27-
"description": "Custom key"
28-
}
29-
},
25+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
3026
"additionalProperties": false,
3127
"examples": [
3228
{

schema/v1/resources.schema.json

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
33
"$id": "https://pgxn.org/meta/v1/resources.schema.json",
4-
"title": "Source Control Repository",
5-
"description": "An Extension is provided by a distribution.",
4+
"title": "Resources",
5+
"description": "Resources related to this distribution.",
66
"type": "object",
77
"properties": {
88
"homepage": {
@@ -13,11 +13,7 @@
1313
"bugtracker": { "$ref": "bugtracker.schema.json" },
1414
"repository": { "$ref": "repository.schema.json" }
1515
},
16-
"patternProperties": {
17-
"^[xX]_.": {
18-
"description": "Custom key"
19-
}
20-
},
16+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
2117
"additionalProperties": false,
2218
"anyOf": [
2319
{ "required": ["homepage"] },

schema/v1/tags.schema.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"description": "A list of keywords that describe the distribution.",
66
"type": "array",
77
"minItems": 1,
8+
"uniqueItems": true,
89
"items": {
910
"title": "Tag",
1011
"description": "A Tag is a subtype of String that must be fewer than 256 characters long contain no slash (/), backslash (\\), or control characters.",

schema/v1/version_range.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"type": "string",
99
"pattern": "^(([=!]=|[<>]=?)\\s*)?((0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?|0)(,\\s*((([=!]=|[<>]=?)\\s*)?)(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)*$",
10-
"$comment": "https://regex101.com/r/Uy7XWK/1"
10+
"$comment": "https://regex101.com/r/Uy7XWK"
1111
},
1212
{
1313
"const": 0

schema/v2/app.schema.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://pgxn.org/meta/v2/app.schema.json",
4+
"title": "App",
5+
"description": "An App represents an applications, command-line or otherwise.",
6+
"type": "object",
7+
"properties": {
8+
"lang": {
9+
"$ref": "term.schema.json",
10+
"description": "A short string representing the implementation language. Required for apps that need the `'#!{cmd}` shebang line modified before installing."
11+
},
12+
"bin": {
13+
"$ref": "path.schema.json",
14+
"description": "A path pointing to the app binary, which may be generated by the build process."
15+
},
16+
"doc": {
17+
"$ref": "path.schema.json",
18+
"description": "A path pointing to the documentation file for the app, which **SHOULD** be more than a README."
19+
},
20+
"abstract": {
21+
"type": "string",
22+
"description": "A short String value describing the extension.",
23+
"minLength": 1
24+
},
25+
"lib": {
26+
"$ref": "path.schema.json",
27+
"description": "A path pointing a directory of additional files to install, such as support libraries or modules."
28+
},
29+
"man": {
30+
"$ref": "path.schema.json",
31+
"description": "A path pointing to a man page or directory of man pages created by the build process."
32+
},
33+
"html": {
34+
"$ref": "path.schema.json",
35+
"description": "A path pointing to an HTML file or directory of HTML files created by the build process."
36+
}
37+
},
38+
"required": ["bin"],
39+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
40+
"additionalProperties": false,
41+
"examples": [
42+
{
43+
"lang": "perl",
44+
"bin": "blib/script/app",
45+
"lib": "blib/lib",
46+
"man": "blib/libdoc",
47+
"html": "blib/libhtml",
48+
"doc": "doc/app.md",
49+
"abstract": "blah blah blah"
50+
},
51+
{
52+
"lang": "python",
53+
"bin": "bin/common/check_unique_constraint.py",
54+
"abstract": "Check that all rows in a partition set are unique for the given columns"
55+
},
56+
{
57+
"bin": "pg_top",
58+
"man": "pg_top.1",
59+
"abstract": "pg_top is 'top' for PostgreSQL"
60+
}
61+
]
62+
}

schema/v2/artifacts.schema.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://pgxn.org/meta/v2/artifacts.schema.json",
4+
"title": "Artifacts",
5+
"description": "*Artifacts* describes non-PGXN links and checksums for downloading the distribution in one or more formats, including source code, binaries, system packages, etc. Consumers **MAY** use this information to determine the best option for installing an extension on a particular system. Useful for projects that publish their own binaries, such as in GitHub releases.",
6+
"type": "array",
7+
"minItems": 1,
8+
"items": {
9+
"type": "object",
10+
"properties": {
11+
"url": {
12+
"type": "string",
13+
"format": "uri",
14+
"description": "The URL to download the artifact."
15+
},
16+
"type": {
17+
"type": "string",
18+
"minLength": 2,
19+
"pattern": "^[a-z0-9]{2,}$",
20+
"description": "The type of artifact. **MUST** be a single lowercase word describing the artifact, such as none of `binary`, `source`, `rpm`, `homebrew`, etc."
21+
},
22+
"platform": {
23+
"$ref": "platform.schema.json",
24+
"description": "Identifies the platform the artifact was built for. **RECOMMENDED** for packages compiled for a specific platform, such as a C extension compiled for `linux-arm64`."
25+
},
26+
"sha256": {
27+
"type": "string",
28+
"pattern": "^[0-9a-fA-F]{64}$",
29+
"description": "The SHA-256 checksum for the artifact in hex format."
30+
},
31+
"sha512": {
32+
"type": "string",
33+
"pattern": "^[0-9a-fA-F]{128}$",
34+
"description": "The SHA-512 checksum for the artifact in hex format."
35+
}
36+
},
37+
"anyOf": [
38+
{ "required": ["url", "type", "sha256"] },
39+
{ "required": ["url", "type", "sha512"] }
40+
],
41+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
42+
"additionalProperties": false
43+
},
44+
"examples": [
45+
[
46+
{
47+
"type": "source",
48+
"url": "https://github.com/theory/pg-pair/releases/download/v1.1.0/pair-1.1.0.zip",
49+
"sha256": "2b9d2416096d2930be51e5332b70bcd97846947777a93e4a3d65fe1b5fd7b004"
50+
},
51+
{
52+
"type": "binary",
53+
"url": "https://github.com/theory/pg-pair/releases/download/v1.1.0/pair-1.1.0-linux-amd64.tar.gz",
54+
"sha256": "ec33656ba693c01be2b2b500c639846fb0ede7f7f8ee1f4c157bc9cab53c8500"
55+
},
56+
{
57+
"type": "binary",
58+
"url": "https://github.com/theory/pg-pair/releases/download/v1.1.0/pair-1.1.0-linux-arm64.tar.gz",
59+
"sha512": "612ad0a8b7e292daf0c723bd0ac8029a838357b2d3abbada7cd7445f7690191abd6593a1336742e705314df81fc1c0063423f62e4abd846f350c251ef6a6a24f"
60+
}
61+
]
62+
]
63+
}

schema/v2/badges.schema.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://pgxn.org/meta/v2/badges.schema.json",
4+
"title": "Badges",
5+
"description": "*Badges* represents links to a [Shields](https://github.com/badges/shields/blob/master/spec/SPECIFICATION.md \"Shields badge specification\")-conformant badges.",
6+
"type": "array",
7+
"minItems": 1,
8+
"items": {
9+
"type": "object",
10+
"properties": {
11+
"src": {
12+
"type": "string",
13+
"format": "uri",
14+
"description": "The URI for the badge."
15+
},
16+
"alt": {
17+
"type": "string",
18+
"minLength": 4,
19+
"maxLength": 4048,
20+
"description": "Alternate text for accessability."
21+
},
22+
"url": {
23+
"type": "string",
24+
"format": "uri",
25+
"description": "The URL the badge links to."
26+
}
27+
},
28+
"required": ["src", "alt"],
29+
"patternProperties": { "^[xX]_.": { "description": "Custom key" } },
30+
"additionalProperties": false
31+
},
32+
"examples": [
33+
[
34+
{
35+
"alt": "Test Status",
36+
"src": "https://test.packages.postgresql.org/github.com/example/pair.svg"
37+
}
38+
]
39+
]
40+
}

0 commit comments

Comments
 (0)