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.
MODIFY
schemas/v3.1/README.md
schemas/v3.1/README.md
@@ -13,6 +13,12 @@ The iteration version of the JSON Schema can be found in the `$id` field. For
example, the value of `$id: https://spec.openapis.org/oas/3.1/schema/2021-03-02`
means this iteration was created on March 2nd, 2021.
+The `schema.yaml` schema doesn't validate the JSON Schemas in your OpenAPI
+document because 3.1 allows you to use any JSON Schema dialect you choose. We
+have also included `schema-base.yaml` that extends the main schema to validate
+that all schemas use the default OAS base vocabulary.
+
+## Contributing
To submit improvements to the schema, modify the schema.yaml file only.
The TSC will then:

ADD
schemas/v3.1/schema-base.json
+{
+ "$id": "https://spec.openapis.org/oas/3.1/schema-base/2021-03-02",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "https://spec.openapis.org/oas/3.1/schema/2021-03-02",
+ "properties": {
+ "jsonSchemaDialect": {
+ "$ref": "#/$defs/dialect"
+ }
+ },
+ "$defs": {
+ "dialect": {
+ "const": "https://spec.openapis.org/oas/3.1/dialect/base"
+ },
+ "schema": {
+ "$dynamicAnchor": "meta",
+ "$ref\"": "https://spec.openapis.org/oas/3.1/dialect/base",
+ "properties": {
+ "$schema": {
+ "$ref": "#/$defs/dialect"
+ }
+ }
+ }
+ }
+}

ADD
schemas/v3.1/schema-base.yaml
+$id: 'https://spec.openapis.org/oas/3.1/schema-base/2021-03-02'
+$schema: 'https://json-schema.org/draft/2020-12/schema'
+
+$ref: 'https://spec.openapis.org/oas/3.1/schema/2021-03-02'
+properties:
+ jsonSchemaDialect:
+ $ref: '#/$defs/dialect'
+
+$defs:
+ dialect:
+ const: 'https://spec.openapis.org/oas/3.1/dialect/base'
+ schema:
+ $dynamicAnchor: meta
+ $ref": 'https://spec.openapis.org/oas/3.1/dialect/base'
+ properties:
+ $schema:
+ $ref: '#/$defs/dialect'

MODIFY
schemas/v3.1/schema.yaml
schemas/v3.1/schema.yaml
@@ -7,7 +7,8 @@ properties:
info:
$ref: '#/$defs/info'
jsonSchemaDialect:
- type: string
+ $ref: '#/$defs/uri'
+ default: 'https://spec.openapis.org/oas/3.1/dialect/base'
servers:
$ref: '#/$defs/server'
paths:
@@ -681,7 +682,9 @@ $defs:
schema:
$dynamicAnchor: meta
- $ref: 'https://spec.openapis.org/oas/3.1/dialect/base'
+ type:
+ - object
+ - boolean
security-scheme:
type: object

MODIFY
schemas/v3.1/test.js
schemas/v3.1/test.js
@@ -16,7 +16,8 @@ before(async () => {
JsonSchema.add(dialect);
JsonSchema.add(vocabulary);
JsonSchema.add(yaml.parse(fs.readFileSync(`${__dirname}/schema.yaml`, "utf8"), { prettyErrors: true }));
- metaSchema = await JsonSchema.get("https://spec.openapis.org/oas/3.1/schema/2021-03-02");
+ JsonSchema.add(yaml.parse(fs.readFileSync(`${__dirname}/schema-base.yaml`, "utf8"), { prettyErrors: true }));
+ metaSchema = await JsonSchema.get("https://spec.openapis.org/oas/3.1/schema-base/2021-03-02");
});
describe("Pass", () => {

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.