Skip to content

Commit cd4dde2

Browse files
committed
feat(test): add schema tests
1 parent 413fe0d commit cd4dde2

20 files changed

+182
-4
lines changed

schemas/v1.0/schema.yaml

Lines changed: 99 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,101 @@
1-
$id: https://spec.openapis.org/overlay/1.0/schema/WORK-IN-PROGRESS
1+
$id: https://spec.openapis.org/overlay/1.0/schema/2024-10-17
22
$schema: https://json-schema.org/draft/2020-12/schema
3-
description: The description of Overlay v1.0.x documents
4-
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
56
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
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
overlay: 1.0.0
2+
info:
3+
title: Invalid `target`, must begin with `$`
4+
version: 1.0.0
5+
actions:
6+
- target: info.description
7+
update: An updated description
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
overlay: 1.0.0
2+
info:
3+
title: Minimal actions
4+
version: 1.0.0
5+
actions: []
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
overlay: 1.0.0
2+
info:
3+
title: Missing actions `target`
4+
version: 1.0.0
5+
actions:
6+
- update: my description
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
overlay: 1.0.0
2+
info:
3+
title: Missing `actions`
4+
version: 1.0.0
5+
extends: '/openapi.yaml'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
overlay: 1.0.0
2+
info:
3+
title: No `update` with `remove`
4+
version: 1.0.0
5+
actions:
6+
- target: $.info
7+
update:
8+
description: An updated description
9+
remove: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
overlay: 1.0.0
2+
info:
3+
title: Actions not unique
4+
version: 1.0.0
5+
actions:
6+
- target: '$.info.title'
7+
update: 'My New title'
8+
- target: '$.info.title'
9+
update: 'My New title'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
overlay: 1.0.0
2+
info:
3+
title: Invalid `extends` type
4+
version: 1.0.0
5+
extends: {}
6+
actions: []
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
overlay: 1.0.0
2+
info:
3+
version: 1.0.0
4+
actions: []
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
overlay: 1.0.0
2+
info:
3+
title: Missing Info version
4+
actions: []

0 commit comments

Comments
 (0)