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

update the JSON Schema for overlays to match the latest spec #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To use, pipe in an Overlay definition and it'll output the result as YAML.
**Example Overlay**

```yaml
overlays: 1.0.0
overlay: 1.0.0
extends: https://petstore3.swagger.io/api/v3/openapi.json
actions:
- target: '$.paths'
Expand Down
2 changes: 1 addition & 1 deletion overlays-test-suite/v1.0.0/all-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ refs:
two: {}

input:
overlays: 1.0.0
overlay: 1.0.0
extends: http://example.com
actions:
- target: $.*
Expand Down
2 changes: 1 addition & 1 deletion overlays-test-suite/v1.0.0/remove-root.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ refs:
one: 1

input:
overlays: 1.0.0
overlay: 1.0.0
extends: http://example.com
actions:
- target: '$'
Expand Down
2 changes: 1 addition & 1 deletion overlays-test-suite/v1.0.0/where-empty-false.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ refs:
/string: 'foo'

input:
overlays: 1.0.0
overlay: 1.0.0
extends: http://example.com
actions:
- target: $.paths.*
Expand Down
2 changes: 1 addition & 1 deletion overlays-test-suite/v1.0.0/where-empty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ refs:
/string: 'foo'

input:
overlays: 1.0.0
overlay: 1.0.0
extends: http://example.com
actions:
- target: $.paths.*
Expand Down
2 changes: 1 addition & 1 deletion overlays-test-suite/v1.0.0/where-not-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ refs:
bar: true

input:
overlays: 1.0.0
overlay: 1.0.0
extends: http://example.com
actions:
- target: $.*
Expand Down
2 changes: 1 addition & 1 deletion overlays-test-suite/v1.0.0/where-not.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ refs:
bar: true

input:
overlays: 1.0.0
overlay: 1.0.0
extends: http://example.com
actions:
- target: $.*
Expand Down
2 changes: 1 addition & 1 deletion overlays-test-suite/v1.0.0/where-target-not.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ refs:
bar: true

input:
overlays: 1.0.0
overlay: 1.0.0
extends: http://example.com
actions:
- target: '$.*'
Expand Down
2 changes: 1 addition & 1 deletion overlays-test-suite/v1.0.0/where.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ refs:
bar: true

input:
overlays: 1.0.0
overlay: 1.0.0
extends: http://example.com
actions:
- target: $.*
Expand Down
58 changes: 43 additions & 15 deletions overlays.schema.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,61 @@
{
"$id": "https://github.com/OAI/Overlay-Specification/blob/main/versions/1.0.0.md",
"required": ["overlays", "actions"],
"required": ["overlay", "info", "actions"],
"type": "object",
"properties": {
"overlays": {
"overlay": {
"type": "string",
"description": "Version of the specification",
"const": "1.0.0"
},
"extends": {
"type": "string"
},
"info": {
"required": ["title", "version"],
"type": "object",
"properties": {
"title": {
"type": "string"
},
"version": {
"type": "string"
}
},
"patternProperties": {
"^x-": true
},
"additionalProperties": false
},
"actions": {
"type": "array",
"description": "List of actions to take",
"minItems": 1,
"items": {
"type": "object",
"required": ["target"],
"properties": {
"target": {
"type": "string"
},
"remove": {
"type": "boolean",
"const": true
},
"update": true
}
"type": "object",
"required": ["target"],
"properties": {
"target": {
"type": "string"
},
"description": {
"type": "string"
},
"remove": {
"type": "boolean",
"default": false
},
"update": true
},
"patternProperties": {
"^x-": true
},
"additionalProperties": false
}
}
}
},
"patternProperties": {
"^x-": true
},
"additionalProperties": false
}
2 changes: 1 addition & 1 deletion samples/apply-403-to-security.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
overlays: 1.0.0
overlay: 1.0.0
extends: https://petstore3.swagger.io/api/v3/openapi.json
actions:
- target: '$.paths.*[?(@.security)].responses'
Expand Down
2 changes: 1 addition & 1 deletion samples/basic.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
overlays: 1.0.0
overlay: 1.0.0
extends: https://petstore3.swagger.io/api/v3/openapi.json
actions:
- target: '$.paths'
Expand Down
2 changes: 1 addition & 1 deletion samples/only-user-tag.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
overlays: 1.0.0
overlay: 1.0.0
extends: https://petstore3.swagger.io/api/v3/openapi.json
actions:
- target: '$.paths.*'
Expand Down
2 changes: 1 addition & 1 deletion samples/update-get-pets.overlay.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
overlays: 1.0.0
overlay: 1.0.0
extends: https://petstore.swagger.io/v2/swagger.json
actions:
- target: '$.paths."/pet/{petId}".get'
Expand Down
2 changes: 1 addition & 1 deletion samples/x-internal.overlay.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
overlays: 1.0.0
overlay: 1.0.0
extends: ./x-internal.source.yml
actions:
- target: '$..[?(@["x-internal"])]'
Expand Down
2 changes: 1 addition & 1 deletion split-into-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const jsonPointerToJsonPath = require('./json-pointer-to-json-path')
const get = require('./get')

module.exports = function splitIntoOverlay(input, {targets=[], fields=[], where=[]} = {}) {
let overlay = {overlays: '1.0.0'}
let overlay = {overlay: '1.0.0'}
targets = Array.isArray(targets) ? targets : [targets]
where = Array.isArray(where) ? where : [where]
if(!targets.length)
Expand Down
12 changes: 6 additions & 6 deletions split-into-overlay.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('splitIntoOverlay', () => {
it('create an empty overlay definition by default', async () => {
const overlay = splitIntoOverlay({})
expect(overlay).toEqual({
overlays: '1.0.0'
overlay: '1.0.0'
})
})

Expand All @@ -17,7 +17,7 @@ describe('splitIntoOverlay', () => {
}
const overlay = splitIntoOverlay(input, {targets: '$.*'})
expect(overlay).toEqual({
overlays: '1.0.0',
overlay: '1.0.0',
actions: [{
target: '$["one"]',
update: {}
Expand All @@ -39,7 +39,7 @@ describe('splitIntoOverlay', () => {
}
const overlay = splitIntoOverlay(input, {targets: ['$.one', '$.two']})
expect(overlay).toEqual({
overlays: '1.0.0',
overlay: '1.0.0',
actions: [{
target: '$["one"]',
update: 1
Expand All @@ -60,7 +60,7 @@ describe('splitIntoOverlay', () => {
}
const overlay = splitIntoOverlay(input, {targets: '$.*'})
expect(overlay).toEqual({
overlays: '1.0.0',
overlay: '1.0.0',
actions: [
{
target: '$["one"]',
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('splitIntoOverlay', () => {
fields: ['description', 'summary'],
})
expect(overlay).toEqual({
overlays: '1.0.0',
overlay: '1.0.0',
actions: [{
target: '$["paths"]["/foo"]["get"]',
update: {
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('splitIntoOverlay', () => {
})

expect(overlay).toEqual({
overlays: '1.0.0',
overlay: '1.0.0',
actions: [{
target: '$["paths"]["/foo"]["get"]',
update: {
Expand Down