Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apidevtools/json-schema-ref-parser

Package Overview
Dependencies
Maintainers
2
Versions
44
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 11.5.3 to 11.5.4

2

dist/lib/bundle.d.ts

@@ -12,3 +12,3 @@ import type $RefParser from "./index";

*/
declare function bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(parser: $RefParser<S, O>, options: O): void;
declare function bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(parser: $RefParser<S, O>, options: O): void;
export default bundle;

@@ -12,2 +12,2 @@ import type { ParserOptions } from "./options.js";

*/
declare function dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(parser: $RefParser<S, O>, options: O): void;
declare function dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(parser: $RefParser<S, O>, options: O): void;

@@ -12,3 +12,3 @@ import $Refs from "./refs.js";

*/
export declare class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
export declare class $RefParser<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
/**

@@ -45,8 +45,8 @@ * The parsed (and possibly dereferenced) JSON schema object

parse(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string): Promise<S>;
static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O): Promise<S>;
static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O): Promise<S>;
static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string): Promise<S>;
static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O): Promise<S>;
static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O): Promise<S>;
static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
/**

@@ -80,8 +80,8 @@ * *This method is used internally by other methods, such as `bundle` and `dereference`. You probably won't need to call this method yourself.*

*/
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string): Promise<$Refs<S, O>>;
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, callback: $RefsCallback<S, O>): Promise<void>;
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O): Promise<$Refs<S, O>>;
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O, callback: $RefsCallback<S, O>): Promise<void>;
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O): Promise<$Refs<S, O>>;
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O, callback: $RefsCallback<S, O>): Promise<void>;
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string): Promise<$Refs<S, O>>;
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, callback: $RefsCallback<S, O>): Promise<void>;
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O): Promise<$Refs<S, O>>;
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O, callback: $RefsCallback<S, O>): Promise<void>;
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O): Promise<$Refs<S, O>>;
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O, callback: $RefsCallback<S, O>): Promise<void>;
/**

@@ -98,8 +98,8 @@ * Bundles all referenced files/URLs into a single schema that only has internal `$ref` pointers. This lets you split-up your schema however you want while you're building it, but easily combine all those files together when it's time to package or distribute the schema to other people. The resulting schema size will be small, since it will still contain internal JSON references rather than being fully-dereferenced.

*/
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string): Promise<S>;
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O): Promise<S>;
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O): Promise<S>;
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<S>;
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string): Promise<S>;
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O): Promise<S>;
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O): Promise<S>;
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<S>;
/**

@@ -133,8 +133,8 @@ * Bundles all referenced files/URLs into a single schema that only has internal `$ref` pointers. This lets you split-up your schema however you want while you're building it, but easily combine all those files together when it's time to package or distribute the schema to other people. The resulting schema size will be small, since it will still contain internal JSON references rather than being fully-dereferenced.

*/
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string): Promise<S>;
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O): Promise<S>;
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O): Promise<S>;
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string): Promise<S>;
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, callback: SchemaCallback<S>): Promise<void>;
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O): Promise<S>;
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O): Promise<S>;
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(baseUrl: string, schema: S | string, options: O, callback: SchemaCallback<S>): Promise<void>;
/**

@@ -141,0 +141,0 @@ * Dereferences all `$ref` pointers in the JSON Schema, replacing each reference with its resolved value. This results in a schema object that does not contain any `$ref` pointers. Instead, it's a normal JavaScript object tree that can easily be crawled and used just like any other JavaScript object. This is great for programmatic usage, especially when using tools that don't understand JSON references.

@@ -93,3 +93,3 @@ "use strict";

}
else if (!args.path && args.schema && args.schema.$id) {
else if (!args.path && args.schema && "$id" in args.schema && args.schema.$id) {
// when schema id has defined an URL should use that hostname to request the references,

@@ -96,0 +96,0 @@ // instead of using the current page URL

import type { Options, ParserOptions } from "./options.js";
import type { JSONSchema, SchemaCallback } from "./types";
export interface NormalizedArguments<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
export interface NormalizedArguments<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
path: string;

@@ -12,3 +12,3 @@ schema: S;

*/
export declare function normalizeArgs<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(_args: Partial<IArguments>): NormalizedArguments<S, O>;
export declare function normalizeArgs<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(_args: Partial<IArguments>): NormalizedArguments<S, O>;
export default normalizeArgs;

@@ -43,3 +43,3 @@ /// <reference types="node" />

