@fumadocs/api-docs 0.0.3 → 0.1.0
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/css/generated/shared.css +1 -1
- package/dist/components/accordion.d.ts +9 -6
- package/dist/components/accordion.js +16 -12
- package/dist/components/collapsible.d.ts +16 -0
- package/dist/components/collapsible.js +16 -0
- package/dist/components/dialog.d.ts +9 -9
- package/dist/components/dialog.js +12 -12
- package/dist/components/input.d.ts +8 -3
- package/dist/components/input.js +3 -4
- package/dist/components/playground/inputs.js +42 -30
- package/dist/components/popover.d.ts +15 -0
- package/dist/components/popover.js +23 -0
- package/dist/components/schema/client.js +34 -32
- package/dist/components/select-tab.js +3 -5
- package/dist/components/select.d.ts +46 -12
- package/dist/components/select.js +78 -66
- 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 +2 -2
- 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 +7 -49
- 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 +12 -14
- 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
package/dist/schema/sample.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { isPlainObject } from "../utils/is-plain-object.js";
|
|
2
|
+
import { mergeDeep } from "../utils/deep-merge.js";
|
|
2
3
|
import { resolveRefSync } from "./resolve-ref.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof RegExp) && !(value instanceof Date);
|
|
8
|
-
}
|
|
9
|
-
});
|
|
4
|
+
//#region src/schema/sample.ts
|
|
5
|
+
/**
|
|
6
|
+
* inspired by https://github.com/Redocly/openapi-sampler (MIT)
|
|
7
|
+
*/
|
|
10
8
|
const SKIP = Symbol("skip");
|
|
11
9
|
const defaultOptions = {
|
|
12
10
|
skipReadOnly: false,
|
package/dist/utils/cn.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cn } from "cnfast";
|
|
2
2
|
export { cn };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { require_deepmerge } from "../node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js";
|
|
2
|
+
import { isPlainObject } from "./is-plain-object.js";
|
|
3
|
+
const mergeDeep = (0, require_deepmerge().deepmerge)({
|
|
4
|
+
all: true,
|
|
5
|
+
isMergeableObject: isPlainObject
|
|
6
|
+
});
|
|
7
|
+
//#endregion
|
|
8
|
+
export { mergeDeep };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fumadocs/api-docs",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Shared utils for API docs generation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -23,10 +23,12 @@
|
|
|
23
23
|
"./auto-anchor/client": "./dist/auto-anchor/client.js",
|
|
24
24
|
"./codegen": "./dist/codegen.js",
|
|
25
25
|
"./components/accordion": "./dist/components/accordion.js",
|
|
26
|
+
"./components/collapsible": "./dist/components/collapsible.js",
|
|
26
27
|
"./components/dialog": "./dist/components/dialog.js",
|
|
27
28
|
"./components/input": "./dist/components/input.js",
|
|
28
29
|
"./components/playground/inputs": "./dist/components/playground/inputs.js",
|
|
29
30
|
"./components/playground/schema": "./dist/components/playground/schema.js",
|
|
31
|
+
"./components/popover": "./dist/components/popover.js",
|
|
30
32
|
"./components/schema": "./dist/components/schema/index.js",
|
|
31
33
|
"./components/schema/client": "./dist/components/schema/client.js",
|
|
32
34
|
"./components/select": "./dist/components/select.js",
|
|
@@ -50,28 +52,25 @@
|
|
|
50
52
|
"access": "public"
|
|
51
53
|
},
|
|
52
54
|
"dependencies": {
|
|
55
|
+
"@base-ui/react": "^1.6.0",
|
|
53
56
|
"@fuma-translate/react": "^1.0.2",
|
|
54
|
-
"@radix-ui/react-accordion": "^1.2.14",
|
|
55
|
-
"@radix-ui/react-dialog": "^1.1.17",
|
|
56
|
-
"@radix-ui/react-select": "^2.3.1",
|
|
57
57
|
"class-variance-authority": "^0.7.1",
|
|
58
|
+
"cnfast": "^0.0.8",
|
|
58
59
|
"github-slugger": "^2.0.0",
|
|
59
|
-
"js-yaml": "^
|
|
60
|
-
"lucide-react": "^1.
|
|
61
|
-
"
|
|
62
|
-
"@fumari/stf": "1.0.5"
|
|
60
|
+
"js-yaml": "^5.2.1",
|
|
61
|
+
"lucide-react": "^1.23.0",
|
|
62
|
+
"@fumari/stf": "1.1.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@apidevtools/json-schema-ref-parser": "^15.3.6",
|
|
66
65
|
"@fastify/deepmerge": "^3.2.1",
|
|
67
|
-
"@tailwindcss/oxide": "^4.3.
|
|
68
|
-
"@types/node": "
|
|
66
|
+
"@tailwindcss/oxide": "^4.3.2",
|
|
67
|
+
"@types/node": "26.1.0",
|
|
69
68
|
"@types/react": "^19.2.17",
|
|
70
69
|
"ajv": "^8.20.0",
|
|
71
70
|
"json-schema-typed": "^8.0.2",
|
|
72
71
|
"tsdown": "0.22.3",
|
|
73
|
-
"fumadocs-
|
|
74
|
-
"fumadocs-
|
|
72
|
+
"fumadocs-core": "16.11.0",
|
|
73
|
+
"fumadocs-ui": "npm:@fumadocs/base-ui@16.11.0",
|
|
75
74
|
"tsconfig": "0.0.0"
|
|
76
75
|
},
|
|
77
76
|
"peerDependencies": {
|
|
@@ -91,7 +90,6 @@
|
|
|
91
90
|
}
|
|
92
91
|
},
|
|
93
92
|
"inlinedDependencies": {
|
|
94
|
-
"@apidevtools/json-schema-ref-parser": "15.3.6",
|
|
95
93
|
"@fastify/deepmerge": "3.2.1",
|
|
96
94
|
"ajv": "8.20.0",
|
|
97
95
|
"fast-deep-equal": "3.1.3",
|
|
@@ -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 };
|