@fumadocs/api-docs 0.0.2 → 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/css/generated/shared.css +1 -1
- package/dist/components/schema/client.d.ts +16 -1
- package/dist/components/schema/client.js +17 -12
- package/dist/components/schema/index.d.ts +13 -20
- package/dist/components/schema/index.js +82 -60
- 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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/pointer.js +24 -53
- package/dist/ref-parser/ref.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/url.js +4 -113
- 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/schema/to-string.js +6 -0
- package/dist/utils/cn.js +1 -1
- package/dist/utils/deep-merge.js +8 -0
- package/package.json +18 -17
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@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.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +0 -112
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@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.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +0 -5
|
@@ -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.5_@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.5_@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 };
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import json_default from "./parsers/json.js";
|
|
2
|
-
import yaml_default from "./parsers/yaml.js";
|
|
3
|
-
import text_default from "./parsers/text.js";
|
|
4
|
-
import binary_default from "./parsers/binary.js";
|
|
5
|
-
import file_default from "./resolvers/file.js";
|
|
6
|
-
import http_default from "./resolvers/http.js";
|
|
7
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js
|
|
8
|
-
const getJsonSchemaRefParserDefaultOptions = () => {
|
|
9
|
-
return {
|
|
10
|
-
/**
|
|
11
|
-
* Determines how different types of files will be parsed.
|
|
12
|
-
*
|
|
13
|
-
* You can add additional parsers of your own, replace an existing one with
|
|
14
|
-
* your own implementation, or disable any parser by setting it to false.
|
|
15
|
-
*/
|
|
16
|
-
parse: {
|
|
17
|
-
json: { ...json_default },
|
|
18
|
-
yaml: { ...yaml_default },
|
|
19
|
-
text: { ...text_default },
|
|
20
|
-
binary: { ...binary_default }
|
|
21
|
-
},
|
|
22
|
-
/**
|
|
23
|
-
* Determines how JSON References will be resolved.
|
|
24
|
-
*
|
|
25
|
-
* You can add additional resolvers of your own, replace an existing one with
|
|
26
|
-
* your own implementation, or disable any resolver by setting it to false.
|
|
27
|
-
*/
|
|
28
|
-
resolve: {
|
|
29
|
-
file: { ...file_default },
|
|
30
|
-
http: { ...http_default },
|
|
31
|
-
/**
|
|
32
|
-
* Determines whether external $ref pointers will be resolved.
|
|
33
|
-
* If this option is disabled, then none of above resolvers will be called.
|
|
34
|
-
* Instead, external $ref pointers will simply be ignored.
|
|
35
|
-
*
|
|
36
|
-
* @type {boolean}
|
|
37
|
-
*/
|
|
38
|
-
external: true
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* By default, JSON Schema $Ref Parser throws the first error it encounters. Setting `continueOnError` to `true`
|
|
42
|
-
* causes it to keep processing as much as possible and then throw a single error that contains all errors
|
|
43
|
-
* that were encountered.
|
|
44
|
-
*/
|
|
45
|
-
continueOnError: false,
|
|
46
|
-
/**
|
|
47
|
-
* Determines the types of JSON references that are allowed.
|
|
48
|
-
*/
|
|
49
|
-
bundle: {
|
|
50
|
-
/**
|
|
51
|
-
* A function, called for each path, which can return true to stop this path and all
|
|
52
|
-
* subpaths from being processed further. This is useful in schemas where some
|
|
53
|
-
* subpaths contain literal $ref keys that should not be changed.
|
|
54
|
-
*
|
|
55
|
-
* @type {function}
|
|
56
|
-
*/
|
|
57
|
-
excludedPathMatcher: () => false },
|
|
58
|
-
/**
|
|
59
|
-
* Determines the types of JSON references that are allowed.
|
|
60
|
-
*/
|
|
61
|
-
dereference: {
|
|
62
|
-
/**
|
|
63
|
-
* Dereference circular (recursive) JSON references?
|
|
64
|
-
* If false, then a {@link ReferenceError} will be thrown if a circular reference is found.
|
|
65
|
-
* If "ignore", then circular references will not be dereferenced.
|
|
66
|
-
*
|
|
67
|
-
* @type {boolean|string}
|
|
68
|
-
*/
|
|
69
|
-
circular: true,
|
|
70
|
-
/**
|
|
71
|
-
* A function, called for each path, which can return true to stop this path and all
|
|
72
|
-
* subpaths from being dereferenced further. This is useful in schemas where some
|
|
73
|
-
* subpaths contain literal $ref keys that should not be dereferenced.
|
|
74
|
-
*
|
|
75
|
-
* @type {function}
|
|
76
|
-
*/
|
|
77
|
-
excludedPathMatcher: () => false,
|
|
78
|
-
referenceResolution: "relative",
|
|
79
|
-
mergeKeys: true
|
|
80
|
-
},
|
|
81
|
-
mutateInputSchema: true
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
const getNewOptions = (options) => {
|
|
85
|
-
const newOptions = getJsonSchemaRefParserDefaultOptions();
|
|
86
|
-
if (options) merge(newOptions, options);
|
|
87
|
-
return newOptions;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Merges the properties of the source object into the target object.
|
|
91
|
-
*
|
|
92
|
-
* @param target - The object that we're populating
|
|
93
|
-
* @param source - The options that are being merged
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
function merge(target, source) {
|
|
97
|
-
if (isMergeable(source)) {
|
|
98
|
-
const keys = Object.keys(source).filter((key) => ![
|
|
99
|
-
"__proto__",
|
|
100
|
-
"constructor",
|
|
101
|
-
"prototype"
|
|
102
|
-
].includes(key));
|
|
103
|
-
for (let i = 0; i < keys.length; i++) {
|
|
104
|
-
const key = keys[i];
|
|
105
|
-
const sourceSetting = source[key];
|
|
106
|
-
const targetSetting = target[key];
|
|
107
|
-
if (isMergeable(sourceSetting)) target[key] = merge(targetSetting || {}, sourceSetting);
|
|
108
|
-
else if (sourceSetting !== void 0) target[key] = sourceSetting;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return target;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Determines whether the given value can be merged,
|
|
115
|
-
* or if it is a scalar value that should just override the target value.
|
|
116
|
-
*
|
|
117
|
-
* @param val
|
|
118
|
-
* @returns
|
|
119
|
-
*/
|
|
120
|
-
function isMergeable(val) {
|
|
121
|
-
return val && typeof val === "object" && !Array.isArray(val) && !(val instanceof RegExp) && !(val instanceof Date);
|
|
122
|
-
}
|
|
123
|
-
//#endregion
|
|
124
|
-
export { getJsonSchemaRefParserDefaultOptions, getNewOptions };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js
|
|
2
|
-
const BINARY_REGEXP = /\.(jpeg|jpg|gif|png|bmp|ico)$/i;
|
|
3
|
-
var binary_default = {
|
|
4
|
-
/**
|
|
5
|
-
* The order that this parser will run, in relation to other parsers.
|
|
6
|
-
*/
|
|
7
|
-
order: 400,
|
|
8
|
-
/**
|
|
9
|
-
* Whether to allow "empty" files (zero bytes).
|
|
10
|
-
*/
|
|
11
|
-
allowEmpty: true,
|
|
12
|
-
/**
|
|
13
|
-
* Determines whether this parser can parse a given file reference.
|
|
14
|
-
* Parsers that return true will be tried, in order, until one successfully parses the file.
|
|
15
|
-
* Parsers that return false will be skipped, UNLESS all parsers returned false, in which case
|
|
16
|
-
* every parser will be tried.
|
|
17
|
-
*/
|
|
18
|
-
canParse(file) {
|
|
19
|
-
return Buffer.isBuffer(file.data) && BINARY_REGEXP.test(file.url);
|
|
20
|
-
},
|
|
21
|
-
/**
|
|
22
|
-
* Parses the given data as a Buffer (byte array).
|
|
23
|
-
*/
|
|
24
|
-
parse(file) {
|
|
25
|
-
if (Buffer.isBuffer(file.data)) return file.data;
|
|
26
|
-
else return Buffer.from(file.data);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
export { binary_default as default };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ParserError } from "../util/errors.js";
|
|
2
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js
|
|
3
|
-
const TEXT_REGEXP = /\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i;
|
|
4
|
-
var text_default = {
|
|
5
|
-
/**
|
|
6
|
-
* The order that this parser will run, in relation to other parsers.
|
|
7
|
-
*/
|
|
8
|
-
order: 300,
|
|
9
|
-
/**
|
|
10
|
-
* Whether to allow "empty" files (zero bytes).
|
|
11
|
-
*/
|
|
12
|
-
allowEmpty: true,
|
|
13
|
-
/**
|
|
14
|
-
* The encoding that the text is expected to be in.
|
|
15
|
-
*/
|
|
16
|
-
encoding: "utf8",
|
|
17
|
-
/**
|
|
18
|
-
* Determines whether this parser can parse a given file reference.
|
|
19
|
-
* Parsers that return true will be tried, in order, until one successfully parses the file.
|
|
20
|
-
* Parsers that return false will be skipped, UNLESS all parsers returned false, in which case
|
|
21
|
-
* every parser will be tried.
|
|
22
|
-
*/
|
|
23
|
-
canParse(file) {
|
|
24
|
-
return (typeof file.data === "string" || Buffer.isBuffer(file.data)) && TEXT_REGEXP.test(file.url);
|
|
25
|
-
},
|
|
26
|
-
/**
|
|
27
|
-
* Parses the given file as text
|
|
28
|
-
*/
|
|
29
|
-
parse(file) {
|
|
30
|
-
if (typeof file.data === "string") return file.data;
|
|
31
|
-
else if (Buffer.isBuffer(file.data)) return file.data.toString(this.encoding);
|
|
32
|
-
else throw new ParserError("data is not text", file.url);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
//#endregion
|
|
36
|
-
export { text_default as default };
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { JSONSchema } from "./types/index.js";
|
|
2
|
-
import { ParserOptions } from "./options.js";
|
|
3
|
-
import { $Ref } from "./ref.js";
|
|
4
|
-
import { JSONSchema4Type, JSONSchema6Type, JSONSchema7Type } from "json-schema";
|
|
5
|
-
|
|
6
|
-
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* This class represents a single JSON pointer and its resolved value.
|
|
9
|
-
*
|
|
10
|
-
* @param $ref
|
|
11
|
-
* @param path
|
|
12
|
-
* @param [friendlyPath] - The original user-specified path (used for error messages)
|
|
13
|
-
* @class
|
|
14
|
-
*/
|
|
15
|
-
declare class Pointer<S extends object = JSONSchema, O extends ParserOptions<S> = ParserOptions<S>> {
|
|
16
|
-
/**
|
|
17
|
-
* The {@link $Ref} object that contains this {@link Pointer} object.
|
|
18
|
-
*/
|
|
19
|
-
$ref: $Ref<S, O>;
|
|
20
|
-
/**
|
|
21
|
-
* The file path or URL, containing the JSON pointer in the hash.
|
|
22
|
-
* This path is relative to the path of the main JSON schema file.
|
|
23
|
-
*/
|
|
24
|
-
path: string;
|
|
25
|
-
/**
|
|
26
|
-
* The original path or URL, used for error messages.
|
|
27
|
-
*/
|
|
28
|
-
originalPath: string;
|
|
29
|
-
/**
|
|
30
|
-
* The current base URI used to resolve nested $ref pointers while walking this pointer.
|
|
31
|
-
*/
|
|
32
|
-
scopeBase: string;
|
|
33
|
-
/**
|
|
34
|
-
* The value of the JSON pointer.
|
|
35
|
-
* Can be any JSON type, not just objects. Unknown file types are represented as Buffers (byte arrays).
|
|
36
|
-
*/
|
|
37
|
-
value: any;
|
|
38
|
-
/**
|
|
39
|
-
* Indicates whether the pointer references itself.
|
|
40
|
-
*/
|
|
41
|
-
circular: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* The number of indirect references that were traversed to resolve the value.
|
|
44
|
-
* Resolving a single pointer may require resolving multiple $Refs.
|
|
45
|
-
*/
|
|
46
|
-
indirections: number;
|
|
47
|
-
constructor($ref: $Ref<S, O>, path: string, friendlyPath?: string);
|
|
48
|
-
/**
|
|
49
|
-
* Resolves the value of a nested property within the given object.
|
|
50
|
-
*
|
|
51
|
-
* @param obj - The object that will be crawled
|
|
52
|
-
* @param options
|
|
53
|
-
* @param pathFromRoot - the path of place that initiated resolving
|
|
54
|
-
*
|
|
55
|
-
* @returns
|
|
56
|
-
* Returns a JSON pointer whose {@link Pointer#value} is the resolved value.
|
|
57
|
-
* If resolving this value required resolving other JSON references, then
|
|
58
|
-
* the {@link Pointer#$ref} and {@link Pointer#path} will reflect the resolution path
|
|
59
|
-
* of the resolved value.
|
|
60
|
-
*/
|
|
61
|
-
resolve(obj: S, options?: O, pathFromRoot?: string): this;
|
|
62
|
-
/**
|
|
63
|
-
* Sets the value of a nested property within the given object.
|
|
64
|
-
*
|
|
65
|
-
* @param obj - The object that will be crawled
|
|
66
|
-
* @param value - the value to assign
|
|
67
|
-
* @param options
|
|
68
|
-
*
|
|
69
|
-
* @returns
|
|
70
|
-
* Returns the modified object, or an entirely new object if the entire object is overwritten.
|
|
71
|
-
*/
|
|
72
|
-
set(obj: S, value: JSONSchema4Type | JSONSchema6Type | JSONSchema7Type, options?: O): string | number | boolean | import("json-schema").JSONSchema4Object | import("json-schema").JSONSchema4Array | S | null;
|
|
73
|
-
/**
|
|
74
|
-
* Parses a JSON pointer (or a path containing a JSON pointer in the hash)
|
|
75
|
-
* and returns an array of the pointer's tokens.
|
|
76
|
-
* (e.g. "schema.json#/definitions/person/name" => ["definitions", "person", "name"])
|
|
77
|
-
*
|
|
78
|
-
* The pointer is parsed according to RFC 6901
|
|
79
|
-
* {@link https://tools.ietf.org/html/rfc6901#section-3}
|
|
80
|
-
*
|
|
81
|
-
* @param path
|
|
82
|
-
* @param [originalPath]
|
|
83
|
-
* @returns
|
|
84
|
-
*/
|
|
85
|
-
static parse(path: string, originalPath?: string): string[];
|
|
86
|
-
/**
|
|
87
|
-
* Creates a JSON pointer path, by joining one or more tokens to a base path.
|
|
88
|
-
*
|
|
89
|
-
* @param base - The base path (e.g. "schema.json#/definitions/person")
|
|
90
|
-
* @param tokens - The token(s) to append (e.g. ["name", "first"])
|
|
91
|
-
* @returns
|
|
92
|
-
*/
|
|
93
|
-
static join(base: string, tokens: string | string[]): string;
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
export { Pointer };
|