-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(package.json): bump json-schema-tree version (#246)
- Loading branch information
1 parent
c467ab1
commit ea0ac6f
Showing
6 changed files
with
109 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"allOf": [ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"AAAAA": { "allOf": [{ "description": "AAAAA", "type": "string" }, { "examples": ["AAAAA"] }] }, | ||
"BBBBB": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/paths/~1operation/post/requestBody/content/application~1json/schema/allOf/0/properties/AAAAA/allOf/0", | ||
"description": "BBBBB" | ||
}, | ||
{ "examples": ["BBBBB"] } | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"paths": { | ||
"/operation": { | ||
"post": { | ||
"summary": "operation", | ||
"requestBody": { | ||
"required": true, | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"allOf": [ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"AAAAA": { "allOf": [{ "description": "AAAAA", "type": "string" }, { "examples": ["AAAAA"] }] }, | ||
"BBBBB": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/paths/~1operation/post/requestBody/content/application~1json/schema/allOf/0/properties/AAAAA/allOf/0", | ||
"description": "BBBBB" | ||
}, | ||
{ "examples": ["BBBBB"] } | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"operationId": "operationId", | ||
"security": [] | ||
} | ||
} | ||
}, | ||
"servers": [{ "url": "http://example.com" }], | ||
"openapi": "3.1.0", | ||
"info": { "title": "Test", "version": "version" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { resolveInlineRef } from '@stoplight/json'; | ||
import { Dictionary } from '@stoplight/types'; | ||
|
||
export type ReferenceInfo = { | ||
source: string | null; | ||
pointer: string | null; | ||
}; | ||
|
||
export type ReferenceResolver = (ref: ReferenceInfo, propertyPath: string[] | null, currentObject?: object) => any; | ||
|
||
export const defaultResolver = | ||
(contextObject: object): ReferenceResolver => | ||
({ pointer }, _, currentObject) => { | ||
const activeObject = contextObject ?? currentObject; | ||
|
||
if (pointer === null) { | ||
return null; | ||
} | ||
|
||
if (pointer === '#') { | ||
return activeObject; | ||
} | ||
|
||
const resolved = resolveInlineRef(activeObject as Dictionary<string>, pointer); | ||
|
||
if (resolved) return resolved; | ||
|
||
throw new ReferenceError(`Could not resolve '${pointer}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters