@fumadocs/api-docs 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +1 -1
- package/dist/ref-parser/bundle.d.ts +10 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/bundle.js +76 -6
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/normalize-args.js +1 -1
- package/dist/ref-parser/options.d.ts +28 -0
- package/dist/ref-parser/options.js +27 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/parse.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/parsers/json.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/parsers/yaml.js +6 -12
- package/dist/ref-parser/pointer.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/pointer.js +16 -54
- package/dist/ref-parser/ref.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/ref.js +6 -48
- package/dist/ref-parser/refs.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/refs.js +4 -41
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/resolve-external.js +3 -3
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/resolvers/file.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/types/index.d.ts +8 -40
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/convert-path-to-posix.js +1 -1
- package/dist/ref-parser/util/errors.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/errors.js +16 -34
- package/dist/ref-parser/util/is-windows.js +5 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/maybe.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/next.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/plugins.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/schema-resources.js +1 -1
- package/dist/ref-parser/util/url.js +206 -0
- package/dist/schema/bundle.d.ts +1 -1
- package/dist/schema/bundle.js +1 -1
- package/dist/schema/ref.d.ts +3 -1
- package/dist/schema/ref.js +1 -1
- package/dist/schema/sample.js +5 -7
- package/dist/utils/cn.js +1 -1
- package/dist/utils/deep-merge.js +8 -0
- package/package.json +8 -10
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +0 -187
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.d.ts +0 -157
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +0 -136
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.d.ts +0 -166
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +0 -124
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +0 -30
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +0 -36
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.d.ts +0 -96
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.d.ts +0 -190
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.d.ts +0 -134
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +0 -121
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.d.ts +0 -34
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +0 -5
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js +0 -381
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { cwd, resolve } from "./util/url.js";
|
|
2
|
-
import { TimeoutError } from "./util/errors.js";
|
|
3
|
-
import { getSchemaBasePath } from "./util/schema-resources.js";
|
|
4
|
-
import Pointer from "./pointer.js";
|
|
5
|
-
import $Ref from "./ref.js";
|
|
6
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js
|
|
7
|
-
var dereference_default = dereference;
|
|
8
|
-
/**
|
|
9
|
-
* Crawls the JSON schema, finds all JSON references, and dereferences them.
|
|
10
|
-
* This method mutates the JSON schema object, replacing JSON references with their resolved value.
|
|
11
|
-
*
|
|
12
|
-
* @param parser
|
|
13
|
-
* @param options
|
|
14
|
-
*/
|
|
15
|
-
function dereference(parser, options) {
|
|
16
|
-
const start = Date.now();
|
|
17
|
-
const rootScopeBase = parser.$refs._root$Ref.dynamicIdScope ? getSchemaBasePath(parser.$refs._root$Ref.path, parser.schema) : parser.$refs._root$Ref.path;
|
|
18
|
-
const dereferenced = crawl(parser.schema, parser.$refs._root$Ref.path, rootScopeBase, parser.$refs._root$Ref.dynamicIdScope, "#", /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), /* @__PURE__ */ new Map(), parser.$refs, options, start, 0);
|
|
19
|
-
parser.$refs.circular = dereferenced.circular;
|
|
20
|
-
parser.schema = dereferenced.value;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Recursively crawls the given value, and dereferences any JSON references.
|
|
24
|
-
*
|
|
25
|
-
* @param obj - The value to crawl. If it's not an object or array, it will be ignored.
|
|
26
|
-
* @param path - The full path of `obj`, possibly with a JSON Pointer in the hash
|
|
27
|
-
* @param pathFromRoot - The path of `obj` from the schema root
|
|
28
|
-
* @param parents - An array of the parent objects that have already been dereferenced
|
|
29
|
-
* @param processedObjects - An array of all the objects that have already been processed
|
|
30
|
-
* @param dereferencedCache - An map of all the dereferenced objects
|
|
31
|
-
* @param $refs
|
|
32
|
-
* @param options
|
|
33
|
-
* @param startTime - The time when the dereferencing started
|
|
34
|
-
* @param depth - The current recursion depth
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
function crawl(obj, path, scopeBase, dynamicIdScope, pathFromRoot, parents, processedObjects, dereferencedCache, $refs, options, startTime, depth) {
|
|
38
|
-
let dereferenced;
|
|
39
|
-
const result = {
|
|
40
|
-
value: obj,
|
|
41
|
-
circular: false
|
|
42
|
-
};
|
|
43
|
-
checkDereferenceTimeout(startTime, options);
|
|
44
|
-
const derefOptions = options.dereference || {};
|
|
45
|
-
const maxDepth = derefOptions.maxDepth ?? 500;
|
|
46
|
-
if (depth > maxDepth) throw new RangeError(`Maximum dereference depth (${maxDepth}) exceeded at ${pathFromRoot}. This likely indicates an extremely deep or recursive schema. You can increase this limit with the dereference.maxDepth option.`);
|
|
47
|
-
const isExcludedPath = derefOptions.excludedPathMatcher || (() => false);
|
|
48
|
-
if (derefOptions?.circular === "ignore" || !processedObjects.has(obj)) {
|
|
49
|
-
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !isExcludedPath(pathFromRoot)) {
|
|
50
|
-
parents.add(obj);
|
|
51
|
-
processedObjects.add(obj);
|
|
52
|
-
const currentScopeBase = scopeBase;
|
|
53
|
-
if ($Ref.isAllowed$Ref(obj, options)) {
|
|
54
|
-
dereferenced = dereference$Ref(obj, path, currentScopeBase, dynamicIdScope, pathFromRoot, parents, processedObjects, dereferencedCache, $refs, options, startTime, depth);
|
|
55
|
-
result.circular = dereferenced.circular;
|
|
56
|
-
result.value = dereferenced.value;
|
|
57
|
-
} else for (const key of Object.keys(obj)) {
|
|
58
|
-
checkDereferenceTimeout(startTime, options);
|
|
59
|
-
const keyPath = Pointer.join(path, key);
|
|
60
|
-
const keyPathFromRoot = Pointer.join(pathFromRoot, key);
|
|
61
|
-
if (isExcludedPath(keyPathFromRoot)) continue;
|
|
62
|
-
const value = obj[key];
|
|
63
|
-
const childScopeBase = dynamicIdScope && value && typeof value === "object" && !ArrayBuffer.isView(value) ? getSchemaBasePath(currentScopeBase, value) : currentScopeBase;
|
|
64
|
-
let circular;
|
|
65
|
-
if ($Ref.isAllowed$Ref(value, options)) {
|
|
66
|
-
dereferenced = dereference$Ref(value, keyPath, childScopeBase, dynamicIdScope, keyPathFromRoot, parents, processedObjects, dereferencedCache, $refs, options, startTime, depth);
|
|
67
|
-
circular = dereferenced.circular;
|
|
68
|
-
if (obj[key] !== dereferenced.value) {
|
|
69
|
-
const preserved = /* @__PURE__ */ new Map();
|
|
70
|
-
if (derefOptions?.preservedProperties) {
|
|
71
|
-
if (typeof obj[key] === "object" && !Array.isArray(obj[key])) derefOptions?.preservedProperties.forEach((prop) => {
|
|
72
|
-
if (prop in obj[key]) preserved.set(prop, obj[key][prop]);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
let assignedValue = dereferenced.value;
|
|
76
|
-
if (derefOptions?.cloneReferences && !circular && assignedValue && typeof assignedValue === "object") assignedValue = structuredClone(assignedValue);
|
|
77
|
-
obj[key] = assignedValue;
|
|
78
|
-
if (derefOptions?.preservedProperties) {
|
|
79
|
-
if (preserved.size && typeof obj[key] === "object" && !Array.isArray(obj[key])) preserved.forEach((value, prop) => {
|
|
80
|
-
obj[key][prop] = value;
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
derefOptions?.onDereference?.(value.$ref, obj[key], obj, key);
|
|
84
|
-
}
|
|
85
|
-
} else if (!parents.has(value)) {
|
|
86
|
-
dereferenced = crawl(value, keyPath, childScopeBase, dynamicIdScope, keyPathFromRoot, parents, processedObjects, dereferencedCache, $refs, options, startTime, depth + 1);
|
|
87
|
-
circular = dereferenced.circular;
|
|
88
|
-
if (obj[key] !== dereferenced.value) obj[key] = dereferenced.value;
|
|
89
|
-
} else circular = foundCircularReference(keyPath, $refs, options);
|
|
90
|
-
result.circular = result.circular || circular;
|
|
91
|
-
}
|
|
92
|
-
parents.delete(obj);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Dereferences the given JSON Reference, and then crawls the resulting value.
|
|
99
|
-
*
|
|
100
|
-
* @param $ref - The JSON Reference to resolve
|
|
101
|
-
* @param path - The full path of `$ref`, possibly with a JSON Pointer in the hash
|
|
102
|
-
* @param pathFromRoot - The path of `$ref` from the schema root
|
|
103
|
-
* @param parents - An array of the parent objects that have already been dereferenced
|
|
104
|
-
* @param processedObjects - An array of all the objects that have already been dereferenced
|
|
105
|
-
* @param dereferencedCache - An map of all the dereferenced objects
|
|
106
|
-
* @param $refs
|
|
107
|
-
* @param options
|
|
108
|
-
* @returns
|
|
109
|
-
*/
|
|
110
|
-
function dereference$Ref($ref, path, scopeBase, dynamicIdScope, pathFromRoot, parents, processedObjects, dereferencedCache, $refs, options, startTime, depth) {
|
|
111
|
-
const $refPath = resolve($Ref.isExternal$Ref($ref) && options?.dereference?.externalReferenceResolution === "root" ? cwd() : dynamicIdScope ? scopeBase : path, $ref.$ref);
|
|
112
|
-
const cache = dereferencedCache.get($refPath);
|
|
113
|
-
if (cache) {
|
|
114
|
-
if (!cache.circular) {
|
|
115
|
-
const refKeys = Object.keys($ref);
|
|
116
|
-
if (refKeys.length > 1) {
|
|
117
|
-
const extraKeys = {};
|
|
118
|
-
for (const key of refKeys) if (key !== "$ref" && !(key in cache.value)) extraKeys[key] = $ref[key];
|
|
119
|
-
return {
|
|
120
|
-
circular: cache.circular,
|
|
121
|
-
value: Object.assign({}, cache.value, extraKeys)
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
return cache;
|
|
125
|
-
}
|
|
126
|
-
if (typeof cache.value === "object" && "$ref" in cache.value && "$ref" in $ref) {
|
|
127
|
-
if (cache.value.$ref === $ref.$ref) {
|
|
128
|
-
foundCircularReference(path, $refs, options);
|
|
129
|
-
return cache;
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
foundCircularReference(path, $refs, options);
|
|
133
|
-
return cache;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const pointer = $refs._resolve($refPath, path, options);
|
|
137
|
-
if (pointer === null) return {
|
|
138
|
-
circular: false,
|
|
139
|
-
value: null
|
|
140
|
-
};
|
|
141
|
-
const directCircular = pointer.circular;
|
|
142
|
-
let circular = directCircular || parents.has(pointer.value);
|
|
143
|
-
if (circular) foundCircularReference(path, $refs, options);
|
|
144
|
-
let dereferencedValue = $Ref.dereference($ref, pointer.value, options);
|
|
145
|
-
if (!circular) {
|
|
146
|
-
const dereferenced = crawl(dereferencedValue, pointer.path, pointer.$ref.path, pointer.$ref.dynamicIdScope, pathFromRoot, parents, processedObjects, dereferencedCache, $refs, options, startTime, depth + 1);
|
|
147
|
-
circular = dereferenced.circular;
|
|
148
|
-
dereferencedValue = dereferenced.value;
|
|
149
|
-
}
|
|
150
|
-
if (circular && !directCircular && options.dereference?.circular === "ignore") dereferencedValue = $ref;
|
|
151
|
-
if (directCircular) dereferencedValue.$ref = pathFromRoot;
|
|
152
|
-
const dereferencedObject = {
|
|
153
|
-
circular,
|
|
154
|
-
value: dereferencedValue
|
|
155
|
-
};
|
|
156
|
-
if (Object.keys($ref).length === 1) dereferencedCache.set($refPath, dereferencedObject);
|
|
157
|
-
return dereferencedObject;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Check if we've run past our allowed timeout and throw an error if we have.
|
|
161
|
-
*
|
|
162
|
-
* @param startTime - The time when the dereferencing started.
|
|
163
|
-
* @param options
|
|
164
|
-
*/
|
|
165
|
-
function checkDereferenceTimeout(startTime, options) {
|
|
166
|
-
if (options && options.timeoutMs) {
|
|
167
|
-
if (Date.now() - startTime > options.timeoutMs) throw new TimeoutError(options.timeoutMs);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Called when a circular reference is found.
|
|
172
|
-
* It sets the {@link $Refs#circular} flag, executes the options.dereference.onCircular callback,
|
|
173
|
-
* and throws an error if options.dereference.circular is false.
|
|
174
|
-
*
|
|
175
|
-
* @param keyPath - The JSON Reference path of the circular reference
|
|
176
|
-
* @param $refs
|
|
177
|
-
* @param options
|
|
178
|
-
* @returns - always returns true, to indicate that a circular reference was found
|
|
179
|
-
*/
|
|
180
|
-
function foundCircularReference(keyPath, $refs, options) {
|
|
181
|
-
$refs.circular = true;
|
|
182
|
-
options?.dereference?.onCircular?.(keyPath);
|
|
183
|
-
if (!options.dereference.circular) throw /* @__PURE__ */ new ReferenceError(`Circular $ref pointer found at ${keyPath}`);
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
//#endregion
|
|
187
|
-
export { dereference_default as default };
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { $RefsCallback, FileInfo, HTTPResolverOptions, JSONSchema, Plugin, ResolverOptions, SchemaCallback } from "./types/index.js";
|
|
2
|
-
import { ParserOptions } from "./options.js";
|
|
3
|
-
import { JSONParserError, MissingPointerError, ParserError, ResolverError } from "./util/errors.js";
|
|
4
|
-
import { $Refs } from "./refs.js";
|
|
5
|
-
|
|
6
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* This class parses a JSON schema, builds a map of its JSON references and their resolved values,
|
|
9
|
-
* and provides methods for traversing, manipulating, and dereferencing those references.
|
|
10
|
-
*
|
|
11
|
-
* @class
|
|
12
|
-
*/
|
|
13
|
-
declare class $RefParser<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
|
|
14
|
-
/**
|
|
15
|
-
* The parsed (and possibly dereferenced) JSON schema object
|
|
16
|
-
*
|
|
17
|
-
* @type {object}
|
|
18
|
-
* @readonly
|
|
19
|
-
*/
|
|
20
|
-
schema: S | null;
|
|
21
|
-
/**
|
|
22
|
-
* The resolved JSON references
|
|
23
|
-
*
|
|
24
|
-
* @type {$Refs}
|
|
25
|
-
* @readonly
|
|
26
|
-
*/
|
|
27
|
-
$refs: $Refs<S, O>;
|
|
28
|
-
/**
|
|
29
|
-
* Parses the given JSON schema.
|
|
30
|
-
* This method does not resolve any JSON references.
|
|
31
|
-
* It just reads a single file in JSON or YAML format, and parse it as a JavaScript object.
|
|
32
|
-
*
|
|
33
|
-
* @param [path] - The file path or URL of the JSON schema
|
|
34
|
-
* @param [schema] - A JSON schema object. This object will be used instead of reading from `path`.
|
|
35
|
-
* @param [options] - Options that determine how the schema is parsed
|
|
36
|
-
* @param [callback] - An error-first callback. The second parameter is the parsed JSON schema object.
|
|
37
|
-
* @returns - The returned promise resolves with the parsed JSON schema object.
|
|
38
|
-
*/
|
|
39
|
-
parse(schema: S | string | unknown): Promise<S>;
|
|
40
|
-
parse(schema: S | string | unknown, callback: SchemaCallback<S>): Promise<void>;
|
|
41
|
-
parse(schema: S | string | unknown, options: O): Promise<S>;
|
|
42
|
-
parse(schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
43
|
-
parse(path: string, schema: S | string | unknown, options: O): Promise<S>;
|
|
44
|
-
parse(path: string, schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
45
|
-
static parse<S extends object = JSONSchema>(schema: S | string | unknown): Promise<S>;
|
|
46
|
-
static parse<S extends object = JSONSchema>(schema: S | string | unknown, callback: SchemaCallback<S>): Promise<void>;
|
|
47
|
-
static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string | unknown, options: O): Promise<S>;
|
|
48
|
-
static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
49
|
-
static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string | unknown, options: O): Promise<S>;
|
|
50
|
-
static parse<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* *This method is used internally by other methods, such as `bundle` and `dereference`. You probably won't need to call this method yourself.*
|
|
53
|
-
*
|
|
54
|
-
* Resolves all JSON references (`$ref` pointers) in the given JSON Schema file. If it references any other files/URLs, then they will be downloaded and resolved as well. This method **does not** dereference anything. It simply gives you a `$Refs` object, which is a map of all the resolved references and their values.
|
|
55
|
-
*
|
|
56
|
-
* See https://apidevtools.com/json-schema-ref-parser/docs/ref-parser.html#resolveschema-options-callback
|
|
57
|
-
*
|
|
58
|
-
* @param schema A JSON Schema object, or the file path or URL of a JSON Schema file. See the `parse` method for more info.
|
|
59
|
-
* @param options (optional)
|
|
60
|
-
* @param callback (optional) A callback that will receive a `$Refs` object
|
|
61
|
-
*/
|
|
62
|
-
resolve(schema: S | string | unknown): Promise<$Refs<S, O>>;
|
|
63
|
-
resolve(schema: S | string | unknown, callback: $RefsCallback<S, O>): Promise<void>;
|
|
64
|
-
resolve(schema: S | string | unknown, options: O): Promise<$Refs<S, O>>;
|
|
65
|
-
resolve(schema: S | string | unknown, options: O, callback: $RefsCallback<S, O>): Promise<void>;
|
|
66
|
-
resolve(path: string, schema: S | string | unknown, options: O): Promise<$Refs<S, O>>;
|
|
67
|
-
resolve(path: string, schema: S | string | unknown, options: O, callback: $RefsCallback<S, O>): Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* *This method is used internally by other methods, such as `bundle` and `dereference`. You probably won't need to call this method yourself.*
|
|
70
|
-
*
|
|
71
|
-
* Resolves all JSON references (`$ref` pointers) in the given JSON Schema file. If it references any other files/URLs, then they will be downloaded and resolved as well. This method **does not** dereference anything. It simply gives you a `$Refs` object, which is a map of all the resolved references and their values.
|
|
72
|
-
*
|
|
73
|
-
* See https://apidevtools.com/json-schema-ref-parser/docs/ref-parser.html#resolveschema-options-callback
|
|
74
|
-
*
|
|
75
|
-
* @param schema A JSON Schema object, or the file path or URL of a JSON Schema file. See the `parse` method for more info.
|
|
76
|
-
* @param options (optional)
|
|
77
|
-
* @param callback (optional) A callback that will receive a `$Refs` object
|
|
78
|
-
*/
|
|
79
|
-
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string | unknown): Promise<$Refs<S, O>>;
|
|
80
|
-
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string | unknown, callback: $RefsCallback<S, O>): Promise<void>;
|
|
81
|
-
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string | unknown, options: O): Promise<$Refs<S, O>>;
|
|
82
|
-
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string | unknown, options: O, callback: $RefsCallback<S, O>): Promise<void>;
|
|
83
|
-
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string | unknown, options: O): Promise<$Refs<S, O>>;
|
|
84
|
-
static resolve<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string | unknown, options: O, callback: $RefsCallback<S, O>): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* 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.
|
|
87
|
-
*
|
|
88
|
-
* This also eliminates the risk of circular references, so the schema can be safely serialized using `JSON.stringify()`.
|
|
89
|
-
*
|
|
90
|
-
* See https://apidevtools.com/json-schema-ref-parser/docs/ref-parser.html#bundleschema-options-callback
|
|
91
|
-
*
|
|
92
|
-
* @param schema A JSON Schema object, or the file path or URL of a JSON Schema file. See the `parse` method for more info.
|
|
93
|
-
* @param options (optional)
|
|
94
|
-
* @param callback (optional) A callback that will receive the bundled schema object
|
|
95
|
-
*/
|
|
96
|
-
static bundle<S extends object = JSONSchema>(schema: S | string | unknown): Promise<S>;
|
|
97
|
-
static bundle<S extends object = JSONSchema>(schema: S | string | unknown, callback: SchemaCallback<S>): Promise<void>;
|
|
98
|
-
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string | unknown, options: O): Promise<S>;
|
|
99
|
-
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
100
|
-
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string | unknown, options: O): Promise<S>;
|
|
101
|
-
static bundle<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<S>;
|
|
102
|
-
/**
|
|
103
|
-
* 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.
|
|
104
|
-
*
|
|
105
|
-
* This also eliminates the risk of circular references, so the schema can be safely serialized using `JSON.stringify()`.
|
|
106
|
-
*
|
|
107
|
-
* See https://apidevtools.com/json-schema-ref-parser/docs/ref-parser.html#bundleschema-options-callback
|
|
108
|
-
*
|
|
109
|
-
* @param schema A JSON Schema object, or the file path or URL of a JSON Schema file. See the `parse` method for more info.
|
|
110
|
-
* @param options (optional)
|
|
111
|
-
* @param callback (optional) A callback that will receive the bundled schema object
|
|
112
|
-
*/
|
|
113
|
-
bundle(schema: S | string | unknown): Promise<S>;
|
|
114
|
-
bundle(schema: S | string | unknown, callback: SchemaCallback<S>): Promise<void>;
|
|
115
|
-
bundle(schema: S | string | unknown, options: O): Promise<S>;
|
|
116
|
-
bundle(schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
117
|
-
bundle(path: string, schema: S | string | unknown, options: O): Promise<S>;
|
|
118
|
-
bundle(path: string, schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
119
|
-
/**
|
|
120
|
-
* 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.
|
|
121
|
-
*
|
|
122
|
-
* The dereference method maintains object reference equality, meaning that all `$ref` pointers that point to the same object will be replaced with references to the same object. Again, this is great for programmatic usage, but it does introduce the risk of circular references, so be careful if you intend to serialize the schema using `JSON.stringify()`. Consider using the bundle method instead, which does not create circular references.
|
|
123
|
-
*
|
|
124
|
-
* See https://apidevtools.com/json-schema-ref-parser/docs/ref-parser.html#dereferenceschema-options-callback
|
|
125
|
-
*
|
|
126
|
-
* @param schema A JSON Schema object, or the file path or URL of a JSON Schema file. See the `parse` method for more info.
|
|
127
|
-
* @param options (optional)
|
|
128
|
-
* @param callback (optional) A callback that will receive the dereferenced schema object
|
|
129
|
-
*/
|
|
130
|
-
static dereference<S extends object = JSONSchema>(schema: S | string | unknown): Promise<S>;
|
|
131
|
-
static dereference<S extends object = JSONSchema>(schema: S | string | unknown, callback: SchemaCallback<S>): Promise<void>;
|
|
132
|
-
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string | unknown, options: O): Promise<S>;
|
|
133
|
-
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
134
|
-
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string | unknown, options: O): Promise<S>;
|
|
135
|
-
static dereference<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>>(path: string, schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
136
|
-
/**
|
|
137
|
-
* 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.
|
|
138
|
-
*
|
|
139
|
-
* The dereference method maintains object reference equality, meaning that all `$ref` pointers that point to the same object will be replaced with references to the same object. Again, this is great for programmatic usage, but it does introduce the risk of circular references, so be careful if you intend to serialize the schema using `JSON.stringify()`. Consider using the bundle method instead, which does not create circular references.
|
|
140
|
-
*
|
|
141
|
-
* See https://apidevtools.com/json-schema-ref-parser/docs/ref-parser.html#dereferenceschema-options-callback
|
|
142
|
-
*
|
|
143
|
-
* @param path
|
|
144
|
-
* @param schema A JSON Schema object, or the file path or URL of a JSON Schema file. See the `parse` method for more info.
|
|
145
|
-
* @param options (optional)
|
|
146
|
-
* @param callback (optional) A callback that will receive the dereferenced schema object
|
|
147
|
-
*/
|
|
148
|
-
dereference(path: string, schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
149
|
-
dereference(schema: S | string | unknown, options: O, callback: SchemaCallback<S>): Promise<void>;
|
|
150
|
-
dereference(schema: S | string | unknown, callback: SchemaCallback<S>): Promise<void>;
|
|
151
|
-
dereference(path: string, schema: S | string | unknown, options: O): Promise<S>;
|
|
152
|
-
dereference(schema: S | string | unknown, options: O): Promise<S>;
|
|
153
|
-
dereference(schema: S | string | unknown): Promise<S>;
|
|
154
|
-
}
|
|
155
|
-
declare const bundle: typeof $RefParser.bundle;
|
|
156
|
-
//#endregion
|
|
157
|
-
export { bundle };
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { cwd, fromFileSystemPath, isFileSystemPath, parse as parse$1, resolve as resolve$1, stripHash } from "./util/url.js";
|
|
2
|
-
import { JSONParserErrorGroup, isHandledError } from "./util/errors.js";
|
|
3
|
-
import { registerSchemaResources, usesDynamicIdScope } from "./util/schema-resources.js";
|
|
4
|
-
import $Refs from "./refs.js";
|
|
5
|
-
import parse$2 from "./parse.js";
|
|
6
|
-
import "./resolvers/file.js";
|
|
7
|
-
import "./resolvers/http.js";
|
|
8
|
-
import "./options.js";
|
|
9
|
-
import normalizeArgs from "./normalize-args.js";
|
|
10
|
-
import resolveExternal from "./resolve-external.js";
|
|
11
|
-
import bundle$1 from "./bundle.js";
|
|
12
|
-
import dereference_default from "./dereference.js";
|
|
13
|
-
import maybe from "./util/maybe.js";
|
|
14
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js
|
|
15
|
-
/**
|
|
16
|
-
* This class parses a JSON schema, builds a map of its JSON references and their resolved values,
|
|
17
|
-
* and provides methods for traversing, manipulating, and dereferencing those references.
|
|
18
|
-
*
|
|
19
|
-
* @class
|
|
20
|
-
*/
|
|
21
|
-
var $RefParser = class $RefParser {
|
|
22
|
-
/**
|
|
23
|
-
* The parsed (and possibly dereferenced) JSON schema object
|
|
24
|
-
*
|
|
25
|
-
* @type {object}
|
|
26
|
-
* @readonly
|
|
27
|
-
*/
|
|
28
|
-
schema = null;
|
|
29
|
-
/**
|
|
30
|
-
* The resolved JSON references
|
|
31
|
-
*
|
|
32
|
-
* @type {$Refs}
|
|
33
|
-
* @readonly
|
|
34
|
-
*/
|
|
35
|
-
$refs = new $Refs();
|
|
36
|
-
async parse() {
|
|
37
|
-
const args = normalizeArgs(arguments);
|
|
38
|
-
let promise;
|
|
39
|
-
if (!args.path && !args.schema) {
|
|
40
|
-
const err = /* @__PURE__ */ new Error(`Expected a file path, URL, or object. Got ${args.path || args.schema}`);
|
|
41
|
-
return maybe(args.callback, Promise.reject(err));
|
|
42
|
-
}
|
|
43
|
-
this.schema = null;
|
|
44
|
-
this.$refs = new $Refs();
|
|
45
|
-
let pathType = "http";
|
|
46
|
-
if (isFileSystemPath(args.path)) {
|
|
47
|
-
args.path = fromFileSystemPath(args.path);
|
|
48
|
-
pathType = "file";
|
|
49
|
-
} else if (!args.path && args.schema && "$id" in args.schema && args.schema.$id) {
|
|
50
|
-
const params = parse$1(args.schema.$id);
|
|
51
|
-
const port = params.port ?? (params.protocol === "https:" ? 443 : 80);
|
|
52
|
-
args.path = `${params.protocol}//${params.hostname}:${port}`;
|
|
53
|
-
}
|
|
54
|
-
args.path = resolve$1(cwd(), args.path);
|
|
55
|
-
if (args.schema && typeof args.schema === "object") {
|
|
56
|
-
const $ref = this.$refs._add(args.path);
|
|
57
|
-
$ref.value = args.schema;
|
|
58
|
-
$ref.pathType = pathType;
|
|
59
|
-
$ref.dynamicIdScope = usesDynamicIdScope($ref.value);
|
|
60
|
-
registerSchemaResources(this.$refs, $ref.path, $ref.value, $ref.pathType, $ref.dynamicIdScope);
|
|
61
|
-
promise = Promise.resolve(args.schema);
|
|
62
|
-
} else promise = parse$2(args.path, this.$refs, args.options);
|
|
63
|
-
try {
|
|
64
|
-
const result = await promise;
|
|
65
|
-
if (result !== null && typeof result === "object" && !Buffer.isBuffer(result)) {
|
|
66
|
-
this.schema = result;
|
|
67
|
-
return maybe(args.callback, Promise.resolve(this.schema));
|
|
68
|
-
} else if (args.options.continueOnError) {
|
|
69
|
-
this.schema = null;
|
|
70
|
-
return maybe(args.callback, Promise.resolve(this.schema));
|
|
71
|
-
} else throw new SyntaxError(`"${this.$refs._root$Ref.path || result}" is not a valid JSON Schema`);
|
|
72
|
-
} catch (err) {
|
|
73
|
-
if (!args.options.continueOnError || !isHandledError(err)) return maybe(args.callback, Promise.reject(err));
|
|
74
|
-
if (this.$refs._$refs[stripHash(args.path)]) this.$refs._$refs[stripHash(args.path)].addError(err);
|
|
75
|
-
return maybe(args.callback, Promise.resolve(null));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
static parse() {
|
|
79
|
-
const parser = new $RefParser();
|
|
80
|
-
return parser.parse.apply(parser, arguments);
|
|
81
|
-
}
|
|
82
|
-
async resolve() {
|
|
83
|
-
const args = normalizeArgs(arguments);
|
|
84
|
-
try {
|
|
85
|
-
await this.parse(args.path, args.schema, args.options);
|
|
86
|
-
await resolveExternal(this, args.options);
|
|
87
|
-
finalize(this);
|
|
88
|
-
return maybe(args.callback, Promise.resolve(this.$refs));
|
|
89
|
-
} catch (err) {
|
|
90
|
-
return maybe(args.callback, Promise.reject(err));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
static resolve() {
|
|
94
|
-
const instance = new $RefParser();
|
|
95
|
-
return instance.resolve.apply(instance, arguments);
|
|
96
|
-
}
|
|
97
|
-
static bundle() {
|
|
98
|
-
const instance = new $RefParser();
|
|
99
|
-
return instance.bundle.apply(instance, arguments);
|
|
100
|
-
}
|
|
101
|
-
async bundle() {
|
|
102
|
-
const args = normalizeArgs(arguments);
|
|
103
|
-
try {
|
|
104
|
-
await this.resolve(args.path, args.schema, args.options);
|
|
105
|
-
bundle$1(this, args.options);
|
|
106
|
-
finalize(this);
|
|
107
|
-
return maybe(args.callback, Promise.resolve(this.schema));
|
|
108
|
-
} catch (err) {
|
|
109
|
-
return maybe(args.callback, Promise.reject(err));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
static dereference() {
|
|
113
|
-
const instance = new $RefParser();
|
|
114
|
-
return instance.dereference.apply(instance, arguments);
|
|
115
|
-
}
|
|
116
|
-
async dereference() {
|
|
117
|
-
const args = normalizeArgs(arguments);
|
|
118
|
-
try {
|
|
119
|
-
await this.resolve(args.path, args.schema, args.options);
|
|
120
|
-
dereference_default(this, args.options);
|
|
121
|
-
finalize(this);
|
|
122
|
-
return maybe(args.callback, Promise.resolve(this.schema));
|
|
123
|
-
} catch (err) {
|
|
124
|
-
return maybe(args.callback, Promise.reject(err));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
function finalize(parser) {
|
|
129
|
-
if (JSONParserErrorGroup.getParserErrors(parser).length > 0) throw new JSONParserErrorGroup(parser);
|
|
130
|
-
}
|
|
131
|
-
$RefParser.parse;
|
|
132
|
-
$RefParser.resolve;
|
|
133
|
-
const bundle = $RefParser.bundle;
|
|
134
|
-
$RefParser.dereference;
|
|
135
|
-
//#endregion
|
|
136
|
-
export { bundle };
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { HTTPResolverOptions, JSONSchema, JSONSchemaObject, Plugin, ResolverOptions } from "./types/index.js";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.6_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.d.ts
|
|
4
|
-
type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;
|
|
5
|
-
interface BundleOptions {
|
|
6
|
-
/**
|
|
7
|
-
* A function, called for each path, which can return true to stop this path and all
|
|
8
|
-
* subpaths from being processed further. This is useful in schemas where some
|
|
9
|
-
* subpaths contain literal $ref keys that should not be changed.
|
|
10
|
-
*/
|
|
11
|
-
excludedPathMatcher?(path: string): boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Callback invoked during bundling.
|
|
14
|
-
*
|
|
15
|
-
* @argument {string} path - The path being processed (ie. the `$ref` string)
|
|
16
|
-
* @argument {JSONSchemaObject} value - The JSON-Schema that the `$ref` resolved to
|
|
17
|
-
* @argument {JSONSchemaObject} parent - The parent of the processed object
|
|
18
|
-
* @argument {string} parentPropName - The prop name of the parent object whose value was processed
|
|
19
|
-
*/
|
|
20
|
-
onBundle?(path: string, value: JSONSchemaObject, parent?: JSONSchemaObject, parentPropName?: string): void;
|
|
21
|
-
/**
|
|
22
|
-
* Whether to optimize internal `$ref` paths by following intermediate `$ref` chains and
|
|
23
|
-
* rewriting them to point directly to the final target. When `false`, intermediate `$ref`
|
|
24
|
-
* indirections are preserved as-is.
|
|
25
|
-
*
|
|
26
|
-
* Default: `true`
|
|
27
|
-
*/
|
|
28
|
-
optimizeInternalRefs?: boolean;
|
|
29
|
-
}
|
|
30
|
-
interface DereferenceOptions {
|
|
31
|
-
/**
|
|
32
|
-
* Determines whether circular `$ref` pointers are handled.
|
|
33
|
-
*
|
|
34
|
-
* If set to `false`, then a `ReferenceError` will be thrown if the schema contains any circular references.
|
|
35
|
-
*
|
|
36
|
-
* If set to `"ignore"`, then circular references will simply be ignored. No error will be thrown, but the `$Refs.circular` property will still be set to `true`.
|
|
37
|
-
*/
|
|
38
|
-
circular?: boolean | "ignore";
|
|
39
|
-
/**
|
|
40
|
-
* A function, called for each path, which can return true to stop this path and all
|
|
41
|
-
* subpaths from being dereferenced further. This is useful in schemas where some
|
|
42
|
-
* subpaths contain literal $ref keys that should not be dereferenced.
|
|
43
|
-
*/
|
|
44
|
-
excludedPathMatcher?(path: string): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Callback invoked during circular reference detection.
|
|
47
|
-
*
|
|
48
|
-
* @argument {string} path - The path that is circular (ie. the `$ref` string)
|
|
49
|
-
*/
|
|
50
|
-
onCircular?(path: string): void;
|
|
51
|
-
/**
|
|
52
|
-
* Callback invoked during dereferencing.
|
|
53
|
-
*
|
|
54
|
-
* @argument {string} path - The path being dereferenced (ie. the `$ref` string)
|
|
55
|
-
* @argument {JSONSchemaObject} value - The JSON-Schema that the `$ref` resolved to
|
|
56
|
-
* @argument {JSONSchemaObject} parent - The parent of the dereferenced object
|
|
57
|
-
* @argument {string} parentPropName - The prop name of the parent object whose value was dereferenced
|
|
58
|
-
*/
|
|
59
|
-
onDereference?(path: string, value: JSONSchemaObject, parent?: JSONSchemaObject, parentPropName?: string): void;
|
|
60
|
-
/**
|
|
61
|
-
* An array of properties to preserve when dereferencing a `$ref` schema. Useful if you want to
|
|
62
|
-
* enforce non-standard dereferencing behavior like present in the OpenAPI 3.1 specification where
|
|
63
|
-
* `description` and `summary` properties are preserved when alongside a `$ref` pointer.
|
|
64
|
-
*
|
|
65
|
-
* If none supplied then no properties will be preserved and the object will be fully replaced
|
|
66
|
-
* with the dereferenced `$ref`.
|
|
67
|
-
*/
|
|
68
|
-
preservedProperties?: string[];
|
|
69
|
-
/**
|
|
70
|
-
* Whether a reference should resolve relative to its directory/path, or from the cwd
|
|
71
|
-
*
|
|
72
|
-
* Default: `relative`
|
|
73
|
-
*/
|
|
74
|
-
externalReferenceResolution?: "relative" | "root";
|
|
75
|
-
/**
|
|
76
|
-
* Whether duplicate keys should be merged when dereferencing objects.
|
|
77
|
-
*
|
|
78
|
-
* Default: `true`
|
|
79
|
-
*/
|
|
80
|
-
mergeKeys?: boolean;
|
|
81
|
-
/**
|
|
82
|
-
* The maximum recursion depth for dereferencing nested schemas.
|
|
83
|
-
* If the schema nesting exceeds this depth, a RangeError will be thrown
|
|
84
|
-
* with a descriptive message instead of crashing with a stack overflow.
|
|
85
|
-
*
|
|
86
|
-
* Default: 500
|
|
87
|
-
*/
|
|
88
|
-
maxDepth?: number;
|
|
89
|
-
/**
|
|
90
|
-
* Whether to create independent clones of each `$ref` target value instead of
|
|
91
|
-
* reusing the same JS object reference. When `false` (the default), multiple
|
|
92
|
-
* `$ref` pointers that resolve to the same value will all share the same object
|
|
93
|
-
* in memory, so modifying one will affect all others. When `true`, each `$ref`
|
|
94
|
-
* replacement gets its own deep copy, preventing unintended side effects from
|
|
95
|
-
* post-dereference mutations.
|
|
96
|
-
*
|
|
97
|
-
* Note: circular references are never cloned — they always maintain reference
|
|
98
|
-
* equality to correctly represent the circular structure.
|
|
99
|
-
*
|
|
100
|
-
* Default: `false`
|
|
101
|
-
*/
|
|
102
|
-
cloneReferences?: boolean;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Options that determine how JSON schemas are parsed, resolved, and dereferenced.
|
|
106
|
-
*
|
|
107
|
-
* @param [options] - Overridden options
|
|
108
|
-
* @class
|
|
109
|
-
*/
|
|
110
|
-
interface $RefParserOptions<S extends object = JSONSchema> {
|
|
111
|
-
/**
|
|
112
|
-
* The `parse` options determine how different types of files will be parsed.
|
|
113
|
-
*
|
|
114
|
-
* JSON Schema `$Ref` Parser comes with built-in JSON, YAML, plain-text, and binary parsers, any of which you can configure or disable. You can also add your own custom parsers if you want.
|
|
115
|
-
*/
|
|
116
|
-
parse: {
|
|
117
|
-
json?: Plugin | boolean;
|
|
118
|
-
yaml?: Plugin | boolean;
|
|
119
|
-
binary?: Plugin | boolean;
|
|
120
|
-
text?: Plugin | boolean;
|
|
121
|
-
[key: string]: Plugin | boolean | undefined;
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* The `resolve` options control how JSON Schema $Ref Parser will resolve file paths and URLs, and how those files will be read/downloaded.
|
|
125
|
-
*
|
|
126
|
-
* JSON Schema `$Ref` Parser comes with built-in support for HTTP and HTTPS, as well as support for local files (when running in Node.js). You can configure or disable either of these built-in resolvers. You can also add your own custom resolvers if you want.
|
|
127
|
-
*/
|
|
128
|
-
resolve: {
|
|
129
|
-
/**
|
|
130
|
-
* Determines whether external $ref pointers will be resolved. If this option is disabled, then external `$ref` pointers will simply be ignored.
|
|
131
|
-
*/
|
|
132
|
-
external?: boolean;
|
|
133
|
-
file?: Partial<ResolverOptions<S>> | boolean;
|
|
134
|
-
http?: HTTPResolverOptions<S> | boolean;
|
|
135
|
-
} & {
|
|
136
|
-
[key: string]: Partial<ResolverOptions<S>> | HTTPResolverOptions<S> | boolean | undefined;
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* By default, JSON Schema $Ref Parser throws the first error it encounters. Setting `continueOnError` to `true`
|
|
140
|
-
* causes it to keep processing as much as possible and then throw a single error that contains all errors
|
|
141
|
-
* that were encountered.
|
|
142
|
-
*/
|
|
143
|
-
continueOnError: boolean;
|
|
144
|
-
/**
|
|
145
|
-
* The `bundle` options control how JSON Schema `$Ref` Parser will process `$ref` pointers within the JSON schema.
|
|
146
|
-
*/
|
|
147
|
-
bundle: BundleOptions;
|
|
148
|
-
/**
|
|
149
|
-
* The `dereference` options control how JSON Schema `$Ref` Parser will dereference `$ref` pointers within the JSON schema.
|
|
150
|
-
*/
|
|
151
|
-
dereference: DereferenceOptions;
|
|
152
|
-
/**
|
|
153
|
-
* Whether to clone the schema before dereferencing it.
|
|
154
|
-
* This is useful when you want to dereference the same schema multiple times, but you don't want to modify the original schema.
|
|
155
|
-
* Default: `true` due to mutating the input being the default behavior historically
|
|
156
|
-
*/
|
|
157
|
-
mutateInputSchema?: boolean;
|
|
158
|
-
/**
|
|
159
|
-
* The maximum amount of time (in milliseconds) that JSON Schema $Ref Parser will spend dereferencing a single schema.
|
|
160
|
-
* It will throw a timeout error if the operation takes longer than this.
|
|
161
|
-
*/
|
|
162
|
-
timeoutMs?: number;
|
|
163
|
-
}
|
|
164
|
-
type ParserOptions<S extends object = JSONSchema> = DeepPartial<$RefParserOptions<S>>;
|
|
165
|
-
//#endregion
|
|
166
|
-
export { ParserOptions };
|