Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/schema-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: schema-test

# Author: @MikeRalphson / runs @jdesrosiers tests
# Issue: https://github.com/OAI/OpenAPI-Specification/pull/2489

#
# This workflow runs the npm test script to validate passing and failing
# testcases for the metaschema.
#

# run this on push to any branch and creation of pull-requests
on:
push: {}
pull_request: {}
workflow_dispatch: {}

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1 # checkout repo content
- uses: actions/setup-node@v1 # setup Node.js
with:
node-version: '14.x'
- name: Install dependencies
run: npm i
- name: Run tests
run: npm run test

2 changes: 1 addition & 1 deletion .github/workflows/validate-markdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v2 # checkout repo content
- uses: actions/setup-node@v1 # setup Node.js
with:
node-version: '12.x'
node-version: '14.x'
- name: Validate markdown
run: npx mdv versions/3.*.md

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"url": "https://github.com/OAI/OpenAPI-Specification.git"
},
"license": "Apache-2.0",
"scripts": {
"test": "npx mocha tests/**/test.js"
},
"readmeFilename": "README.md",
"files": [
"README.md",
Expand Down
13 changes: 13 additions & 0 deletions tests/v3.1/fail/invalid_schema_types.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
openapi: 3.1.1

# this example shows invalid types for the schemaObject

info:
title: API
version: 1.0.0
components:
schemas:
invalid_null: null
invalid_number: 0
invalid_array: []

14 changes: 14 additions & 0 deletions tests/v3.1/pass/valid_schema_types.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
openapi: 3.1.1

# this example shows that top-level schemaObjects MAY be booleans

info:
title: API
version: 1.0.0
components:
schemas:
anything_boolean: true
nothing_boolean: false
anything_object: {}
nothing_object: { not: {} }

4 changes: 2 additions & 2 deletions tests/v3.1/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ before(async () => {
metaSchema = await JsonSchema.get("https://spec.openapis.org/oas/3.1/schema/2021-05-20");
});

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

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