You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@apidevtools/json-schema-ref-parser

Package Overview
Dependencies
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apidevtools/json-schema-ref-parser - npm Package Compare versions

Comparing version

to
14.1.0

7

dist/lib/bundle.js

@@ -72,3 +72,5 @@ "use strict";

const obj = key === null ? parent : parent[key];
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj)) {
const bundleOptions = (options.bundle || {});
const isExcludedPath = bundleOptions.excludedPathMatcher || (() => false);
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !isExcludedPath(pathFromRoot)) {
if (ref_js_1.default.isAllowed$Ref(obj)) {

@@ -106,2 +108,5 @@ inventory$Ref(parent, key, path, pathFromRoot, indirections, inventory, $refs, options);

}
if (value["$ref"]) {
bundleOptions?.onBundle?.(value["$ref"], obj[key], obj, key);
}
}

@@ -108,0 +113,0 @@ }

@@ -5,2 +5,19 @@ import type { HTTPResolverOptions, JSONSchema, JSONSchemaObject, Plugin, ResolverOptions } from "./types/index.js";

} : T;
export interface BundleOptions {
/**
* A function, called for each path, which can return true to stop this path and all
* subpaths from being processed further. This is useful in schemas where some
* subpaths contain literal $ref keys that should not be changed.
*/
excludedPathMatcher?(path: string): boolean;
/**
* Callback invoked during bundling.
*
* @argument {string} path - The path being processed (ie. the `$ref` string)
* @argument {JSONSchemaObject} value - The JSON-Schema that the `$ref` resolved to
* @argument {JSONSchemaObject} parent - The parent of the processed object
* @argument {string} parentPropName - The prop name of the parent object whose value was processed
*/
onBundle?(path: string, value: JSONSchemaObject, parent?: JSONSchemaObject, parentPropName?: string): void;
}
export interface DereferenceOptions {

@@ -93,2 +110,6 @@ /**

/**
* The `bundle` options control how JSON Schema `$Ref` Parser will process `$ref` pointers within the JSON schema.
*/
bundle: BundleOptions;
/**
* The `dereference` options control how JSON Schema `$Ref` Parser will dereference `$ref` pointers within the JSON schema.

@@ -95,0 +116,0 @@ */

@@ -54,2 +54,15 @@ "use strict";

*/
bundle: {
/**
* A function, called for each path, which can return true to stop this path and all
* subpaths from being processed further. This is useful in schemas where some
* subpaths contain literal $ref keys that should not be changed.
*
* @type {function}
*/
excludedPathMatcher: () => false,
},
/**
* Determines the types of JSON references that are allowed.
*/
dereference: {

@@ -56,0 +69,0 @@ /**

@@ -8,2 +8,3 @@ import $Ref from "./ref.js";

import type { JSONSchema } from "./index";
import type { BundleOptions } from "./options";

@@ -69,4 +70,6 @@ export interface InventoryEntry {

const obj = key === null ? parent : parent[key as keyof typeof parent];
const bundleOptions = (options.bundle || {}) as BundleOptions;
const isExcludedPath = bundleOptions.excludedPathMatcher || (() => false);
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj)) {
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !isExcludedPath(pathFromRoot)) {
if ($Ref.isAllowed$Ref(obj)) {

@@ -102,2 +105,6 @@ inventory$Ref(parent, key, path, pathFromRoot, indirections, inventory, $refs, options);

}
if (value["$ref"]) {
bundleOptions?.onBundle?.(value["$ref"], obj[key], obj as any, key);
}
}

@@ -104,0 +111,0 @@ }

@@ -15,2 +15,22 @@ import jsonParser from "./parsers/json.js";

: T;
export interface BundleOptions {
/**
* A function, called for each path, which can return true to stop this path and all
* subpaths from being processed further. This is useful in schemas where some
* subpaths contain literal $ref keys that should not be changed.
*/
excludedPathMatcher?(path: string): boolean;
/**
* Callback invoked during bundling.
*
* @argument {string} path - The path being processed (ie. the `$ref` string)
* @argument {JSONSchemaObject} value - The JSON-Schema that the `$ref` resolved to
* @argument {JSONSchemaObject} parent - The parent of the processed object
* @argument {string} parentPropName - The prop name of the parent object whose value was processed
*/
onBundle?(path: string, value: JSONSchemaObject, parent?: JSONSchemaObject, parentPropName?: string): void;
}
export interface DereferenceOptions {

@@ -112,2 +132,7 @@ /**

/**
* The `bundle` options control how JSON Schema `$Ref` Parser will process `$ref` pointers within the JSON schema.
*/
bundle: BundleOptions;
/**
* The `dereference` options control how JSON Schema `$Ref` Parser will dereference `$ref` pointers within the JSON schema.

@@ -176,2 +201,16 @@ */

*/
bundle: {
/**
* A function, called for each path, which can return true to stop this path and all
* subpaths from being processed further. This is useful in schemas where some
* subpaths contain literal $ref keys that should not be changed.
*
* @type {function}
*/
excludedPathMatcher: () => false,
},
/**
* Determines the types of JSON references that are allowed.
*/
dereference: {

@@ -178,0 +217,0 @@ /**

2

package.json
{
"name": "@apidevtools/json-schema-ref-parser",
"version": "14.0.3",
"version": "14.1.0",
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",

@@ -5,0 +5,0 @@ "scripts": {