@apidevtools/json-schema-ref-parser
Advanced tools
Comparing version 11.4.0 to 11.4.1
import $Refs from "./refs.js"; | ||
import { JSONParserError, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, UnmatchedResolverError } from "./util/errors.js"; | ||
import { JSONParserError, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, UnmatchedResolverError, isHandledError, JSONParserErrorGroup } from "./util/errors.js"; | ||
import type { ParserOptions } from "./options.js"; | ||
import type { $RefsCallback, JSONSchema, SchemaCallback } from "./types/index.js"; | ||
export { JSONParserError }; | ||
export { InvalidPointerError }; | ||
export { MissingPointerError }; | ||
export { ResolverError }; | ||
export { ParserError }; | ||
export { UnmatchedParserError }; | ||
export { UnmatchedResolverError }; | ||
type RefParserSchema = string | JSONSchema; | ||
export type RefParserSchema = string | JSONSchema; | ||
/** | ||
@@ -207,1 +200,2 @@ * This class parses a JSON schema, builds a map of its JSON references and their resolved values, | ||
export declare const dereference: typeof $RefParser.dereference; | ||
export { UnmatchedResolverError, JSONParserError, JSONSchema, InvalidPointerError, MissingPointerError, ResolverError, ParserError, UnmatchedParserError, ParserOptions, $RefsCallback, isHandledError, JSONParserErrorGroup, SchemaCallback, }; |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.dereference = exports.bundle = exports.resolve = exports.parse = exports.$RefParser = exports.UnmatchedResolverError = exports.UnmatchedParserError = exports.ParserError = exports.ResolverError = exports.MissingPointerError = exports.InvalidPointerError = exports.JSONParserError = void 0; | ||
exports.JSONParserErrorGroup = exports.isHandledError = exports.UnmatchedParserError = exports.ParserError = exports.ResolverError = exports.MissingPointerError = exports.InvalidPointerError = exports.JSONParserError = exports.UnmatchedResolverError = exports.dereference = exports.bundle = exports.resolve = exports.parse = exports.$RefParser = void 0; | ||
const refs_js_1 = __importDefault(require("./refs.js")); | ||
@@ -46,2 +46,4 @@ const parse_js_1 = __importDefault(require("./parse.js")); | ||
Object.defineProperty(exports, "UnmatchedResolverError", { enumerable: true, get: function () { return errors_js_1.UnmatchedResolverError; } }); | ||
Object.defineProperty(exports, "isHandledError", { enumerable: true, get: function () { return errors_js_1.isHandledError; } }); | ||
Object.defineProperty(exports, "JSONParserErrorGroup", { enumerable: true, get: function () { return errors_js_1.JSONParserErrorGroup; } }); | ||
const ono_1 = require("@jsdevtools/ono"); | ||
@@ -48,0 +50,0 @@ const maybe_js_1 = __importDefault(require("./util/maybe.js")); |
@@ -0,10 +1,13 @@ | ||
import type { JSONSchema, SchemaCallback } from "./types"; | ||
import type $RefParserOptions from "./options"; | ||
export default normalizeArgs; | ||
export interface NormalizedArguments { | ||
path: string; | ||
schema: JSONSchema; | ||
options: $RefParserOptions; | ||
callback: SchemaCallback; | ||
} | ||
/** | ||
* Normalizes the given arguments, accounting for optional args. | ||
*/ | ||
declare function normalizeArgs(_args: Partial<IArguments>): { | ||
path: string; | ||
schema: any; | ||
options: any; | ||
callback: any; | ||
}; | ||
declare function normalizeArgs(_args: Partial<IArguments>): NormalizedArguments; |
@@ -39,5 +39,5 @@ "use strict"; | ||
catch (e) { | ||
console.log(e); | ||
console.error(`JSON Schema Ref Parser: Error normalizing options: ${e}`); | ||
} | ||
if (!options.mutateInputSchema) { | ||
if (!options.mutateInputSchema && typeof schema === "object") { | ||
// Make a deep clone of the schema, so that we don't alter the original object | ||
@@ -44,0 +44,0 @@ schema = JSON.parse(JSON.stringify(schema)); |
import type { HTTPResolverOptions, JSONSchemaObject, Plugin, ResolverOptions } from "./types/index.js"; | ||
type DeepPartial<T> = T extends object ? { | ||
export type DeepPartial<T> = T extends object ? { | ||
[P in keyof T]?: DeepPartial<T[P]>; | ||
@@ -11,3 +11,3 @@ } : T; | ||
*/ | ||
interface $RefParserOptions { | ||
export interface $RefParserOptions { | ||
/** | ||
@@ -89,5 +89,6 @@ * The `parse` options determine how different types of files will be parsed. | ||
} | ||
export declare const getNewOptions: (options: DeepPartial<$RefParserOptions>) => $RefParserOptions; | ||
export declare const getJsonSchemaRefParserDefaultOptions: () => $RefParserOptions; | ||
export declare const getNewOptions: (options: DeepPartial<$RefParserOptions> | undefined) => $RefParserOptions; | ||
export type Options = $RefParserOptions; | ||
export type ParserOptions = DeepPartial<$RefParserOptions>; | ||
export default $RefParserOptions; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getNewOptions = void 0; | ||
exports.getNewOptions = exports.getJsonSchemaRefParserDefaultOptions = void 0; | ||
const json_js_1 = __importDefault(require("./parsers/json.js")); | ||
@@ -14,3 +14,3 @@ const yaml_js_1 = __importDefault(require("./parsers/yaml.js")); | ||
const http_js_1 = __importDefault(require("./resolvers/http.js")); | ||
const getDefaults = () => { | ||
const getJsonSchemaRefParserDefaultOptions = () => { | ||
const defaults = { | ||
@@ -79,4 +79,5 @@ /** | ||
}; | ||
exports.getJsonSchemaRefParserDefaultOptions = getJsonSchemaRefParserDefaultOptions; | ||
const getNewOptions = (options) => { | ||
const newOptions = getDefaults(); | ||
const newOptions = (0, exports.getJsonSchemaRefParserDefaultOptions)(); | ||
if (options) { | ||
@@ -83,0 +84,0 @@ merge(newOptions, options); |
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
export type JSONSchemaObject = JSONSchema4Object | JSONSchema6Object | JSONSchema7Object; | ||
export type SchemaCallback = (err: Error | null, schema?: JSONSchema | object) => any; | ||
export type SchemaCallback = (err: Error | null, schema?: JSONSchema | object | null) => any; | ||
export type $RefsCallback = (err: Error | null, $refs?: $Refs) => any; | ||
@@ -9,0 +9,0 @@ /** |
@@ -24,12 +24,4 @@ import $Refs from "./refs.js"; | ||
export { JSONParserError }; | ||
export { InvalidPointerError }; | ||
export { MissingPointerError }; | ||
export { ResolverError }; | ||
export { ParserError }; | ||
export { UnmatchedParserError }; | ||
export { UnmatchedResolverError }; | ||
export type RefParserSchema = string | JSONSchema; | ||
type RefParserSchema = string | JSONSchema; | ||
/** | ||
@@ -80,3 +72,2 @@ * This class parses a JSON schema, builds a map of its JSON references and their resolved values, | ||
): Promise<void>; | ||
async parse() { | ||
@@ -423,1 +414,17 @@ const args = normalizeArgs(arguments as any); | ||
export const dereference = $RefParser.dereference; | ||
export { | ||
UnmatchedResolverError, | ||
JSONParserError, | ||
JSONSchema, | ||
InvalidPointerError, | ||
MissingPointerError, | ||
ResolverError, | ||
ParserError, | ||
UnmatchedParserError, | ||
ParserOptions, | ||
$RefsCallback, | ||
isHandledError, | ||
JSONParserErrorGroup, | ||
SchemaCallback, | ||
}; |
import { getNewOptions } from "./options.js"; | ||
import type { JSONSchema, SchemaCallback } from "./types"; | ||
import type $RefParserOptions from "./options"; | ||
export default normalizeArgs; | ||
// I really dislike this function and the way it's written. It's not clear what it's doing, and it's way too flexible | ||
// In the future, I'd like to deprecate the api and accept only named parameters in index.ts | ||
export interface NormalizedArguments { | ||
path: string; | ||
schema: JSONSchema; | ||
options: $RefParserOptions; | ||
callback: SchemaCallback; | ||
} | ||
/** | ||
* Normalizes the given arguments, accounting for optional args. | ||
*/ | ||
function normalizeArgs(_args: Partial<IArguments>) { | ||
function normalizeArgs(_args: Partial<IArguments>): NormalizedArguments { | ||
let path, schema, options, callback; | ||
@@ -39,6 +49,6 @@ const args = Array.prototype.slice.call(_args) as any[]; | ||
} catch (e) { | ||
console.log(e); | ||
console.error(`JSON Schema Ref Parser: Error normalizing options: ${e}`); | ||
} | ||
if (!options.mutateInputSchema) { | ||
if (!options.mutateInputSchema && typeof schema === "object") { | ||
// Make a deep clone of the schema, so that we don't alter the original object | ||
@@ -45,0 +55,0 @@ schema = JSON.parse(JSON.stringify(schema)); |
@@ -10,3 +10,3 @@ import jsonParser from "./parsers/json.js"; | ||
type DeepPartial<T> = T extends object | ||
export type DeepPartial<T> = T extends object | ||
? { | ||
@@ -22,3 +22,3 @@ [P in keyof T]?: DeepPartial<T[P]>; | ||
*/ | ||
interface $RefParserOptions { | ||
export interface $RefParserOptions { | ||
/** | ||
@@ -106,3 +106,3 @@ * The `parse` options determine how different types of files will be parsed. | ||
const getDefaults = () => { | ||
export const getJsonSchemaRefParserDefaultOptions = () => { | ||
const defaults = { | ||
@@ -178,4 +178,4 @@ /** | ||
export const getNewOptions = (options: DeepPartial<$RefParserOptions>): $RefParserOptions => { | ||
const newOptions = getDefaults(); | ||
export const getNewOptions = (options: DeepPartial<$RefParserOptions> | undefined): $RefParserOptions => { | ||
const newOptions = getJsonSchemaRefParserDefaultOptions(); | ||
if (options) { | ||
@@ -182,0 +182,0 @@ merge(newOptions, options); |
@@ -13,3 +13,3 @@ import type { | ||
export type JSONSchemaObject = JSONSchema4Object | JSONSchema6Object | JSONSchema7Object; | ||
export type SchemaCallback = (err: Error | null, schema?: JSONSchema | object) => any; | ||
export type SchemaCallback = (err: Error | null, schema?: JSONSchema | object | null) => any; | ||
export type $RefsCallback = (err: Error | null, $refs?: $Refs) => any; | ||
@@ -16,0 +16,0 @@ |
{ | ||
"name": "@apidevtools/json-schema-ref-parser", | ||
"version": "11.4.0", | ||
"version": "11.4.1", | ||
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
302948
7219