Skip to content

Commit 703acb5

Browse files
committed
3.1 Schema - Extend schema to use OAS base vocabulary
The main schema no longer validates schemas other than verifying that they are either a schema or an object.
1 parent e9e4b4c commit 703acb5

File tree

5 files changed

+54
-3
lines changed

5 files changed

+54
-3
lines changed

schemas/v3.1/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ The iteration version of the JSON Schema can be found in the `$id` field. For
1313
example, the value of `$id: https://spec.openapis.org/oas/3.1/schema/2021-03-02`
1414
means this iteration was created on March 2nd, 2021.
1515

16+
The `schema.yaml` schema doesn't validate the JSON Schemas in your OpenAPI
17+
document because 3.1 allows you to use any JSON Schema dialect you choose. We
18+
have also included `schema-base.yaml` that extends the main schema to validate
19+
that all schemas use the default OAS base vocabulary.
20+
21+
## Contributing
1622
To submit improvements to the schema, modify the schema.yaml file only.
1723

1824
The TSC will then:

schemas/v3.1/schema-base.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$id": "https://spec.openapis.org/oas/3.1/schema-full/2021-03-02",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"$ref": "https://spec.openapis.org/oas/3.1/schema/2021-03-02",
5+
"properties": {
6+
"jsonSchemaDialect": {
7+
"$ref": "#/$defs/dialect"
8+
}
9+
},
10+
"$defs": {
11+
"dialect": {
12+
"const": "https://spec.openapis.org/oas/3.1/dialect/base"
13+
},
14+
"schema": {
15+
"$dynamicAnchor": "meta",
16+
"$ref\"": "https://spec.openapis.org/oas/3.1/dialect/base",
17+
"properties": {
18+
"$schema": {
19+
"$ref": "#/$defs/dialect"
20+
}
21+
}
22+
}
23+
}
24+
}

schemas/v3.1/schema-base.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
$id: 'https://spec.openapis.org/oas/3.1/schema-full/2021-03-02'
2+
$schema: 'https://json-schema.org/draft/2020-12/schema'
3+
4+
$ref: 'https://spec.openapis.org/oas/3.1/schema/2021-03-02'
5+
properties:
6+
jsonSchemaDialect:
7+
$ref: '#/$defs/dialect'
8+
9+
$defs:
10+
dialect:
11+
const: 'https://spec.openapis.org/oas/3.1/dialect/base'
12+
schema:
13+
$dynamicAnchor: meta
14+
$ref": 'https://spec.openapis.org/oas/3.1/dialect/base'
15+
properties:
16+
$schema:
17+
$ref: '#/$defs/dialect'

schemas/v3.1/schema.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ properties:
77
info:
88
$ref: '#/$defs/info'
99
jsonSchemaDialect:
10-
type: string
10+
$ref: '#/$defs/uri'
11+
default: 'https://spec.openapis.org/oas/3.1/dialect/base'
1112
servers:
1213
$ref: '#/$defs/server'
1314
paths:
@@ -681,7 +682,9 @@ $defs:
681682

682683
schema:
683684
$dynamicAnchor: meta
684-
$ref: 'https://spec.openapis.org/oas/3.1/dialect/base'
685+
type:
686+
- object
687+
- boolean
685688

686689
security-scheme:
687690
type: object

schemas/v3.1/test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ before(async () => {
1616
JsonSchema.add(dialect);
1717
JsonSchema.add(vocabulary);
1818
JsonSchema.add(yaml.parse(fs.readFileSync(`${__dirname}/schema.yaml`, "utf8"), { prettyErrors: true }));
19-
metaSchema = await JsonSchema.get("https://spec.openapis.org/oas/3.1/schema/2021-03-02");
19+
JsonSchema.add(yaml.parse(fs.readFileSync(`${__dirname}/schema-base.yaml`, "utf8"), { prettyErrors: true }));
20+
metaSchema = await JsonSchema.get("https://spec.openapis.org/oas/3.1/schema-base/2021-03-02");
2021
});
2122

2223
describe("Pass", () => {

0 commit comments

Comments
 (0)