*/
export interface $RefParserOptions<S extends JSONSchema = JSONSchema> {
export interface $RefParserOptions<S extends object = JSONSchema> {
/**

@@ -92,3 +92,3 @@ * The `parse` options determine how different types of files will be parsed.

export declare const getJsonSchemaRefParserDefaultOptions: () => $RefParserOptions<JSONSchema>;
export declare const getNewOptions: <S extends JSONSchema = JSONSchema, O extends {
export declare const getNewOptions: <S extends object = JSONSchema, O extends {
parse?: {

@@ -656,4 +656,4 @@ [x: string]: boolean | {

}>(options: O | undefined) => O & $RefParserOptions<S>;
export type Options<S extends JSONSchema = JSONSchema> = $RefParserOptions<S>;
export type ParserOptions<S extends JSONSchema = JSONSchema> = DeepPartial<$RefParserOptions<S>>;
export type Options<S extends object = JSONSchema> = $RefParserOptions<S>;
export type ParserOptions<S extends object = JSONSchema> = DeepPartial<$RefParserOptions<S>>;
export default $RefParserOptions;

@@ -8,3 +8,3 @@ /// <reference types="node" />

*/
declare function parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, $refs: $Refs<S, O>, options: O): Promise<string | Buffer | S | undefined>;
declare function parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, $refs: $Refs<S, O>, options: O): Promise<string | Buffer | S | undefined>;
export default parse;

@@ -12,3 +12,3 @@ import type { ParserOptions } from "./options.js";

*/
declare class Pointer<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
declare class Pointer<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
/**

@@ -55,3 +55,3 @@ * The {@link $Ref} object that contains this {@link Pointer} object.

*/
resolve(obj: any, options?: O, pathFromRoot?: string): this;
resolve(obj: S, options?: O, pathFromRoot?: string): this;
/**

@@ -67,3 +67,3 @@ * Sets the value of a nested property within the given object.

*/
set(obj: any, value: any, options?: O): any;
set(obj: S, value: any, options?: O): any;
/**

@@ -70,0 +70,0 @@ * Parses a JSON pointer (or a path containing a JSON pointer in the hash)

@@ -12,3 +12,3 @@ import Pointer from "./pointer.js";

*/
declare class $Ref<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
declare class $Ref<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
/**

@@ -113,3 +113,3 @@ * The file path or URL of the referenced file.

*/
static isAllowed$Ref<S extends JSONSchema = JSONSchema>(value: unknown, options?: ParserOptions<S>): true | undefined;
static isAllowed$Ref<S extends object = JSONSchema>(value: unknown, options?: ParserOptions<S>): true | undefined;
/**

@@ -181,4 +181,4 @@ * Determines whether the given value is a JSON reference that "extends" its resolved value.

*/
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>($ref: $Ref<S, O>, resolvedValue: S): S;
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>($ref: $Ref<S, O>, resolvedValue: S): S;
}
export default $Ref;

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

import type { JSONSchema } from "./types";
interface $RefsMap<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
interface $RefsMap<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
[url: string]: $Ref<S, O>;

@@ -16,3 +16,3 @@ }

*/
export default class $Refs<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
export default class $Refs<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
/**

@@ -19,0 +19,0 @@ * This property is true if the schema contains any circular references. You may want to check this property before serializing the dereferenced schema as JSON, since JSON.stringify() does not support circular references by default.

@@ -14,3 +14,3 @@ import type { ParserOptions } from "./options.js";

*/
declare function resolveExternal<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(parser: $RefParser<S, O>, options: O): Promise<void> | Promise<any[]>;
declare function resolveExternal<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(parser: $RefParser<S, O>, options: O): Promise<void> | Promise<any[]>;
export default resolveExternal;

@@ -7,8 +7,8 @@ /// <reference types="node" />

