Skip to content

Commit 252fdae

Browse files
committed
Add test cases for valid and invalid top-level schemaObject types
Signed-off-by: Mike Ralphson <[email protected]>
1 parent e4ddc4b commit 252fdae

6 files changed

+32
-2
lines changed

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"url": "https://github.com/OAI/OpenAPI-Specification.git"
1313
},
1414
"license": "Apache-2.0",
15+
"scripts": {
16+
"test": "npx mocha tests/**/test.js"
17+
},
1518
"readmeFilename": "README.md",
1619
"files": [
1720
"README.md",
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
openapi: 3.1.1
2+
3+
# this example shows invalid types for the schemaObject
4+
5+
info:
6+
title: API
7+
version: 1.0.0
8+
components:
9+
schemas:
10+
invalid_null: null
11+
invalid_number: 0
12+
invalid_array: []
13+
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: 3.1.1
2+
3+
# this example shows that top-level schemaObjects MAY be booleans
4+
5+
info:
6+
title: API
7+
version: 1.0.0
8+
components:
9+
schemas:
10+
anything_boolean: true
11+
nothing_boolean: false
12+
anything_object: {}
13+
nothing_object: { not: {} }
14+

tests/v3.1/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ before(async () => {
1717
metaSchema = await JsonSchema.get("https://spec.openapis.org/oas/3.1/schema/2021-03-02");
1818
});
1919

20-
describe("Pass", () => {
20+
describe("v3.1 Pass", () => {
2121
fs.readdirSync(`${__dirname}/pass`, { withFileTypes: true })
2222
.filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name))
2323
.forEach((entry) => {
@@ -32,7 +32,7 @@ describe("Pass", () => {
3232
});
3333
});
3434

35-
describe("Fail", () => {
35+
describe("v3.1 Fail", () => {
3636
fs.readdirSync(`${__dirname}/fail`, { withFileTypes: true })
3737
.filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name))
3838
.forEach((entry) => {

0 commit comments

Comments
 (0)