Skip to content

Commit e32058b

Browse files
committed
Fully test schema and fix issues found
Test each sub-schema to ensure things work as expected, and fix the things that do not. Also port the tests from the pgxn-meta-validator project and fix the additional issues.
1 parent e1b1034 commit e32058b

17 files changed

+2381
-109
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ exclude = [ ".github", ".gitattributes", "target", ".vscode", ".gitignore" ]
1515
[dev-dependencies]
1616
boon = "0.6"
1717
serde_json = "1.0"
18+
19+
[dependencies]
20+
serde = { version = "1", features = ["derive"] }

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: test # Validate the JSON schema.
22
test:
3-
@cargo test -- --show-output
3+
@cargo test
44

55
.git/hooks/pre-commit:
66
@printf "#!/bin/sh\nmake lint\n" > $@

schema/v1/bugtracker.schema.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@
1616
"description": "An email address to which bug reports can be sent"
1717
}
1818
},
19-
"anyOf": [
20-
{ "required": ["web"] },
21-
{ "required": ["mailto"] },
22-
{ "required": ["web", "mailto"] }
23-
],
19+
"anyOf": [{ "required": ["web"] }, { "required": ["mailto"] }],
2420
"patternProperties": {
25-
"^[xX]_": {
21+
"^[xX]_.": {
2622
"description": "Custom key"
2723
}
2824
},

schema/v1/distribution.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"resources": { "$ref": "resources.schema.json" }
5252
},
5353
"patternProperties": {
54-
"^[xX]_": {
54+
"^[xX]_.": {
5555
"description": "Custom key"
5656
}
5757
},

schema/v1/extension.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"required": ["file", "version"],
2929
"patternProperties": {
30-
"^[xX]_": {
30+
"^[xX]_.": {
3131
"description": "Custom key"
3232
}
3333
},

schema/v1/meta-spec.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"version": {
99
"type": "string",
1010
"pattern": "^1[.]0[.][[:digit:]]+$",
11-
"description": "The version of the PGXN Meta Spec against which the document was generated."
11+
"description": "The version of the PGXN Meta Spec against which the document was generated. Must be 1.0.x."
1212
},
1313
"url": {
1414
"type": "string",
@@ -18,7 +18,7 @@
1818
},
1919
"required": ["version"],
2020
"patternProperties": {
21-
"^[xX]_": {
21+
"^[xX]_.": {
2222
"description": "Custom key"
2323
}
2424
},

schema/v1/no_index.schema.json

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,16 @@
77
"properties": {
88
"file": {
99
"description": "A list of relative paths to files. Paths **must be** specified with unix conventions.",
10-
"type": "array",
11-
"minItems": 1,
12-
"items": {
13-
"type": "string",
14-
"description": "Relative path in unix convention to a file to ignore.",
15-
"minLength": 1
16-
}
10+
"$ref": "#/$defs/fileList"
1711
},
1812
"directory": {
1913
"description": "A list of relative paths to directories. Paths **must be** specified with unix conventions.",
20-
"type": "array",
21-
"minItems": 1,
22-
"items": {
23-
"type": "string",
24-
"description": "Relative path in unix convention to a directory to ignore.",
25-
"minLength": 1
26-
}
14+
"$ref": "#/$defs/fileList"
2715
}
2816
},
29-
"anyOf": [
30-
{ "required": ["file"] },
31-
{ "required": ["directory"] },
32-
{ "required": ["file", "directory"] }
33-
],
17+
"anyOf": [{ "required": ["file"] }, { "required": ["directory"] }],
3418
"patternProperties": {
35-
"^[xX]_": {
19+
"^[xX]_.": {
3620
"description": "Custom key"
3721
}
3822
},
@@ -42,5 +26,25 @@
4226
"file": ["src/file.sql"],
4327
"directory": ["src/private"]
4428
}
45-
]
29+
],
30+
"$defs": {
31+
"fileList": {
32+
"oneOf": [
33+
{
34+
"type": "array",
35+
"minItems": 1,
36+
"items": {
37+
"type": "string",
38+
"description": "Relative path in unix convention to a file to ignore.",
39+
"minLength": 1
40+
}
41+
},
42+
{
43+
"type": "string",
44+
"description": "Relative path in unix convention to a file to ignore.",
45+
"minLength": 1
46+
}
47+
]
48+
}
49+
}
4650
}

schema/v1/prereq_phase.schema.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@
2323
}
2424
},
2525
"patternProperties": {
26-
"^[xX]_": {
26+
"^[xX]_.": {
2727
"description": "Custom key"
2828
}
2929
},
3030
"additionalProperties": false,
31-
"minProperties": 1,
32-
"$comment": "Really should require at least one of the named properties; this allows for a single _x property. Good enough for now.",
31+
"anyOf": [
32+
{ "required": ["requires"] },
33+
{ "required": ["recommends"] },
34+
{ "required": ["suggests"] },
35+
{ "required": ["conflicts"] }
36+
],
3337
"examples": [
3438
{
3539
"requires": {

schema/v1/prereqs.schema.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@
2626
"description": "The develop phase’s prereqs are extensions needed to work on the distribution’s source code as its maintainer does. These tools might be needed to build a release tarball, to run maintainer-only tests, or to perform other tasks related to developing new versions of the distribution."
2727
}
2828
},
29-
"minProperties": 1,
30-
"$comment": "Really should require at least one of the named properties; this allows for a single _x property. Good enough for now.",
29+
"anyOf": [
30+
{ "required": ["configure"] },
31+
{ "required": ["build"] },
32+
{ "required": ["test"] },
33+
{ "required": ["runtime"] },
34+
{ "required": ["develop"] }
35+
],
3136
"patternProperties": {
32-
"^[xX]_": {
37+
"^[xX]_.": {
3338
"description": "Custom key"
3439
}
3540
},

0 commit comments

Comments
 (0)