export type JSONSchemaObject = JSONSchema4Object | JSONSchema6Object | JSONSchema7Object;
export type SchemaCallback<S extends JSONSchema = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
export type $RefsCallback<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> = (err: Error | null, $refs?: $Refs<S, O>) => any;
export type SchemaCallback<S extends object = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
export type $RefsCallback<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> = (err: Error | null, $refs?: $Refs<S, O>) => any;
/**
* See https://apitools.dev/json-schema-ref-parser/docs/options.html
*/
export interface HTTPResolverOptions<S extends JSONSchema = JSONSchema> extends Partial<ResolverOptions<S>> {
export interface HTTPResolverOptions<S extends object = JSONSchema> extends Partial<ResolverOptions<S>> {
/**

@@ -36,3 +36,3 @@ * You can specify any HTTP headers that should be sent when downloading files. For example, some servers may require you to set the `Accept` or `Referrer` header.

*/
export interface ResolverOptions<S extends JSONSchema = JSONSchema> {
export interface ResolverOptions<S extends object = JSONSchema> {
name?: string;

@@ -39,0 +39,0 @@ /**

@@ -14,6 +14,6 @@ import type $RefParser from "../index.js";

}
export declare class JSONParserErrorGroup<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> extends Error {
export declare class JSONParserErrorGroup<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> extends Error {
files: $RefParser<S, O>;
constructor(parser: $RefParser<S, O>);
static getParserErrors<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(parser: $RefParser<S, O>): JSONParserError[];
static getParserErrors<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(parser: $RefParser<S, O>): JSONParserError[];
get errors(): Array<JSONParserError | InvalidPointerError | ResolverError | ParserError | MissingPointerError | UnmatchedParserError | UnmatchedResolverError>;

@@ -20,0 +20,0 @@ }

@@ -13,3 +13,3 @@ /// <reference types="node" />

*/
export declare function all<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(plugins: O["resolve"]): Plugin[];
export declare function all<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(plugins: O["resolve"]): Plugin[];
/**

@@ -23,3 +23,3 @@ * Filters the given plugins, returning only the ones return `true` for the given method.

export declare function sort(plugins: Plugin[]): Plugin[];
export interface PluginResult<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
export interface PluginResult<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
plugin: Plugin;

@@ -37,2 +37,2 @@ result?: string | Buffer | S;

*/
export declare function run<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(plugins: Plugin[], method: keyof Plugin | keyof ResolverOptions<S>, file: FileInfo, $refs: $Refs<S, O>): Promise<PluginResult<S, O>>;
export declare function run<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(plugins: Plugin[], method: keyof Plugin | keyof ResolverOptions<S>, file: FileInfo, $refs: $Refs<S, O>): Promise<PluginResult<S, O>>;

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

*/
function bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
parser: $RefParser<S, O>,

@@ -44,3 +44,3 @@ options: O,

*/
function crawl<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function crawl<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
parent: any,

@@ -107,3 +107,3 @@ key: string | null,

*/
function inventory$Ref<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function inventory$Ref<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
$refParent: any,

@@ -110,0 +110,0 @@ $refKey: any,

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

*/
function dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
parser: $RefParser<S, O>,

@@ -52,3 +52,3 @@ options: O,

*/
function crawl<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function crawl<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
obj: any,

@@ -166,3 +166,3 @@ path: string,

*/
function dereference$Ref<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function dereference$Ref<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
$ref: any,

@@ -169,0 +169,0 @@ path: string,

@@ -40,3 +40,3 @@ import $Refs from "./refs.js";

*/
export class $RefParser<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
export class $RefParser<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
/**

@@ -98,6 +98,6 @@ * The parsed (and possibly dereferenced) JSON schema object

pathType = "file";
} else if (!args.path && args.schema && args.schema.$id) {
} else if (!args.path && args.schema && "$id" in args.schema && args.schema.$id) {
// when schema id has defined an URL should use that hostname to request the references,
// instead of using the current page URL
const params = url.parse(args.schema.$id);
const params = url.parse(args.schema.$id as string);
const port = params.protocol === "https:" ? 443 : 80;

@@ -148,14 +148,14 @@

public static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
): Promise<S>;
public static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
callback: SchemaCallback<S>,
): Promise<void>;
public static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
options: O,
): Promise<S>;
public static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,

@@ -165,3 +165,3 @@ options: O,

): Promise<void>;
public static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
baseUrl: string,

@@ -171,3 +171,3 @@ schema: S | string,

): Promise<S>;
public static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
baseUrl: string,

@@ -178,3 +178,3 @@ schema: S | string,

): Promise<void>;
public static parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>():
public static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>():
| Promise<S>

@@ -227,14 +227,14 @@ | Promise<void> {

*/
public static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
): Promise<$Refs<S, O>>;
public static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
callback: $RefsCallback<S, O>,
): Promise<void>;
public static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
options: O,
): Promise<$Refs<S, O>>;
public static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,

@@ -244,3 +244,3 @@ options: O,

): Promise<void>;
public static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
baseUrl: string,

@@ -250,3 +250,3 @@ schema: S | string,

): Promise<$Refs<S, O>>;
public static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
baseUrl: string,

@@ -257,3 +257,3 @@ schema: S | string,

): Promise<void>;
static resolve<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>():
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>():
| Promise<S>

@@ -276,14 +276,14 @@ | Promise<void> {

*/
public static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
): Promise<S>;
public static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
callback: SchemaCallback<S>,
): Promise<void>;
public static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
options: O,
): Promise<S>;
public static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,

