Skip to content

Commit fe950d2

Browse files
authored
Merge pull request #180 from OAI/chore/v1.1-dev-setup
ci: sets up testing infra for 1.1 version
2 parents 3a7cdad + aa5902d commit fe950d2

26 files changed

+258
-7
lines changed

package-lock.json

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

schemas/v1.1/schema.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
$id: https://spec.openapis.org/overlay/1.1/schema/WORK-IN-PROGRESS
2+
$schema: https://json-schema.org/draft/2020-12/schema
3+
description: The description of Overlay v1.1.x documents
4+
type: object
5+
properties:
6+
overlay:
7+
type: string
8+
pattern: ^1\.1\.\d+$
9+
info:
10+
$ref: "#/$defs/info-object"
11+
extends:
12+
type: string
13+
format: uri-reference
14+
actions:
15+
type: array
16+
minItems: 1
17+
uniqueItems: true
18+
items:
19+
$ref: "#/$defs/action-object"
20+
required:
21+
- overlay
22+
- info
23+
- actions
24+
$ref: "#/$defs/specification-extensions"
25+
unevaluatedProperties: false
26+
$defs:
27+
info-object:
28+
type: object
29+
properties:
30+
title:
31+
type: string
32+
version:
33+
type: string
34+
required:
35+
- title
36+
- version
37+
$ref: "#/$defs/specification-extensions"
38+
unevaluatedProperties: false
39+
action-object:
40+
properties:
41+
target:
42+
type: string
43+
pattern: ^\$
44+
description:
45+
type: string
46+
update:
47+
type:
48+
- string
49+
- boolean
50+
- object
51+
- array
52+
- number
53+
- "null"
54+
remove:
55+
type: boolean
56+
default: false
57+
required:
58+
- target
59+
$ref: "#/$defs/specification-extensions"
60+
unevaluatedProperties: false
61+
specification-extensions:
62+
patternProperties:
63+
^x-: true

scripts/validate.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ const args = process.argv.reduce((acc, arg) => {
3838

3939
const schemaType = args.schema || "schema";
4040
const outputFormat = args.format || defaultOutputFormat;
41+
const version = args.version || "1.0";
4142

4243
// Config
4344
setMetaSchemaOutputFormat(outputFormat);
4445

4546
// Compile / meta-validate
46-
const validateOverlay = await validate(`./schemas/v1.0/${schemaType}.yaml`);
47+
const validateOverlay = await validate(`./schemas/v${version}/${schemaType}.yaml`);
4748

4849
// Validate instance
4950
const instanceYaml = await readFile(`${process.argv[process.argv.length - 1]}`, "utf8");

tests/v1.0/schema.test.mjs renamed to tests/schema.test.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ const parseYamlFromFile = (filePath) => {
88
};
99

1010
function runTestSuite(version, suite) {
11-
const schema = `./schemas/${version}/schema.yaml`;
11+
const schema = `./schemas/v${version}/schema.yaml`;
1212
describe(suite, () => {
13-
readdirSync(`./tests/${version}/${suite}`, { withFileTypes: true })
13+
readdirSync(`./tests/v${version}/${suite}`, { withFileTypes: true })
1414
.filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name))
1515
.forEach((entry) => {
1616
test(entry.name, async () => {
17-
const instance = parseYamlFromFile(`./tests/${version}/${suite}/${entry.name}`);
17+
const instance = parseYamlFromFile(`./tests/v${version}/${suite}/${entry.name}`);
1818
if (suite === "pass") {
1919
await expect(instance).to.matchJsonSchema(schema);
2020
} else {
@@ -25,9 +25,9 @@ function runTestSuite(version, suite) {
2525
});
2626
}
2727

28-
const version = "v1.0";
28+
const versions = ["1.0", "1.1"];
2929

30-
describe(version, () => {
30+
describe.each(versions)("v%s", (version) => {
3131
runTestSuite(version, "pass");
3232
runTestSuite(version, "fail");
3333
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
overlay: 1.1.0
2+
info:
3+
title: Actions invalid description
4+
version: 1.0.0
5+
actions:
6+
- target: '$' # Root of document
7+
description: 10
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
overlay: 1.1.0
2+
info:
3+
title: Invalid `target`, must begin with `$`
4+
version: 1.0.0
5+
actions:
6+
- target: info.description
7+
update: An updated description
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
overlay: 1.1.0
2+
info:
3+
title: Minimal actions
4+
version: 1.0.0
5+
actions: []
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
overlay: 1.1.0
2+
info:
3+
title: Missing actions `target`
4+
version: 1.0.0
5+
actions:
6+
- update: my description
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
overlay: 1.1.0
2+
info:
3+
title: Missing `actions`
4+
version: 1.0.0
5+
extends: '/openapi.yaml'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
overlay: 1.1.0
2+
info:
3+
title: Actions not unique
4+
version: 1.0.0
5+
actions:
6+
- target: '$.info.title'
7+
update: 'My New title'
8+
- target: '$.info.title'
9+
update: 'My New title'

0 commit comments

Comments
 (0)