Skip to content

Commit 851a6d1

Browse files
authored
Add a GitHub workflow to run the metaschema tests (incl. boolean schemas) (#2614)
* Add test cases for valid and invalid top-level schemaObject types Signed-off-by: Mike Ralphson <[email protected]> * Update workflow actions to node 14 Signed-off-by: Mike Ralphson <[email protected]>
1 parent fe41bac commit 851a6d1

File tree

6 files changed

+64
-3
lines changed

6 files changed

+64
-3
lines changed

.github/workflows/schema-tests.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: schema-test
2+
3+
# Author: @MikeRalphson / runs @jdesrosiers tests
4+
# Issue: https://github.com/OAI/OpenAPI-Specification/pull/2489
5+
6+
#
7+
# This workflow runs the npm test script to validate passing and failing
8+
# testcases for the metaschema.
9+
#
10+
11+
# run this on push to any branch and creation of pull-requests
12+
on:
13+
push: {}
14+
pull_request: {}
15+
workflow_dispatch: {}
16+
17+
jobs:
18+
test:
19+
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v1 # checkout repo content
24+
- uses: actions/setup-node@v1 # setup Node.js
25+
with:
26+
node-version: '14.x'
27+
- name: Install dependencies
28+
run: npm i
29+
- name: Run tests
30+
run: npm run test
31+

.github/workflows/validate-markdown.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions/checkout@v2 # checkout repo content
2222
- uses: actions/setup-node@v1 # setup Node.js
2323
with:
24-
node-version: '12.x'
24+
node-version: '14.x'
2525
- name: Validate markdown
2626
run: npx mdv versions/3.*.md
2727

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-05-20");
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)