Skip to content

Commit 3539656

Browse files
committed
feat(schemas): add JSON Schema 2020-12 schemas to repo
* add constraint for `update` scenario' -m 'rename version folder' * update `$id` with the official release date * add `$comment` for each section * add schema readme.md * remove .json file as it's auto-generated by the build * revise target regex pattern * update schema readme closes #71
1 parent d029f0d commit 3539656

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

schemas/v1.0/readme.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# OpenAPI Overlay 1.0.x JSON Schema
2+
3+
Here you can find the JSON Schema for validating OpenAPI Overlay description of versions 1.0.x.
4+
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.
10+
11+
The iteration version of the JSON Schema can be found in the `$id` field.
12+
For example, the value of `$id: https://spec.openapis.org/overlay/1.0/schema/2024-10-17` means this iteration was created on October 17, 2024.
13+
14+
## Contributing
15+
16+
To submit improvements to the schema, modify the `schema.yaml` and add test cases for your changes.
17+
18+
The TSC will then:
19+
- Run tests on the updated schema
20+
- Update the iteration version
21+
- Publish the new version
22+
23+
## Tests
24+
25+
The [test suite](../../tests/v1.0) is part of this package.
26+
27+
```bash
28+
npm install
29+
npm test
30+
```
31+
32+
You can also validate a document individually.
33+
34+
```bash
35+
node scripts/validate.mjs path/to/document/to/validate.yaml
36+
```

schemas/v1.0/schema.yaml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
$id: https://spec.openapis.org/overlay/1.0/schema/2024-10-17
2+
$schema: https://json-schema.org/draft/2020-12/schema
3+
description: The description of OpenAPI Initiative Overlay v1.0.0 documents
4+
without schema validation, as defined by
5+
https://spec.openapis.org/overlay/v1.0.0
6+
type: object
7+
$comment: https://spec.openapis.org/overlay/v1.0.0#overlay-object
8+
properties:
9+
overlay:
10+
description: The version number of the Overlay Specification
11+
type: string
12+
pattern: ^1\.0\.\d+(-.+)?$
13+
info:
14+
$ref: "#/$defs/info-object"
15+
extends:
16+
type: string
17+
format: uri-reference
18+
actions:
19+
type: array
20+
minItems: 1
21+
uniqueItems: true
22+
items:
23+
$ref: "#/$defs/action-object"
24+
required:
25+
- overlay
26+
- info
27+
- actions
28+
$ref: "#/$defs/specification-extensions"
29+
unevaluatedProperties: false
30+
$defs:
31+
info-object:
32+
$comment: https://spec.openapis.org/overlay/v1.0.0#info-object
33+
description: Provides metadata about the Overlay description
34+
type: object
35+
properties:
36+
title:
37+
description: A human readable title of the Overlay Description
38+
type: string
39+
version:
40+
description: The version identifier of the Overlay document (which is distinct
41+
from the Overlay Specification version)
42+
type: string
43+
required:
44+
- title
45+
- version
46+
$ref: "#/$defs/specification-extensions"
47+
unevaluatedProperties: false
48+
action-object:
49+
$comment: https://spec.openapis.org/overlay/v1.0.0#action-object
50+
description: This object represents one or more changes to be applied to the
51+
target document at the location defined by the target JSONPath expression.
52+
properties:
53+
target:
54+
description: A JSONPath expression selecting nodes in the target document
55+
type: string
56+
pattern: ^\$[.\[]?.*$
57+
description:
58+
description: A description of the action. [[CommonMark]] syntax MAY be used for
59+
rich text representation.
60+
type: string
61+
update:
62+
description: If the target selects an object node, the value of this field
63+
MUST be an object with the properties and values to merge with the
64+
node. If the target selects an array, the value of this field MUST
65+
be an entry to append to the array.
66+
type:
67+
- string
68+
- boolean
69+
- object
70+
- array
71+
- number
72+
- "null"
73+
remove:
74+
description: A boolean value that indicates that the target object is to be
75+
removed from the the map or array it is contained in
76+
type: boolean
77+
default: false
78+
allOf:
79+
- description: The `update` field has no impact if the `remove` field of this
80+
action object is true.
81+
if:
82+
properties:
83+
remove:
84+
const: true
85+
required:
86+
- remove
87+
then:
88+
not:
89+
required:
90+
- update
91+
required:
92+
- target
93+
$ref: "#/$defs/specification-extensions"
94+
unevaluatedProperties: false
95+
specification-extensions:
96+
$comment: https://spec.openapis.org/overlay/v1.0.0#specification-extensions
97+
description: While the Overlay Specification tries to accommodate most use
98+
cases, additional data can be added to extend the specification at certain
99+
points
100+
patternProperties:
101+
^x-: true

0 commit comments

Comments
 (0)