@apidevtools/json-schema-ref-parser
Advanced tools
Comparing version 11.1.0 to 11.1.1
@@ -71,7 +71,7 @@ "use strict"; | ||
for (let i = 0; i < tokens.length; i++) { | ||
if (resolveIf$Ref(this, options)) { | ||
if (resolveIf$Ref(this, options, pathFromRoot)) { | ||
// The $ref path has changed, so append the remaining tokens to the path | ||
this.path = Pointer.join(this.path, tokens.slice(i)); | ||
} | ||
if (typeof this.value === "object" && this.value !== null && "$ref" in this.value) { | ||
if (typeof this.value === "object" && this.value !== null && !isRootPath(pathFromRoot) && "$ref" in this.value) { | ||
return this; | ||
@@ -90,3 +90,3 @@ } | ||
if (!this.value || (this.value.$ref && url.resolve(this.path, this.value.$ref) !== pathFromRoot)) { | ||
resolveIf$Ref(this, options); | ||
resolveIf$Ref(this, options, pathFromRoot); | ||
} | ||
@@ -195,9 +195,10 @@ return this; | ||
* @param options | ||
* @param [pathFromRoot] - the path of place that initiated resolving | ||
* @returns - Returns `true` if the resolution path changed | ||
*/ | ||
function resolveIf$Ref(pointer, options) { | ||
function resolveIf$Ref(pointer, options, pathFromRoot) { | ||
// Is the value a JSON reference? (and allowed?) | ||
if (ref_js_1.default.isAllowed$Ref(pointer.value, options)) { | ||
const $refPath = url.resolve(pointer.path, pointer.value.$ref); | ||
if ($refPath === pointer.path) { | ||
if ($refPath === pointer.path && !isRootPath(pathFromRoot)) { | ||
// The value is a reference to itself, so there's nothing to do. | ||
@@ -260,1 +261,4 @@ pointer.circular = true; | ||
} | ||
function isRootPath(pathFromRoot) { | ||
return typeof pathFromRoot == "string" && Pointer.parse(pathFromRoot).length == 0; | ||
} |
@@ -12,4 +12,4 @@ "use strict"; | ||
} | ||
return filePath.split(path_1.default.win32.sep).join(path_1.default.posix.sep); | ||
return filePath.split(path_1.default?.win32?.sep).join(path_1.default.posix.sep); | ||
} | ||
exports.default = convertPathToPosix; |
@@ -86,3 +86,3 @@ import type $RefParserOptions from "./options.js"; | ||
for (let i = 0; i < tokens.length; i++) { | ||
if (resolveIf$Ref(this, options)) { | ||
if (resolveIf$Ref(this, options, pathFromRoot)) { | ||
// The $ref path has changed, so append the remaining tokens to the path | ||
@@ -92,3 +92,3 @@ this.path = Pointer.join(this.path, tokens.slice(i)); | ||
if (typeof this.value === "object" && this.value !== null && "$ref" in this.value) { | ||
if (typeof this.value === "object" && this.value !== null && !isRootPath(pathFromRoot) && "$ref" in this.value) { | ||
return this; | ||
@@ -108,3 +108,3 @@ } | ||
if (!this.value || (this.value.$ref && url.resolve(this.path, this.value.$ref) !== pathFromRoot)) { | ||
resolveIf$Ref(this, options); | ||
resolveIf$Ref(this, options, pathFromRoot); | ||
} | ||
@@ -230,5 +230,6 @@ | ||
* @param options | ||
* @param [pathFromRoot] - the path of place that initiated resolving | ||
* @returns - Returns `true` if the resolution path changed | ||
*/ | ||
function resolveIf$Ref(pointer: any, options: any) { | ||
function resolveIf$Ref(pointer: any, options: any, pathFromRoot?: any) { | ||
// Is the value a JSON reference? (and allowed?) | ||
@@ -239,3 +240,3 @@ | ||
if ($refPath === pointer.path) { | ||
if ($refPath === pointer.path && !isRootPath(pathFromRoot)) { | ||
// The value is a reference to itself, so there's nothing to do. | ||
@@ -302,1 +303,5 @@ pointer.circular = true; | ||
} | ||
function isRootPath(pathFromRoot: any): boolean { | ||
return typeof pathFromRoot == "string" && Pointer.parse(pathFromRoot).length == 0; | ||
} |
@@ -10,3 +10,3 @@ import path from "path"; | ||
return filePath.split(path.win32.sep).join(path.posix.sep); | ||
return filePath.split(path?.win32?.sep).join(path.posix.sep); | ||
} |
{ | ||
"name": "@apidevtools/json-schema-ref-parser", | ||
"version": "11.1.0", | ||
"version": "11.1.1", | ||
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
# JSON Schema $Ref Parser | ||
_**This package needs [a new maintainer](https://github.com/APIDevTools/json-schema-ref-parser/issues/285) or at least some contributors. For more information [please read this article](https://phil.tech/2022/bundling-openapi-with-javascript/). As of v10.0.0 I am no longer spending any time working on this tool, so I can focus on scaling up my [reforestation charity](https://protect.earth/) instead of burning myself out trying to maintain a whole load of OSS projects I don't use in my vanishingly small spare time. Get in touch if you'd like to take over.** - [Phil Sturgeon](https://github.com/philsturgeon)_ | ||
#### Parse, Resolve, and Dereference JSON Schema $ref pointers | ||
@@ -6,0 +4,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7146
307177
187