Skip to content

Commit f7ef3c9

Browse files
committed
Add schemas for 3.1
1 parent 42a9e3d commit f7ef3c9

File tree

10 files changed

+2457
-0
lines changed

10 files changed

+2457
-0
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "schemas/v3.1/openapi3-examples"]
2+
path = schemas/v3.1/openapi3-examples
3+
url = [email protected]:Mermade/openapi3-examples.git

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
],
2020
"dependencies": {},
2121
"devDependencies": {
22+
"@hyperjump/json-schema": "^0.17.0",
23+
"chai": "^4.3.1",
2224
"mdv": "^1.0.7",
25+
"mocha": "^8.3.0",
2326
"yaml": "^1.8.3"
2427
},
2528
"keywords": [

schemas/v3.1/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# OpenAPI 3.1.X JSON Schema
2+
3+
Here you can find the JSON Schema for validating OpenAPI definitions of versions
4+
3.1.X.
5+
6+
As a reminder, the JSON Schema is not the source of truth for the Specification.
7+
In cases of conflicts between the Specification itself and the JSON Schema, the
8+
Specification wins. Also, some Specification constraints cannot be represented
9+
with the JSON Schema so it's highly recommended to employ other methods to
10+
ensure compliance.
11+
12+
The iteration version of the JSON Schema can be found in the `$id` field. For
13+
example, the value of `$id: https://spec.openapis.org/oas/3.1/schema/2021-03-02`
14+
means this iteration was created on March 2nd, 2021.
15+
16+
To submit improvements to the schema, modify the schema.yaml file only.
17+
18+
The TSC will then:
19+
- Run tests on the updated schema
20+
- Update the iteration version
21+
- Convert the schema.yaml to schema.json
22+
- Publish the new version
23+
24+
## Tests
25+
The test suite is included as a git submodule of https://github.com/Mermade/openapi3-examples.
26+
27+
```bash
28+
npx mocha test.js
29+
```
30+
31+
You can also validate a document individually.
32+
33+
```bash
34+
node validate.js path/to/document/to/validate.yaml
35+
```

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

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$id": "https://spec.openapis.org/oas/3.1/dialect/base",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"$vocabulary": {
5+
"https://json-schema.org/draft/2020-12/vocab/core": true,
6+
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
7+
"https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
8+
"https://json-schema.org/draft/2020-12/vocab/validation": true,
9+
"https://json-schema.org/draft/2020-12/vocab/meta-data": true,
10+
"https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
11+
"https://json-schema.org/draft/2020-12/vocab/content": true,
12+
"https://spec.openapis.org/oas/3.1/vocab/base": false
13+
},
14+
"$dynamicAnchor": "meta",
15+
16+
"title": "OpenAPI 3.1 Schema Object Dialect",
17+
"allOf": [
18+
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" },
19+
{ "$ref": "https://json-schema.org/draft/2020-12/meta/applicator" },
20+
{ "$ref": "https://json-schema.org/draft/2020-12/meta/unevaluated" },
21+
{ "$ref": "https://json-schema.org/draft/2020-12/meta/validation" },
22+
{ "$ref": "https://json-schema.org/draft/2020-12/meta/meta-data" },
23+
{ "$ref": "https://json-schema.org/draft/2020-12/meta/format-annotation" },
24+
{ "$ref": "https://json-schema.org/draft/2020-12/meta/content" },
25+
{ "$ref": "https://spec.openapis.org/oas/3.1/meta/base" }
26+
]
27+
}

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

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"$id": "https://spec.openapis.org/oas/3.1/meta/base",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"$vocabulary": {
5+
"https://spec.openapis.org/oas/3.1/vocab/base": true
6+
},
7+
"$dynamicAnchor": "meta",
8+
"title": "OAS Base vocabulary",
9+
10+
"type": ["object", "boolean"],
11+
"properties": {
12+
"example": true,
13+
"discriminator": { "$ref": "#/$defs/Discriminator" },
14+
"externalDocs": { "$ref": "#/$defs/ExternalDocs" },
15+
"xml": { "$ref": "#/$defs/Xml" }
16+
},
17+
"$defs": {
18+
"Extensible": {
19+
"patternProperties": {
20+
"^x-": true
21+
}
22+
},
23+
"Discriminator": {
24+
"$ref": "#/$defs/Extensible",
25+
"type": "object",
26+
"properties": {
27+
"propertyName": {
28+
"type": "string"
29+
},
30+
"mapping": {
31+
"type": "object",
32+
"additionalProperties": {
33+
"type": "string"
34+
}
35+
}
36+
},
37+
"required": ["propertyName"],
38+
"unevaluatedProperties": false
39+
},
40+
"ExternalDocs": {
41+
"$ref": "#/$defs/Extensible",
42+
"type": "object",
43+
"properties": {
44+
"url": {
45+
"type": "string",
46+
"format": "uri-reference"
47+
},
48+
"description": {
49+
"type": "string"
50+
}
51+
},
52+
"required": ["url"],
53+
"unevaluatedProperties": false
54+
},
55+
"Xml": {
56+
"$ref": "#/$defs/Extensible",
57+
"type": "object",
58+
"properties": {
59+
"name": {
60+
"type": "string"
61+
},
62+
"namespace": {
63+
"type": "string",
64+
"format": "uri"
65+
},
66+
"prefix": {
67+
"type": "string"
68+
},
69+
"attribute": {
70+
"type": "boolean"
71+
},
72+
"wrapped": {
73+
"type": "boolean"
74+
}
75+
},
76+
"unevaluatedProperties": false
77+
}
78+
}
79+
}

schemas/v3.1/openapi3-examples

Submodule openapi3-examples added at 9c2997e

0 commit comments

Comments
 (0)