Skip to content

Commit 5c0aa8b

Browse files
committed
static coverage of schema.yaml
1 parent 71b1007 commit 5c0aa8b

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

tests/schema/schema.test.mjs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,45 @@ await registerOasSchema();
1313
await registerSchema("./src/schemas/validation/schema.yaml");
1414
const fixtures = './tests/schema';
1515

16-
describe("v3.1", () => {
16+
describe("v3.2", () => {
17+
test("schema.yaml schema test", async () => {
18+
// Hardcode this simple document instead of putting it in pass/fail directories because
19+
// documents in those folders get run against schema-base.yaml instead of schema.yaml.
20+
const oad = {
21+
// Also need to include required properties
22+
openapi: "3.2.0",
23+
info: {
24+
title: "API",
25+
version: "1.0.0"
26+
},
27+
components: {
28+
schemas: {
29+
foo: {}
30+
}
31+
}
32+
};
33+
await expect(oad).to.matchJsonSchema("./src/schemas/validation/schema.yaml"); // <-- "schema.yaml" instead of "schema-base.yaml"
34+
});
35+
36+
test("schema.yaml invalid Schema Object type", async () => {
37+
// Hardcode this simple document instead of putting it in pass/fail directories because
38+
// documents in those folders get run against schema-base.yaml instead of schema.yaml.
39+
const oad = {
40+
// Also need to include required properties
41+
openapi: "3.2.0",
42+
info: {
43+
title: "API",
44+
version: "1.0.0"
45+
},
46+
components: {
47+
schemas: {
48+
foo: 42
49+
}
50+
}
51+
};
52+
await expect(oad).to.not.matchJsonSchema("./src/schemas/validation/schema.yaml"); // <-- "schema.yaml" instead of "schema-base.yaml"
53+
});
54+
1755
describe("Pass", () => {
1856
readdirSync(`${fixtures}/pass`, { withFileTypes: true })
1957
.filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name))

0 commit comments

Comments
 (0)