Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test): add schema tests #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 99 additions & 3 deletions schemas/v1.0/schema.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,101 @@
$id: https://spec.openapis.org/overlay/1.0/schema/WORK-IN-PROGRESS
$id: https://spec.openapis.org/overlay/1.0/schema/2024-10-17
$schema: https://json-schema.org/draft/2020-12/schema
description: The description of Overlay v1.0.x documents

description: The description of OpenAPI Initiative Overlay v1.0.0 documents
without schema validation, as defined by
https://spec.openapis.org/overlay/v1.0.0
type: object
$comment: https://spec.openapis.org/overlay/v1.0.0#overlay-object
properties:
overlay:
description: The version number of the Overlay Specification
type: string
pattern: ^1\.0\.\d+(-.+)?$
info:
$ref: "#/$defs/info-object"
extends:
type: string
format: uri-reference
actions:
type: array
minItems: 1
uniqueItems: true
items:
$ref: "#/$defs/action-object"
required:
- overlay
- info
- actions
$ref: "#/$defs/specification-extensions"
unevaluatedProperties: false
$defs:
info-object:
$comment: https://spec.openapis.org/overlay/v1.0.0#info-object
description: Provides metadata about the Overlay description
type: object
properties:
title:
description: A human readable title of the Overlay Description
type: string
version:
description: The version identifier of the Overlay document (which is distinct
from the Overlay Specification version)
type: string
required:
- title
- version
$ref: "#/$defs/specification-extensions"
unevaluatedProperties: false
action-object:
$comment: https://spec.openapis.org/overlay/v1.0.0#action-object
description: This object represents one or more changes to be applied to the
target document at the location defined by the target JSONPath expression.
properties:
target:
description: A JSONPath expression selecting nodes in the target document
type: string
pattern: ^\$[.\[]?.*$
description:
description: A description of the action. [[CommonMark]] syntax MAY be used for
rich text representation.
type: string
update:
description: If the target selects an object node, the value of this field
MUST be an object with the properties and values to merge with the
node. If the target selects an array, the value of this field MUST
be an entry to append to the array.
type:
- string
- boolean
- object
- array
- number
- "null"
remove:
description: A boolean value that indicates that the target object is to be
removed from the the map or array it is contained in
type: boolean
default: false
allOf:
- description: The `update` field has no impact if the `remove` field of this
action object is true.
if:
properties:
remove:
const: true
required:
- remove
then:
not:
required:
- update
required:
- target
$ref: "#/$defs/specification-extensions"
unevaluatedProperties: false
specification-extensions:
$comment: https://spec.openapis.org/overlay/v1.0.0#specification-extensions
description: While the Overlay Specification tries to accommodate most use
cases, additional data can be added to extend the specification at certain
points
patternProperties:
^x-: true
7 changes: 7 additions & 0 deletions tests/v1.0/fail/actions-invalid-target.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
overlay: 1.0.0
info:
title: Invalid `target`, must begin with `$`
version: 1.0.0
actions:
- target: info.description
update: An updated description
5 changes: 5 additions & 0 deletions tests/v1.0/fail/actions-minimal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
overlay: 1.0.0
info:
title: Minimal actions
version: 1.0.0
actions: []
6 changes: 6 additions & 0 deletions tests/v1.0/fail/actions-missing-target.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
overlay: 1.0.0
info:
title: Missing actions `target`
version: 1.0.0
actions:
- update: my description
5 changes: 5 additions & 0 deletions tests/v1.0/fail/actions-missing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
overlay: 1.0.0
info:
title: Missing `actions`
version: 1.0.0
extends: '/openapi.yaml'
9 changes: 9 additions & 0 deletions tests/v1.0/fail/actions-no-update-with-remove.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
overlay: 1.0.0
info:
title: No `update` with `remove`
version: 1.0.0
actions:
- target: $.info
update:
description: An updated description
remove: true
9 changes: 9 additions & 0 deletions tests/v1.0/fail/actions-not-unique.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
overlay: 1.0.0
info:
title: Actions not unique
version: 1.0.0
actions:
- target: '$.info.title'
update: 'My New title'
- target: '$.info.title'
update: 'My New title'
6 changes: 6 additions & 0 deletions tests/v1.0/fail/extends-invalid-type.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
overlay: 1.0.0
info:
title: Invalid `extends` type
version: 1.0.0
extends: {}
actions: []
4 changes: 4 additions & 0 deletions tests/v1.0/fail/info-missing-title.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
overlay: 1.0.0
info:
version: 1.0.0
actions: []
4 changes: 4 additions & 0 deletions tests/v1.0/fail/info-missing-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
overlay: 1.0.0
info:
title: Missing Info version
actions: []
5 changes: 5 additions & 0 deletions tests/v1.0/fail/invalid-overlay-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
overlay: 2
info:
title: Invalid Overlay version
version: 1.0.0
actions: []
7 changes: 7 additions & 0 deletions tests/v1.0/pass/actions-extensions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
overlay: 1.0.0
info:
title: Actions Extensions
version: 1.0.0
actions:
- target: '$' # Root of document
x-myActionsExtension: {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ overlay: 1.0.0
info:
title: Structured Overlay
version: 1.0.0
extends: '/openapi.yaml'
actions:
- target: '$' # Root of document
update:
Expand All @@ -18,4 +19,4 @@ actions:
summary: 'Retrieve a list of pets'
x-rate-limit: 100
components:
tags:
tags: []
7 changes: 7 additions & 0 deletions tests/v1.0/pass/info-extensions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
overlay: 1.0.0
info:
title: Info Extensions
version: 1.0.0
x-myInfoExtension: {}
actions:
- target: '$' # Root of document
7 changes: 7 additions & 0 deletions tests/v1.0/pass/root-extensions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
overlay: 1.0.0
info:
title: Root Extensions
version: 1.0.0
actions:
- target: '$' # Root of document
x-myExtension: {}