@@ -293,3 +293,3 @@ options: O,

): Promise<void>;
public static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
baseUrl: string,

@@ -299,3 +299,3 @@ schema: S | string,

): Promise<S>;
public static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
baseUrl: string,

@@ -306,3 +306,3 @@ schema: S | string,

): Promise<S>;
static bundle<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>():
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>():
| Promise<S>

@@ -354,14 +354,14 @@ | Promise<void> {

*/
public static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
): Promise<S>;
public static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
callback: SchemaCallback<S>,
): Promise<void>;
public static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,
options: O,
): Promise<S>;
public static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
schema: S | string,

@@ -371,3 +371,3 @@ options: O,

): Promise<void>;
public static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
baseUrl: string,

@@ -377,3 +377,3 @@ schema: S | string,

): Promise<S>;
public static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
public static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
baseUrl: string,

@@ -384,3 +384,3 @@ schema: S | string,

): Promise<void>;
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>():
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>():
| Promise<S>

@@ -425,3 +425,3 @@ | Promise<void> {

function finalize<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function finalize<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
parser: $RefParser<S, O>,

@@ -428,0 +428,0 @@ ) {

@@ -7,3 +7,3 @@ import type { Options, ParserOptions } from "./options.js";

// In the future, I'd like to deprecate the api and accept only named parameters in index.ts
export interface NormalizedArguments<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
export interface NormalizedArguments<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
path: string;

@@ -17,3 +17,3 @@ schema: S;

*/
export function normalizeArgs<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
export function normalizeArgs<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
_args: Partial<IArguments>,

@@ -20,0 +20,0 @@ ): NormalizedArguments<S, O> {

@@ -56,3 +56,3 @@ import jsonParser from "./parsers/json.js";

*/
export interface $RefParserOptions<S extends JSONSchema = JSONSchema> {
export interface $RefParserOptions<S extends object = JSONSchema> {
/**

@@ -178,3 +178,3 @@ * The `parse` options determine how different types of files will be parsed.

export const getNewOptions = <S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
export const getNewOptions = <S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
options: O | undefined,

@@ -189,4 +189,4 @@ ): O & $RefParserOptions<S> => {

export type Options<S extends JSONSchema = JSONSchema> = $RefParserOptions<S>;
export type ParserOptions<S extends JSONSchema = JSONSchema> = DeepPartial<$RefParserOptions<S>>;
export type Options<S extends object = JSONSchema> = $RefParserOptions<S>;
export type ParserOptions<S extends object = JSONSchema> = DeepPartial<$RefParserOptions<S>>;
/**

@@ -193,0 +193,0 @@ * Merges the properties of the source object into the target object.

@@ -18,3 +18,3 @@ import { ono } from "@jsdevtools/ono";

*/
async function parse<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
async function parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
path: string,

@@ -74,3 +74,3 @@ $refs: $Refs<S, O>,

*/
async function readFile<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
async function readFile<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
file: FileInfo,

@@ -121,3 +121,3 @@ options: O,

*/
async function parseFile<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
async function parseFile<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
file: FileInfo,

@@ -124,0 +124,0 @@ options: O,

@@ -29,3 +29,3 @@ import type { ParserOptions } from "./options.js";

*/
class Pointer<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
class Pointer<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
/**

@@ -90,3 +90,3 @@ * The {@link $Ref} object that contains this {@link Pointer} object.

*/
resolve(obj: any, options?: O, pathFromRoot?: string) {
resolve(obj: S, options?: O, pathFromRoot?: string) {
const tokens = Pointer.parse(this.path, this.originalPath);

@@ -149,3 +149,3 @@

*/
set(obj: any, value: any, options?: O) {
set(obj: S, value: any, options?: O) {
const tokens = Pointer.parse(this.path);

@@ -152,0 +152,0 @@ let token;

@@ -16,3 +16,3 @@ import Pointer from "./pointer.js";

*/
class $Ref<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
class $Ref<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
/**

@@ -189,3 +189,3 @@ * The file path or URL of the referenced file.

*/
static isAllowed$Ref<S extends JSONSchema = JSONSchema>(value: unknown, options?: ParserOptions<S>) {
static isAllowed$Ref<S extends object = JSONSchema>(value: unknown, options?: ParserOptions<S>) {
if (this.is$Ref(value)) {

@@ -271,3 +271,3 @@ if (value.$ref.substring(0, 2) === "#/" || value.$ref === "#") {

*/
static dereference<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
$ref: $Ref<S, O>,

@@ -274,0 +274,0 @@ resolvedValue: S,

@@ -9,3 +9,3 @@ import { ono } from "@jsdevtools/ono";

interface $RefsMap<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
interface $RefsMap<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
[url: string]: $Ref<S, O>;

@@ -20,3 +20,3 @@ }

*/
export default class $Refs<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
export default class $Refs<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
/**

@@ -220,3 +220,3 @@ * This property is true if the schema contains any circular references. You may want to check this property before serializing the dereferenced schema as JSON, since JSON.stringify() does not support circular references by default.

*/
function getPaths<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function getPaths<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
$refs: $RefsMap<S, O>,

@@ -223,0 +223,0 @@ types: string[],

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

*/
function resolveExternal<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function resolveExternal<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
parser: $RefParser<S, O>,

@@ -56,3 +56,3 @@ options: O,

*/
function crawl<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function crawl<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
obj: string | Buffer | S | undefined | null,

@@ -97,3 +97,3 @@ path: string,

*/
async function resolve$Ref<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
async function resolve$Ref<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
$ref: S,

@@ -105,3 +105,3 @@ path: string,

const shouldResolveOnCwd = options.dereference?.externalReferenceResolution === "root";
const resolvedPath = url.resolve(shouldResolveOnCwd ? url.cwd() : path, $ref.$ref!);
const resolvedPath = url.resolve(shouldResolveOnCwd ? url.cwd() : path, ($ref as JSONSchema).$ref!);
const withoutHash = url.stripHash(resolvedPath);

@@ -108,0 +108,0 @@

@@ -69,3 +69,3 @@ import { ono } from "@jsdevtools/ono";

*/
async function download<S extends JSONSchema = JSONSchema>(
async function download<S extends object = JSONSchema>(
u: URL | string,

@@ -113,3 +113,3 @@ httpOptions: HTTPResolverOptions<S>,

*/
async function get<S extends JSONSchema = JSONSchema>(u: RequestInfo | URL, httpOptions: HTTPResolverOptions<S>) {
async function get<S extends object = JSONSchema>(u: RequestInfo | URL, httpOptions: HTTPResolverOptions<S>) {
let controller: any;

@@ -116,0 +116,0 @@ let timeoutId: any;

@@ -14,4 +14,4 @@ import type {

export type JSONSchemaObject = JSONSchema4Object | JSONSchema6Object | JSONSchema7Object;
export type SchemaCallback<S extends JSONSchema = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
export type $RefsCallback<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> = (
export type SchemaCallback<S extends object = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
export type $RefsCallback<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> = (
err: Error | null,

@@ -25,3 +25,3 @@ $refs?: $Refs<S, O>,

export interface HTTPResolverOptions<S extends JSONSchema = JSONSchema> extends Partial<ResolverOptions<S>> {
export interface HTTPResolverOptions<S extends object = JSONSchema> extends Partial<ResolverOptions<S>> {
/**

@@ -53,3 +53,3 @@ * You can specify any HTTP headers that should be sent when downloading files. For example, some servers may require you to set the `Accept` or `Referrer` header.

*/
export interface ResolverOptions<S extends JSONSchema = JSONSchema> {
export interface ResolverOptions<S extends object = JSONSchema> {
name?: string;

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

@@ -41,3 +41,3 @@ import { Ono } from "@jsdevtools/ono";

export class JSONParserErrorGroup<
S extends JSONSchema = JSONSchema,
S extends object = JSONSchema,
O extends ParserOptions<S> = ParserOptions<S>,

@@ -59,3 +59,3 @@ > extends Error {

static getParserErrors<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
static getParserErrors<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
parser: $RefParser<S, O>,

@@ -62,0 +62,0 @@ ) {

@@ -13,3 +13,3 @@ import type { FileInfo, JSONSchema } from "../types/index.js";

*/
export function all<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
export function all<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
plugins: O["resolve"],

@@ -49,3 +49,3 @@ ): Plugin[] {

export interface PluginResult<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
export interface PluginResult<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
plugin: Plugin;

@@ -64,3 +64,3 @@ result?: string | Buffer | S;

*/
export async function run<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
export async function run<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
plugins: Plugin[],

@@ -135,3 +135,3 @@ method: keyof Plugin | keyof ResolverOptions<S>,

*/
function getResult<S extends JSONSchema = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
function getResult<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(
obj: Plugin,

@@ -138,0 +138,0 @@ prop: keyof Plugin | keyof ResolverOptions<S>,

{
"name": "@apidevtools/json-schema-ref-parser",
"version": "11.5.3",
"version": "11.5.4",
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc