fumadocs-openapi 10.10.0 → 10.10.2
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 -4
- package/dist/_openapi/types.d.ts +27 -1
- package/dist/index.d.ts +5 -4
- 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/bundle.js +239 -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/dereference.js +187 -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/index.js +136 -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/normalize-args.js +41 -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/options.js +124 -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/parse.js +109 -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/parsers/binary.js +30 -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/parsers/json.js +46 -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/parsers/text.js +36 -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/parsers/yaml.js +49 -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/pointer.js +242 -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.js +247 -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/refs.js +210 -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/resolve-external.js +100 -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/resolvers/file.js +41 -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/resolvers/http.js +112 -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/util/convert-path-to-posix.js +8 -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/util/errors.js +146 -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/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/util/maybe.js +18 -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/util/next.js +11 -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/util/plugins.js +99 -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/util/schema-resources.js +30 -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/util/url.js +315 -0
- package/dist/playground/client.d.ts +1 -1
- package/dist/requests/generators/all.d.ts +1 -1
- package/dist/requests/generators/all.js +1 -0
- package/dist/types.d.ts +3 -13
- package/dist/ui/base.d.ts +1 -1
- package/dist/ui/base.js +4 -3
- package/dist/ui/client/index.d.ts +15 -10
- package/dist/ui/components/heading.js +9 -1
- package/dist/ui/contexts/api.js +1 -7
- package/dist/ui/create-client.d.ts +2 -1
- package/dist/ui/create-client.js +8 -9
- package/dist/ui/operation/request-tabs.js +4 -1
- package/dist/ui/operation/response-tabs.js +4 -1
- package/dist/ui/operation/usage-tabs/index.js +2 -8
- package/dist/utils/document/process.js +7 -12
- package/dist/utils/pages/builder.d.ts +2 -4
- package/dist/utils/pages/preset-auto.d.ts +1 -2
- package/package.json +4 -8
- package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/general/create-limiter.js +0 -43
- package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/object/is-object.js +0 -27
- package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/object/prevent-pollution.js +0 -33
- package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/queue/queue.js +0 -106
- package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/string/generate-hash.js +0 -120
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/bundle.js +0 -357
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/fetch-urls/index.js +0 -73
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/node.js +0 -3
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/parse-yaml/index.js +0 -1
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/read-files/index.js +0 -51
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/value-generator.js +0 -102
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/convert-to-local-ref.js +0 -24
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/escape-json-pointer.js +0 -11
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-schemas.js +0 -44
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-segments-from-path.js +0 -10
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-value-by-path.js +0 -42
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-file-path.js +0 -23
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-http-url.js +0 -23
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-json-object.js +0 -28
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-yaml.js +0 -21
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/normalize.js +0 -33
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/resolve-reference-path.js +0 -30
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/set-value-at-path.js +0 -70
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/to-relative-path.js +0 -33
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/unescape-json-pointer.js +0 -12
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +0 -19
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +0 -430
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-collection.js +0 -50
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-doc.js +0 -39
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-node.js +0 -85
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-scalar.js +0 -57
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/composer.js +0 -193
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-map.js +0 -82
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +0 -174
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +0 -40
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-end.js +0 -36
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +0 -153
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +0 -203
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-props.js +0 -105
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-contains-newline.js +0 -27
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +0 -25
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +0 -10
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-map-includes.js +0 -10
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/Document.js +0 -277
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/anchors.js +0 -62
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/applyReviver.js +0 -38
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/createNode.js +0 -61
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/directives.js +0 -163
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/errors.js +0 -48
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/index.js +0 -16
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/log.js +0 -6
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Alias.js +0 -92
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Collection.js +0 -117
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Node.js +0 -32
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Pair.js +0 -29
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Scalar.js +0 -24
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/YAMLMap.js +0 -106
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +0 -104
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +0 -49
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/identity.js +0 -33
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/toJS.js +0 -35
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst-scalar.js +0 -3
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst-visit.js +0 -89
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst.js +0 -40
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/lexer.js +0 -529
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/line-counter.js +0 -45
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/parser.js +0 -859
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/public-api.js +0 -44
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/Schema.js +0 -27
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/map.js +0 -16
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/null.js +0 -13
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/seq.js +0 -16
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/string.js +0 -14
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/bool.js +0 -17
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/float.js +0 -38
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/int.js +0 -37
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/schema.js +0 -23
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/json/schema.js +0 -61
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/tags.js +0 -81
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +0 -52
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +0 -24
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +0 -41
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +0 -70
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +0 -39
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +0 -60
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +0 -56
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +0 -39
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +0 -65
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +0 -79
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +0 -111
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringify.js +0 -105
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +0 -116
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyComment.js +0 -16
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +0 -59
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +0 -19
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyPair.js +0 -95
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyString.js +0 -222
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/visit.js +0 -187
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/index.js +0 -16
package/css/generated/shared.css
CHANGED
|
@@ -192,6 +192,7 @@
|
|
|
192
192
|
@source inline("could");
|
|
193
193
|
@source inline("createAutoPreset");
|
|
194
194
|
@source inline("createCodeSample");
|
|
195
|
+
@source inline("createCodeUsageGeneratorRegistry");
|
|
195
196
|
@source inline("createContext");
|
|
196
197
|
@source inline("createMethod");
|
|
197
198
|
@source inline("createProxy");
|
|
@@ -397,7 +398,6 @@
|
|
|
397
398
|
@source inline("ghost");
|
|
398
399
|
@source inline("github-dark");
|
|
399
400
|
@source inline("github-light");
|
|
400
|
-
@source inline("github-slugger");
|
|
401
401
|
@source inline("given");
|
|
402
402
|
@source inline("grant_type");
|
|
403
403
|
@source inline("green");
|
|
@@ -617,7 +617,6 @@
|
|
|
617
617
|
@source inline("openApiData");
|
|
618
618
|
@source inline("openIdConnect");
|
|
619
619
|
@source inline("openapi");
|
|
620
|
-
@source inline("openapi-types");
|
|
621
620
|
@source inline("openid");
|
|
622
621
|
@source inline("operation");
|
|
623
622
|
@source inline("operationId");
|
|
@@ -923,8 +922,6 @@
|
|
|
923
922
|
@source inline("slot");
|
|
924
923
|
@source inline("slotType");
|
|
925
924
|
@source inline("slots");
|
|
926
|
-
@source inline("slug");
|
|
927
|
-
@source inline("slugger");
|
|
928
925
|
@source inline("sm");
|
|
929
926
|
@source inline("sm:flex-row");
|
|
930
927
|
@source inline("sm:gap-2");
|
package/dist/_openapi/types.d.ts
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
//#region src/_openapi/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* These types are copied from openapi-types, with two modifications:
|
|
4
|
+
*
|
|
5
|
+
* - all attributes are optional, you can't rely on the specification for user input
|
|
6
|
+
* - extensions (basically any attributes, not only prefixed with an `x-`) are allowed
|
|
7
|
+
*
|
|
8
|
+
* We deal with user input and can't assume they really stick to any official specification.
|
|
9
|
+
*/
|
|
10
|
+
/** any other attribute, for example x-* extensions */
|
|
11
|
+
declare namespace OpenAPI {
|
|
12
|
+
type Document<T = {}> = OpenAPIV2.Document<T> | OpenAPIV3.Document<T> | OpenAPIV3_1.Document<T> | OpenAPIV3_2.Document<T>;
|
|
13
|
+
type Operation<T = {}> = OpenAPIV2.OperationObject<T> | OpenAPIV3.OperationObject<T> | OpenAPIV3_1.OperationObject<T> | OpenAPIV3_2.OperationObject<T>;
|
|
14
|
+
type Request = {
|
|
15
|
+
body?: any;
|
|
16
|
+
headers?: object;
|
|
17
|
+
params?: object;
|
|
18
|
+
query?: object;
|
|
19
|
+
};
|
|
20
|
+
type ResponseObject = OpenAPIV2.ResponseObject | OpenAPIV3.ResponseObject | OpenAPIV3_1.ResponseObject | OpenAPIV3_2.ResponseObject;
|
|
21
|
+
type HeaderObject = OpenAPIV2.HeaderObject | OpenAPIV3.HeaderObject | OpenAPIV3_1.HeaderObject | OpenAPIV3_2.HeaderObject;
|
|
22
|
+
type Parameter = OpenAPIV3_2.ReferenceObject | OpenAPIV3_2.ParameterObject | OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.ParameterObject | OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject | OpenAPIV2.ReferenceObject | OpenAPIV2.Parameter;
|
|
23
|
+
type Parameters = (OpenAPIV3_2.ReferenceObject | OpenAPIV3_2.ParameterObject)[] | (OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.ParameterObject)[] | (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[] | (OpenAPIV2.ReferenceObject | OpenAPIV2.Parameter)[];
|
|
24
|
+
type ExampleObject = OpenAPIV2.ExampleObject | OpenAPIV3.ExampleObject | OpenAPIV3_1.ExampleObject | OpenAPIV3_2.ExampleObject;
|
|
25
|
+
type SchemaObject = OpenAPIV2.SchemaObject | OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject | OpenAPIV3_2.SchemaObject;
|
|
26
|
+
type HttpMethod = OpenAPIV2.HttpMethods | OpenAPIV3.HttpMethods | OpenAPIV3_1.HttpMethods | OpenAPIV3_2.HttpMethods;
|
|
27
|
+
}
|
|
2
28
|
declare namespace OpenAPIV3_2 {
|
|
3
29
|
type Modify<T, R> = Omit<T, keyof R> & R;
|
|
4
30
|
export type PathsWebhooksComponents<T = {}> = {
|
|
@@ -877,4 +903,4 @@ type IJsonSchema = {
|
|
|
877
903
|
$ref?: string;
|
|
878
904
|
};
|
|
879
905
|
//#endregion
|
|
880
|
-
export { OpenAPIV3, OpenAPIV3_2 };
|
|
906
|
+
export { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1, OpenAPIV3_2 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MediaAdapter } from "./requests/media/adapter.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1, OpenAPIV3_2 } from "./_openapi/types.js";
|
|
3
|
+
import { OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput } from "./utils/pages/builder.js";
|
|
4
|
+
import { SchemaToPagesOptions } from "./utils/pages/preset-auto.js";
|
|
5
|
+
import { MethodInformation, RenderContext } from "./types.js";
|
|
5
6
|
import { Config, OutputFile, generateFiles, generateFilesOnly } from "./generate-file.js";
|
|
6
|
-
export {
|
|
7
|
+
export { Config, type MediaAdapter, type MethodInformation, type OpenAPI, type OpenAPIV2, type OpenAPIV3, type OpenAPIV3_1, type OpenAPIV3_2, type OperationOutput, type OutputEntry, OutputFile, type OutputGroup, type PageOutput, type PagesBuilder, type PagesBuilderConfig, type RenderContext, type SchemaToPagesOptions, type WebhookOutput, generateFiles, generateFilesOnly };
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { getHash, resolve, stripHash } from "./util/url.js";
|
|
2
|
+
import { getSchemaBasePath } from "./util/schema-resources.js";
|
|
3
|
+
import Pointer from "./pointer.js";
|
|
4
|
+
import $Ref from "./ref.js";
|
|
5
|
+
//#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/bundle.js
|
|
6
|
+
/**
|
|
7
|
+
* Bundles all external JSON references into the main JSON schema, thus resulting in a schema that
|
|
8
|
+
* only has *internal* references, not any *external* references.
|
|
9
|
+
* This method mutates the JSON schema object, adding new references and re-mapping existing ones.
|
|
10
|
+
*
|
|
11
|
+
* @param parser
|
|
12
|
+
* @param options
|
|
13
|
+
*/
|
|
14
|
+
function bundle(parser, options) {
|
|
15
|
+
const rootScopeBase = parser.$refs._root$Ref.dynamicIdScope ? getSchemaBasePath(parser.$refs._root$Ref.path, parser.schema) : parser.$refs._root$Ref.path;
|
|
16
|
+
const inventory = [];
|
|
17
|
+
crawl(parser, "schema", parser.$refs._root$Ref.path + "#", rootScopeBase, parser.$refs._root$Ref.dynamicIdScope, "#", 0, inventory, parser.$refs, options);
|
|
18
|
+
remap(inventory, options, parser.schema && typeof parser.schema === "object" && "$id" in parser.schema ? parser.schema.$id : void 0);
|
|
19
|
+
if ((options.bundle || {}).optimizeInternalRefs !== false) fixRefsThroughRefs(inventory, parser.schema);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Recursively crawls the given value, and inventories all JSON references.
|
|
23
|
+
*
|
|
24
|
+
* @param parent - The object containing the value to crawl. If the value is not an object or array, it will be ignored.
|
|
25
|
+
* @param key - The property key of `parent` to be crawled
|
|
26
|
+
* @param path - The full path of the property being crawled, possibly with a JSON Pointer in the hash
|
|
27
|
+
* @param pathFromRoot - The path of the property being crawled, from the schema root
|
|
28
|
+
* @param indirections
|
|
29
|
+
* @param inventory - An array of already-inventoried $ref pointers
|
|
30
|
+
* @param $refs
|
|
31
|
+
* @param options
|
|
32
|
+
*/
|
|
33
|
+
function crawl(parent, key, path, scopeBase, dynamicIdScope, pathFromRoot, indirections, inventory, $refs, options) {
|
|
34
|
+
const obj = key === null ? parent : parent[key];
|
|
35
|
+
const bundleOptions = options.bundle || {};
|
|
36
|
+
const isExcludedPath = bundleOptions.excludedPathMatcher || (() => false);
|
|
37
|
+
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !isExcludedPath(pathFromRoot)) {
|
|
38
|
+
const currentScopeBase = scopeBase;
|
|
39
|
+
if ($Ref.isAllowed$Ref(obj)) inventory$Ref(parent, key, path, currentScopeBase, dynamicIdScope, pathFromRoot, indirections, inventory, $refs, options);
|
|
40
|
+
else {
|
|
41
|
+
const keys = Object.keys(obj).sort((a, b) => {
|
|
42
|
+
if (a === "definitions" || a === "$defs") return -1;
|
|
43
|
+
else if (b === "definitions" || b === "$defs") return 1;
|
|
44
|
+
else return a.length - b.length;
|
|
45
|
+
});
|
|
46
|
+
for (const key of keys) {
|
|
47
|
+
const keyPath = Pointer.join(path, key);
|
|
48
|
+
const keyPathFromRoot = Pointer.join(pathFromRoot, key);
|
|
49
|
+
const value = obj[key];
|
|
50
|
+
const childScopeBase = dynamicIdScope && value && typeof value === "object" && !ArrayBuffer.isView(value) ? getSchemaBasePath(currentScopeBase, value) : currentScopeBase;
|
|
51
|
+
if ($Ref.isAllowed$Ref(value)) inventory$Ref(obj, key, keyPath, childScopeBase, dynamicIdScope, keyPathFromRoot, indirections, inventory, $refs, options);
|
|
52
|
+
else crawl(obj, key, keyPath, childScopeBase, dynamicIdScope, keyPathFromRoot, indirections, inventory, $refs, options);
|
|
53
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
54
|
+
if ("$ref" in value) bundleOptions?.onBundle?.(value["$ref"], obj[key], obj, key);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Inventories the given JSON Reference (i.e. records detailed information about it so we can
|
|
62
|
+
* optimize all $refs in the schema), and then crawls the resolved value.
|
|
63
|
+
*
|
|
64
|
+
* @param $refParent - The object that contains a JSON Reference as one of its keys
|
|
65
|
+
* @param $refKey - The key in `$refParent` that is a JSON Reference
|
|
66
|
+
* @param path - The full path of the JSON Reference at `$refKey`, possibly with a JSON Pointer in the hash
|
|
67
|
+
* @param indirections - unknown
|
|
68
|
+
* @param pathFromRoot - The path of the JSON Reference at `$refKey`, from the schema root
|
|
69
|
+
* @param inventory - An array of already-inventoried $ref pointers
|
|
70
|
+
* @param $refs
|
|
71
|
+
* @param options
|
|
72
|
+
*/
|
|
73
|
+
function inventory$Ref($refParent, $refKey, path, scopeBase, dynamicIdScope, pathFromRoot, indirections, inventory, $refs, options) {
|
|
74
|
+
const $ref = $refKey === null ? $refParent : $refParent[$refKey];
|
|
75
|
+
const $refPath = resolve(dynamicIdScope ? scopeBase : path, $ref.$ref);
|
|
76
|
+
const pointer = $refs._resolve($refPath, pathFromRoot, options);
|
|
77
|
+
if (pointer === null) return;
|
|
78
|
+
const depth = Pointer.parse(pathFromRoot).length;
|
|
79
|
+
const file = stripHash(pointer.path);
|
|
80
|
+
const hash = getHash(pointer.path);
|
|
81
|
+
const external = file !== $refs._root$Ref.path && !$refs._aliases[file];
|
|
82
|
+
const extended = $Ref.isExtended$Ref($ref);
|
|
83
|
+
indirections += pointer.indirections;
|
|
84
|
+
const existingEntry = findInInventory(inventory, $refParent, $refKey);
|
|
85
|
+
if (existingEntry) if (depth < existingEntry.depth || indirections < existingEntry.indirections) removeFromInventory(inventory, existingEntry);
|
|
86
|
+
else return;
|
|
87
|
+
inventory.push({
|
|
88
|
+
$ref,
|
|
89
|
+
parent: $refParent,
|
|
90
|
+
key: $refKey,
|
|
91
|
+
pathFromRoot,
|
|
92
|
+
depth,
|
|
93
|
+
file,
|
|
94
|
+
hash,
|
|
95
|
+
value: pointer.value,
|
|
96
|
+
circular: pointer.circular,
|
|
97
|
+
extended,
|
|
98
|
+
external,
|
|
99
|
+
indirections
|
|
100
|
+
});
|
|
101
|
+
if (!existingEntry || external) crawl(pointer.value, null, pointer.path, pointer.$ref.path, pointer.$ref.dynamicIdScope, pathFromRoot, indirections + 1, inventory, $refs, options);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Re-maps every $ref pointer, so that they're all relative to the root of the JSON Schema.
|
|
105
|
+
* Each referenced value is dereferenced EXACTLY ONCE. All subsequent references to the same
|
|
106
|
+
* value are re-mapped to point to the first reference.
|
|
107
|
+
*
|
|
108
|
+
* @example: {
|
|
109
|
+
* first: { $ref: somefile.json#/some/part },
|
|
110
|
+
* second: { $ref: somefile.json#/another/part },
|
|
111
|
+
* third: { $ref: somefile.json },
|
|
112
|
+
* fourth: { $ref: somefile.json#/some/part/sub/part }
|
|
113
|
+
* }
|
|
114
|
+
*
|
|
115
|
+
* In this example, there are four references to the same file, but since the third reference points
|
|
116
|
+
* to the ENTIRE file, that's the only one we need to dereference. The other three can just be
|
|
117
|
+
* remapped to point inside the third one.
|
|
118
|
+
*
|
|
119
|
+
* On the other hand, if the third reference DIDN'T exist, then the first and second would both need
|
|
120
|
+
* to be dereferenced, since they point to different parts of the file. The fourth reference does NOT
|
|
121
|
+
* need to be dereferenced, because it can be remapped to point inside the first one.
|
|
122
|
+
*
|
|
123
|
+
* @param inventory
|
|
124
|
+
*/
|
|
125
|
+
function remap(inventory, options, rootId) {
|
|
126
|
+
inventory.sort((a, b) => {
|
|
127
|
+
if (a.file !== b.file) return a.file < b.file ? -1 : 1;
|
|
128
|
+
else if (a.hash !== b.hash) return a.hash < b.hash ? -1 : 1;
|
|
129
|
+
else if (a.circular !== b.circular) return a.circular ? -1 : 1;
|
|
130
|
+
else if (a.extended !== b.extended) return a.extended ? 1 : -1;
|
|
131
|
+
else if (a.indirections !== b.indirections) return a.indirections - b.indirections;
|
|
132
|
+
else if (a.depth !== b.depth) return a.depth - b.depth;
|
|
133
|
+
else {
|
|
134
|
+
const aDefinitionsIndex = Math.max(a.pathFromRoot.lastIndexOf("/definitions"), a.pathFromRoot.lastIndexOf("/$defs"));
|
|
135
|
+
const bDefinitionsIndex = Math.max(b.pathFromRoot.lastIndexOf("/definitions"), b.pathFromRoot.lastIndexOf("/$defs"));
|
|
136
|
+
if (aDefinitionsIndex !== bDefinitionsIndex) return bDefinitionsIndex - aDefinitionsIndex;
|
|
137
|
+
else return a.pathFromRoot.length - b.pathFromRoot.length;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
let file, hash, pathFromRoot;
|
|
141
|
+
for (const entry of inventory) {
|
|
142
|
+
const bundleOpts = options.bundle || {};
|
|
143
|
+
if (!entry.external) {
|
|
144
|
+
if (bundleOpts.optimizeInternalRefs !== false) entry.$ref.$ref = entry.hash;
|
|
145
|
+
} else if (entry.file === file && entry.hash === hash) if (rootId && isInsideIdScope(inventory, entry)) entry.$ref.$ref = rootId + pathFromRoot;
|
|
146
|
+
else entry.$ref.$ref = pathFromRoot;
|
|
147
|
+
else if (entry.file === file && entry.hash.indexOf(hash + "/") === 0) {
|
|
148
|
+
const subPath = Pointer.join(pathFromRoot, Pointer.parse(entry.hash.replace(hash, "#")));
|
|
149
|
+
if (rootId && isInsideIdScope(inventory, entry)) entry.$ref.$ref = rootId + subPath;
|
|
150
|
+
else entry.$ref.$ref = subPath;
|
|
151
|
+
} else {
|
|
152
|
+
file = entry.file;
|
|
153
|
+
hash = entry.hash;
|
|
154
|
+
pathFromRoot = entry.pathFromRoot;
|
|
155
|
+
entry.$ref = entry.parent[entry.key] = $Ref.dereference(entry.$ref, entry.value, options);
|
|
156
|
+
if (entry.circular) entry.$ref.$ref = entry.pathFromRoot;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* TODO
|
|
162
|
+
*/
|
|
163
|
+
function findInInventory(inventory, $refParent, $refKey) {
|
|
164
|
+
for (const existingEntry of inventory) if (existingEntry && existingEntry.parent === $refParent && existingEntry.key === $refKey) return existingEntry;
|
|
165
|
+
}
|
|
166
|
+
function removeFromInventory(inventory, entry) {
|
|
167
|
+
const index = inventory.indexOf(entry);
|
|
168
|
+
inventory.splice(index, 1);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* After remapping, some $ref paths may traverse through other $ref nodes.
|
|
172
|
+
* JSON pointer resolution does not follow $ref indirection, so these paths are invalid.
|
|
173
|
+
* This function detects and fixes such paths by following any intermediate $refs
|
|
174
|
+
* to compute a valid direct path.
|
|
175
|
+
*/
|
|
176
|
+
function fixRefsThroughRefs(inventory, schema) {
|
|
177
|
+
for (const entry of inventory) {
|
|
178
|
+
if (!entry.$ref || typeof entry.$ref !== "object" || !("$ref" in entry.$ref)) continue;
|
|
179
|
+
const refValue = entry.$ref.$ref;
|
|
180
|
+
if (typeof refValue !== "string" || !refValue.startsWith("#/")) continue;
|
|
181
|
+
const fixedPath = resolvePathThroughRefs(schema, refValue);
|
|
182
|
+
if (fixedPath !== refValue) entry.$ref.$ref = fixedPath;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Walks a JSON pointer path through the schema. If any intermediate value
|
|
187
|
+
* is a $ref, follows it and adjusts the path accordingly.
|
|
188
|
+
* Returns the corrected path that doesn't traverse through any $ref.
|
|
189
|
+
*/
|
|
190
|
+
function resolvePathThroughRefs(schema, refPath) {
|
|
191
|
+
if (!refPath.startsWith("#/")) return refPath;
|
|
192
|
+
const segments = refPath.slice(2).split("/");
|
|
193
|
+
let current = schema;
|
|
194
|
+
const resolvedSegments = [];
|
|
195
|
+
for (const seg of segments) {
|
|
196
|
+
if (current === null || current === void 0 || typeof current !== "object") return refPath;
|
|
197
|
+
if ("$ref" in current && typeof current.$ref === "string" && current.$ref.startsWith("#/")) {
|
|
198
|
+
const targetSegments = current.$ref.slice(2).split("/");
|
|
199
|
+
resolvedSegments.length = 0;
|
|
200
|
+
resolvedSegments.push(...targetSegments);
|
|
201
|
+
current = walkPath(schema, current.$ref);
|
|
202
|
+
if (current === null || current === void 0 || typeof current !== "object") return refPath;
|
|
203
|
+
}
|
|
204
|
+
const decoded = seg.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
205
|
+
current = current[Array.isArray(current) ? parseInt(decoded) : decoded];
|
|
206
|
+
resolvedSegments.push(seg);
|
|
207
|
+
}
|
|
208
|
+
return "#/" + resolvedSegments.join("/");
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Walks a JSON pointer path through a schema object, returning the value at that path.
|
|
212
|
+
*/
|
|
213
|
+
function walkPath(schema, path) {
|
|
214
|
+
if (!path.startsWith("#/")) return;
|
|
215
|
+
const segments = path.slice(2).split("/");
|
|
216
|
+
let current = schema;
|
|
217
|
+
for (const seg of segments) {
|
|
218
|
+
if (current === null || current === void 0 || typeof current !== "object") return;
|
|
219
|
+
const decoded = seg.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
220
|
+
current = current[Array.isArray(current) ? parseInt(decoded) : decoded];
|
|
221
|
+
}
|
|
222
|
+
return current;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Checks whether the given inventory entry is located inside a sub-schema that has its own $id.
|
|
226
|
+
* If so, root-relative JSON Pointer $refs placed at this location would be resolved against
|
|
227
|
+
* the $id base URI rather than the document root, making them invalid.
|
|
228
|
+
*/
|
|
229
|
+
function isInsideIdScope(inventory, entry) {
|
|
230
|
+
for (const other of inventory) {
|
|
231
|
+
if (other.pathFromRoot === "#" || other.pathFromRoot === "#/") continue;
|
|
232
|
+
if (entry.pathFromRoot.startsWith(other.pathFromRoot + "/")) {
|
|
233
|
+
if (other.value && typeof other.value === "object" && "$id" in other.value) return true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
export { bundle as default };
|
|
@@ -0,0 +1,187 @@
|
|
|
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.5_@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 };
|
|
@@ -0,0 +1,136 @@
|
|
|
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 };
|