Skip to content

Commit

Permalink
3.1 Schema: Remove submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesrosiers committed Mar 20, 2021
1 parent b5bf761 commit 1ce46a0
Show file tree
Hide file tree
Showing 18 changed files with 193 additions and 14 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "tests/v3.1/openapi3-examples"]
path = tests/openapi3-examples
url = [email protected]:Mermade/openapi3-examples.git
8 changes: 4 additions & 4 deletions scripts/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ const args = process.argv.reduce((acc, arg) => {

(async function () {
try {
const schemaType = args.schema || "schema";
const schemaVersion = args.version || "2021-03-02";
const outputFormat = args.format || JsonSchema.BASIC;

// Config
JsonSchema.setMetaOutputFormat(outputFormat);
//JsonSchema.setShouldMetaValidate(false);

const schemaType = args.schema || "schema";
const schemaVersion = args.version || "2021-03-02";
const ouputFormat = args.format || JsonSchema.BASIC;

// Load schemas
JsonSchema.add(dialect);
JsonSchema.add(vocabulary);
Expand Down
1 change: 0 additions & 1 deletion tests/openapi3-examples
Submodule openapi3-examples deleted from 9c2997
4 changes: 4 additions & 0 deletions tests/v3.1/fail/no_containers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
iopenapi: 3.1.0
info:
title: API
version: 1.0.0
11 changes: 11 additions & 0 deletions tests/v3.1/fail/sever_enum_empty.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
openapi: 3.1.0
info:
title: API
version: 1.0.0
servers:
- url: https://example.com/{var}
variables:
var:
enum: []
default: a
components: {}
12 changes: 12 additions & 0 deletions tests/v3.1/fail/sever_enum_unknown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
openapi: 3.1.0
info:
title: API
version: 1.0.0
servers:
- url: https://example.com/{var}
variables:
var:
enum:
- a
default: b
components: {}
5 changes: 5 additions & 0 deletions tests/v3.1/fail/unknown_container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
openapi: 3.1.0
info:
title: API
version: 1.0.0
overlays: {}
6 changes: 6 additions & 0 deletions tests/v3.1/pass/comp_pathitems.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
openapi: 3.1.0
info:
title: API
version: 1.0.0
components:
pathItems: {}
6 changes: 6 additions & 0 deletions tests/v3.1/pass/info_summary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
openapi: 3.1.0
info:
title: API
summary: My lovely API
version: 1.0.0
components: {}
9 changes: 9 additions & 0 deletions tests/v3.1/pass/license_identifier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
openapi: 3.1.0
info:
title: API
summary: My lovely API
version: 1.0.0
license:
name: Apache
identifier: Apache-2.0
components: {}
49 changes: 49 additions & 0 deletions tests/v3.1/pass/mega.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
openapi: 3.1.0
info:
summary: My API's summary
title: My API
version: 1.0.0
license:
name: Apache 2.0
identifier: Apache-2.0
jsonSchemaDialect: https://spec.openapis.org/oas/3.1/dialect/base
paths:
/:
get:
parameters: []
/{pathTest}: {}
webhooks:
myWebhook:
$ref: '#/components/pathItems/myPathItem'
description: Overriding description
components:
securitySchemes:
mtls:
type: mutualTLS
pathItems:
myPathItem:
post:
requestBody:
required: true
content:
'application/json':
schema:
type: object
properties:
type:
type: string
int:
type: integer
exclusiveMaximum: 100
exclusiveMinimum: 0
none:
type: 'null'
arr:
type: array
$comment: Array without items keyword
either:
type: ['string','null']
discriminator:
propertyName: type
x-extension: true
myArbitraryKeyword: true
5 changes: 5 additions & 0 deletions tests/v3.1/pass/minimal_comp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
openapi: 3.1.0
info:
title: API
version: 1.0.0
components: {}
5 changes: 5 additions & 0 deletions tests/v3.1/pass/minimal_hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
openapi: 3.1.0
info:
title: API
version: 1.0.0
webhooks: {}
5 changes: 5 additions & 0 deletions tests/v3.1/pass/minimal_paths.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
openapi: 3.1.0
info:
title: API
version: 1.0.0
paths: {}
7 changes: 7 additions & 0 deletions tests/v3.1/pass/path_no_response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
openapi: 3.1.0
info:
title: API
version: 1.0.0
paths:
/:
get: {}
6 changes: 6 additions & 0 deletions tests/v3.1/pass/path_var_empty_pathitem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
openapi: 3.1.0
info:
title: API
version: 1.0.0
paths:
/{var}: {}
55 changes: 55 additions & 0 deletions tests/v3.1/pass/schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
openapi: 3.1.0
info:
title: API
version: 1.0.0
paths: {}
components:
schemas:
model:
type: object
properties:
one:
description: type array
type:
- integer
- string
two:
description: type 'null'
type: "null"
three:
description: type array including 'null'
type:
- string
- "null"
four:
description: array with no items
type: array
five:
description: singular example
type: string
examples:
- exampleValue
six:
description: exclusiveMinimum true
exclusiveMinimum: 10
seven:
description: exclusiveMinimum false
minimum: 10
eight:
description: exclusiveMaximum true
exclusiveMaximum: 20
nine:
description: exclusiveMaximum false
maximum: 20
ten:
description: nullable string
type:
- string
- "null"
eleven:
description: x-nullable string
type:
- string
- "null"
twelve:
description: file/binary
10 changes: 4 additions & 6 deletions tests/v3.1/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const dialect = require("../../schemas/v3.1/dialect/base.schema.json");
const vocabulary = require("../../schemas/v3.1/meta/base.schema.json");


const testSuitePath = `${__dirname}/../openapi3-examples/3.1`;

JsonSchema.setMetaOutputFormat(JsonSchema.BASIC);
//JsonSchema.setShouldMetaValidate(false);

Expand All @@ -20,10 +18,10 @@ before(async () => {
});

describe("Pass", () => {
fs.readdirSync(`${testSuitePath}/pass`, { withFileTypes: true })
fs.readdirSync(`${__dirname}/pass`, { withFileTypes: true })
.filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name))
.forEach((entry) => {
const file = `${testSuitePath}/pass/${entry.name}`;
const file = `${__dirname}/pass/${entry.name}`;

it(entry.name, async () => {
const instance = yaml.parse(fs.readFileSync(file, "utf8"));
Expand All @@ -35,10 +33,10 @@ describe("Pass", () => {
});

describe("Fail", () => {
fs.readdirSync(`${testSuitePath}/fail`, { withFileTypes: true })
fs.readdirSync(`${__dirname}/fail`, { withFileTypes: true })
.filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name))
.forEach((entry) => {
const file = `${testSuitePath}/fail/${entry.name}`;
const file = `${__dirname}/fail/${entry.name}`;

it(entry.name, async () => {
const instance = yaml.parse(fs.readFileSync(file, "utf8"));
Expand Down

0 comments on commit 1ce46a0

Please sign in to comment.