Skip to content

Commit cc25d27

Browse files
authored
Merge pull request #4146 from handrews/schema-ids
schemas: add WORK-IN-PROGRESS placeholders, don't mention patch numbers, update terminology
2 parents 69d8b79 + 520a7c3 commit cc25d27

File tree

7 files changed

+71
-45
lines changed

7 files changed

+71
-45
lines changed

schemas/v3.0/README.md

+23-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
# OpenAPI 3.0.X JSON Schema
22

3-
Here you can find the JSON Schema for validating OpenAPI definitions of versions 3.0.x.
3+
This directory contains the YAML source for generating the JSON Schema for validating OpenAPI definitions of versions 3.0.X, which is published on [https://spec.openapis.org](https://spec.openapis.org).
44

5-
As a reminder, the JSON Schema is not the source of truth for the Specification.
6-
In cases of conflicts between the Specification itself and the JSON Schema, the
7-
Specification wins. Also, some Specification constraints cannot be represented
8-
with the JSON Schema so it's highly recommended to employ other methods to
9-
ensure compliance.
5+
Due to limitations of GitHub pages, the schemas on the spec site are served with `Content-Type: application/octet-stream`, but should be interpreted as `application/schema+json`.
6+
7+
The source in this directory, which has `WORK-IN-PROGRESS` in its `id`, is _not intended for direct use_.
8+
9+
## Schema `id` dates
10+
11+
The published schemas on the spec site have an _iteration date_ in their `id`s.
12+
This allows the schemas for a release line (in this case 3.0) to be updated independent of the spec patch release cycle.
1013

1114
The iteration version of the JSON Schema can be found in the `id` field.
1215
For example, the value of `id: https://spec.openapis.org/oas/3.0/schema/2019-04-02` means this iteration was created on April 2nd, 2019.
1316

14-
## Contributing
17+
We are [working on](https://github.com/OAI/OpenAPI-Specification/issues/4152) how to best provide programmatic access for determining the latest date for each schema.
18+
19+
## Improving the schema
1520

16-
To submit improvements to the schema, modify the `schema.yaml` and add test cases for your changes.
21+
As a reminder, the JSON Schema is not the source of truth for the Specification.
22+
In cases of conflicts between the Specification itself and the JSON Schema, the Specification wins.
23+
Also, some Specification constraints cannot be represented with the JSON Schema so it's highly recommended to employ other methods to ensure compliance.
24+
25+
The schema only validates the mandatory aspects of the OAS.
26+
Validating requirements that are optional, or field usage that has undefined or ignored behavior are not within the scope of this schema.
27+
Schemas to perform additional optional validation are [under consideration](https://github.com/OAI/OpenAPI-Specification/issues/4141).
28+
29+
Improvements can be submitted by opening a PR against the `main` branch.
30+
31+
Modify the `schema.yaml` file and add test cases for your changes.
1732

1833
The TSC will then:
1934
- Run tests on the updated schema
2035
- Update the iteration version
2136
- Publish the new version
2237

23-
## Tests
24-
2538
The [test suite](../../tests/v3.0) is part of this package.
2639

2740
```bash

schemas/v3.0/schema.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
id: https://spec.openapis.org/oas/3.0/schema/2021-09-28
1+
id: https://spec.openapis.org/oas/3.0/schema/WORK-IN-PROGRESS
22
$schema: http://json-schema.org/draft-04/schema#
3-
description: The description of OpenAPI v3.0.x documents, as defined by https://spec.openapis.org/oas/v3.0.3
3+
description: The description of OpenAPI v3.0.x Documents
44
type: object
55
required:
66
- openapi

schemas/v3.1/README.md

+33-20
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,54 @@
11
# OpenAPI 3.1.X JSON Schema
22

3-
Here you can find the JSON Schema for validating OpenAPI definitions of versions 3.1.x.
3+
This directory contains the YAML sources for generating the JSON Schemas for validating OpenAPI definitions of versions 3.1.X, which are published on [https://spec.openapis.org](https://spec.openapis.org).
44

5-
As a reminder, the JSON Schema is not the source of truth for the Specification.
6-
In cases of conflicts between the Specification itself and the JSON Schema, the
7-
Specification wins. Also, some Specification constraints cannot be represented
8-
with the JSON Schema so it's highly recommended to employ other methods to
9-
ensure compliance.
5+
Due to limitations of GitHub pages, the schemas on the spec site are served with `Content-Type: application/octet-stream`, but should be interpreted as `application/schema+json`.
6+
7+
The sources in this directory, which have `WORK-IN-PROGRESS` in their `$id`s, is _not intended for direct use_.
8+
9+
## Choosing which schema to use
10+
11+
There are two schemas to choose from for 3.1 usage, both of which have an `$id` that starts with `https://spec.openapis.org/oas/3.1/` and end with date or the `WORK-IN-PROGRESS` placeholder:
12+
13+
* `https://spec.openapis.org/oas/3.1/schema/{date}` — A self-contained schema that _does not_ validate Schema Objects beyond `type: [object, boolean]`
14+
* `https://spec.openapis.org/oas/3.1/meta/base/{date}` — The vocabulary metaschema for OAS 3.1's extensions to draft 2020-12
15+
* `https://spec.openapis.org/oas/3.1/dialect/base/{date}` — The dialect metaschema that extends the standard `draft/2020-12` metaschema by adding the OAS "base" vocabulary
16+
* `https://spec.openapis.org/oas/3.1/schema-base/{date}` — A schema that combines the self-contained schema and the "base" dialect schema to validate Schema Objects with the dialect; this schema does not allow changing `$schema` or `jsonSchemaDialect` to other dialects
17+
18+
The name "base" for the dialect was intended to indicate that the OAS dialect could be further extended.
19+
20+
An additional schema that validates the Schema Object with the OAS 3.1 dialect but does not restrict changing `$schema` is [under consideration](https://github.com/OAI/OpenAPI-Specification/issues/4147).
21+
22+
## Schema `$id` dates
23+
24+
The published schemas on the spec site have an _iteration date_ in their `id`s.
25+
This allows the schemas for a release line (in this case 3.0) to be updated independent of the spec patch release cycle.
1026

1127
The iteration version of the JSON Schema can be found in the `$id` field.
1228
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.
1329

14-
The `schema.yaml` schema doesn't validate the JSON Schemas in your OpenAPI
15-
document because 3.1 allows you to use any JSON Schema dialect you choose. We
16-
have also included `schema-base.yaml` that extends the main schema to validate
17-
that all schemas use the default OAS base vocabulary.
30+
We are [working on](https://github.com/OAI/OpenAPI-Specification/issues/4152) how to best provide programmatic access for determining the latest date for each schema.
1831

19-
## Contributing
32+
## Improving the schemas
2033

21-
To submit improvements to the schema, modify the `schema.yaml` and add test cases for your changes.
34+
As a reminder, the JSON Schema is not the source of truth for the Specification. In cases of conflicts between the Specification itself and the JSON Schema, the Specification wins. Also, some Specification constraints cannot be represented with the JSON Schema so it's highly recommended to employ other methods to ensure compliance.
35+
36+
The schema only validates the mandatory aspects of the OAS.
37+
Validating requirements that are optional, or field usage that has undefined or ignored behavior are not within the scope of this schema.
38+
Schemas to perform additional optional validation are [under consideration](https://github.com/OAI/OpenAPI-Specification/issues/4141).
39+
40+
Improvements can be submitted by opening a PR against the `main` branch.
41+
42+
Modify the `*schema*.yaml` files and add test cases for your changes.
2243

2344
The TSC will then:
2445
- Run tests on the updated schema
2546
- Update the iteration version
2647
- Publish the new version
2748

28-
## Tests
29-
3049
The [test suite](../../tests/v3.1) is part of this package.
3150

3251
```bash
3352
npm install
3453
npm test
3554
```
36-
37-
You can also validate a document individually.
38-
39-
```bash
40-
node scripts/validate.mjs path/to/document/to/validate.yaml
41-
```

schemas/v3.1/dialect/base.schema.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
$id: https://spec.openapis.org/oas/3.1/dialect/base
1+
$id: https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS
22
$schema: https://json-schema.org/draft/2020-12/schema
33

44
title: OpenAPI 3.1 Schema Object Dialect
5-
description: A JSON Schema dialect describing schemas found in OpenAPI documents
5+
description: A JSON Schema dialect describing schemas found in OpenAPI v3.1 Descriptions
66

77
$dynamicAnchor: meta
88

@@ -18,4 +18,4 @@ $vocabulary:
1818

1919
allOf:
2020
- $ref: https://json-schema.org/draft/2020-12/schema
21-
- $ref: https://spec.openapis.org/oas/3.1/meta/base
21+
- $ref: https://spec.openapis.org/oas/3.1/meta/WORK-IN-PROGRESS

schemas/v3.1/meta/base.schema.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
$id: https://spec.openapis.org/oas/3.1/meta/base
1+
$id: https://spec.openapis.org/oas/3.1/meta/WORK-IN-PROGRESS
22
$schema: https://json-schema.org/draft/2020-12/schema
33

4-
title: OAS Base vocabulary
4+
title: OAS Base Vocabulary
55
description: A JSON Schema Vocabulary used in the OpenAPI Schema Dialect
66

77
$dynamicAnchor: meta

schemas/v3.1/schema-base.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
$id: 'https://spec.openapis.org/oas/3.1/schema-base/2022-10-07'
1+
$id: 'https://spec.openapis.org/oas/3.1/schema-base/WORK-IN-PROGRESS'
22
$schema: 'https://json-schema.org/draft/2020-12/schema'
33

4-
description: The description of OpenAPI v3.1.x documents using the OpenAPI JSON Schema dialect, as defined by https://spec.openapis.org/oas/v3.1.0
4+
description: The description of OpenAPI v3.1.x Documents using the OpenAPI JSON Schema dialect
55

6-
$ref: 'https://spec.openapis.org/oas/3.1/schema/2022-10-07'
6+
$ref: 'https://spec.openapis.org/oas/3.1/schema/WORK-IN-PROGRESS'
77
properties:
88
jsonSchemaDialect:
99
$ref: '#/$defs/dialect'
1010

1111
$defs:
1212
dialect:
13-
const: 'https://spec.openapis.org/oas/3.1/dialect/base'
13+
const: 'https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS'
1414

1515
schema:
1616
$dynamicAnchor: meta
17-
$ref: 'https://spec.openapis.org/oas/3.1/dialect/base'
17+
$ref: 'https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS'
1818
properties:
1919
$schema:
2020
$ref: '#/$defs/dialect'

schemas/v3.1/schema.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
$id: 'https://spec.openapis.org/oas/3.1/schema/2022-10-07'
1+
$id: 'https://spec.openapis.org/oas/3.1/schema/WORK-IN-PROGRESS'
22
$schema: 'https://json-schema.org/draft/2020-12/schema'
33

4-
description: The description of OpenAPI v3.1.x documents without schema validation, as defined by https://spec.openapis.org/oas/v3.1.0
4+
description: The description of OpenAPI v3.1.x Documents without Schema Object validation
55

66
type: object
77
properties:
@@ -13,7 +13,7 @@ properties:
1313
jsonSchemaDialect:
1414
type: string
1515
format: uri
16-
default: 'https://spec.openapis.org/oas/3.1/dialect/base'
16+
default: 'https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS'
1717
servers:
1818
type: array
1919
items:

0 commit comments

Comments
 (0)