@stoplight/json-ref-resolver
Advanced tools
Comparing version 3.0.4 to 3.0.5
@@ -0,4 +1,6 @@ | ||
import { Optional } from '@stoplight/types'; | ||
import { DepGraph } from 'dependency-graph'; | ||
import * as Types from './types'; | ||
export declare class ResolveCrawler implements Types.ICrawler { | ||
private _resolved; | ||
readonly resolvers: Array<Promise<Types.IUriResult>>; | ||
@@ -9,5 +11,5 @@ jsonPointer?: string; | ||
private _runner; | ||
constructor(runner: Types.IResolveRunner, jsonPointer?: string); | ||
constructor(runner: Types.IResolveRunner, jsonPointer: Optional<string>, _resolved: Types.IResolveResult); | ||
computeGraph: (target: any, parentPath?: string[], parentPointer?: string, pointerStack?: string[]) => void; | ||
private _resolveRef; | ||
} |
@@ -8,3 +8,4 @@ "use strict"; | ||
class ResolveCrawler { | ||
constructor(runner, jsonPointer) { | ||
constructor(runner, jsonPointer, _resolved) { | ||
this._resolved = _resolved; | ||
this.resolvers = []; | ||
@@ -68,3 +69,17 @@ this.pointerGraph = new dependency_graph_1.DepGraph({ circular: true }); | ||
const targetPointer = Utils.uriToJSONPointer(ref); | ||
const targetPath = json_1.pointerToPath(targetPointer); | ||
let targetPath; | ||
try { | ||
targetPath = json_1.pointerToPath(targetPointer); | ||
} | ||
catch (_a) { | ||
this._resolved.errors.push({ | ||
code: 'PARSE_POINTER', | ||
message: `'${ref}' JSON pointer is invalid`, | ||
uri: this._runner.baseUri, | ||
uriStack: this._runner.uriStack, | ||
pointerStack: [], | ||
path: [], | ||
}); | ||
return; | ||
} | ||
let referencesParent = targetPath.length > 0; | ||
@@ -71,0 +86,0 @@ for (const i in targetPath) { |
{ | ||
"name": "@stoplight/json-ref-resolver", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Recursively resolve JSON pointers and remote authorities.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -254,3 +254,3 @@ "use strict"; | ||
} | ||
const crawler = new crawler_1.ResolveCrawler(this, jsonPointer); | ||
const crawler = new crawler_1.ResolveCrawler(this, jsonPointer, resolved); | ||
crawler.computeGraph(resolved.result, targetPath, jsonPointer || ''); | ||
@@ -257,0 +257,0 @@ let uriResults = []; |
@@ -117,2 +117,3 @@ /// <reference types="urijs" /> | ||
depth: number; | ||
uriStack: string[]; | ||
baseUri: uri.URI; | ||
@@ -119,0 +120,0 @@ graph: DepGraph<IGraphNodeData>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
80445
901