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
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import convertPathToPosix from "./convert-path-to-posix.js";
|
|
2
|
+
import { isWindows } from "./is-windows.js";
|
|
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/util/url.js
|
|
4
|
+
const forwardSlashPattern = /\//g;
|
|
5
|
+
const protocolPattern = /^(\w{2,}):\/\//i;
|
|
6
|
+
const jsonPointerSlash = /~1/g;
|
|
7
|
+
const jsonPointerTilde = /~0/g;
|
|
8
|
+
const isAbsoluteWin32Path = /^[a-zA-Z]:[\\/]/;
|
|
9
|
+
const urlEncodePatterns = [[/\?/g, "%3F"], [/#/g, "%23"]];
|
|
10
|
+
const urlDecodePatterns = [
|
|
11
|
+
/%23/g,
|
|
12
|
+
"#",
|
|
13
|
+
/%24/g,
|
|
14
|
+
"$",
|
|
15
|
+
/%26/g,
|
|
16
|
+
"&",
|
|
17
|
+
/%2C/g,
|
|
18
|
+
",",
|
|
19
|
+
/%40/g,
|
|
20
|
+
"@"
|
|
21
|
+
];
|
|
22
|
+
const parse = (u) => new URL(u);
|
|
23
|
+
/**
|
|
24
|
+
* Returns resolved target URL relative to a base URL in a manner similar to that of a Web browser resolving an anchor tag HREF.
|
|
25
|
+
*
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
function resolve(from, to) {
|
|
29
|
+
const fromUrl = new URL(convertPathToPosix(from), "https://aaa.nonexistanturl.com");
|
|
30
|
+
const resolvedUrl = new URL(convertPathToPosix(to), fromUrl);
|
|
31
|
+
const endSpaces = to.match(/(\s*)$/)?.[1] || "";
|
|
32
|
+
if (resolvedUrl.hostname === "aaa.nonexistanturl.com") {
|
|
33
|
+
const { pathname, search, hash } = resolvedUrl;
|
|
34
|
+
return pathname + search + decodeURIComponent(hash) + endSpaces;
|
|
35
|
+
}
|
|
36
|
+
const resolved = resolvedUrl.toString() + endSpaces;
|
|
37
|
+
if (resolved.includes("#")) {
|
|
38
|
+
const [base, hash] = resolved.split("#", 2);
|
|
39
|
+
return base + "#" + decodeURIComponent(hash || "");
|
|
40
|
+
}
|
|
41
|
+
return resolved;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns the current working directory (in Node) or the current page URL (in browsers).
|
|
45
|
+
*
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
function cwd() {
|
|
49
|
+
if (typeof window !== "undefined" && window.location && window.location.href) {
|
|
50
|
+
const href = window.location.href;
|
|
51
|
+
if (!href || !href.startsWith("http")) try {
|
|
52
|
+
new URL(href);
|
|
53
|
+
return href;
|
|
54
|
+
} catch {
|
|
55
|
+
return "/";
|
|
56
|
+
}
|
|
57
|
+
return href;
|
|
58
|
+
}
|
|
59
|
+
if (typeof process !== "undefined" && process.cwd) {
|
|
60
|
+
const path = process.cwd();
|
|
61
|
+
const lastChar = path.slice(-1);
|
|
62
|
+
if (lastChar === "/" || lastChar === "\\") return path;
|
|
63
|
+
else return path + "/";
|
|
64
|
+
}
|
|
65
|
+
return "/";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns the protocol of the given URL, or `undefined` if it has no protocol.
|
|
69
|
+
*
|
|
70
|
+
* @param path
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
function getProtocol(path) {
|
|
74
|
+
const match = protocolPattern.exec(path || "");
|
|
75
|
+
if (match) return match[1].toLowerCase();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the lowercased file extension of the given URL,
|
|
79
|
+
* or an empty string if it has no extension.
|
|
80
|
+
*
|
|
81
|
+
* @param path
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
function getExtension(path) {
|
|
85
|
+
const lastDot = path.lastIndexOf(".");
|
|
86
|
+
if (lastDot >= 0) return stripQuery(path.substring(lastDot).toLowerCase());
|
|
87
|
+
return "";
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Removes the query, if any, from the given path.
|
|
91
|
+
*
|
|
92
|
+
* @param path
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
function stripQuery(path) {
|
|
96
|
+
const queryIndex = path.indexOf("?");
|
|
97
|
+
if (queryIndex >= 0) path = path.substring(0, queryIndex);
|
|
98
|
+
return path;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns the hash (URL fragment), of the given path.
|
|
102
|
+
* If there is no hash, then the root hash ("#") is returned.
|
|
103
|
+
*
|
|
104
|
+
* @param path
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
function getHash(path) {
|
|
108
|
+
if (!path) return "#";
|
|
109
|
+
const hashIndex = path.indexOf("#");
|
|
110
|
+
if (hashIndex >= 0) return path.substring(hashIndex);
|
|
111
|
+
return "#";
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Removes the hash (URL fragment), if any, from the given path.
|
|
115
|
+
*
|
|
116
|
+
* @param path
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
function stripHash(path) {
|
|
120
|
+
if (!path) return "";
|
|
121
|
+
const hashIndex = path.indexOf("#");
|
|
122
|
+
if (hashIndex >= 0) path = path.substring(0, hashIndex);
|
|
123
|
+
return path;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Determines whether the given path is an HTTP(S) URL.
|
|
127
|
+
*
|
|
128
|
+
* @param path
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
function isHttp(path) {
|
|
132
|
+
const protocol = getProtocol(path);
|
|
133
|
+
if (protocol === "http" || protocol === "https") return true;
|
|
134
|
+
else if (protocol === void 0) return typeof window !== "undefined";
|
|
135
|
+
else return false;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Determines whether the given url is an unsafe or internal url.
|
|
139
|
+
*
|
|
140
|
+
* @param path - The URL or path to check
|
|
141
|
+
* @returns true if the URL is unsafe/internal, false otherwise
|
|
142
|
+
*/
|
|
143
|
+
function isUnsafeUrl(path) {
|
|
144
|
+
if (!path || typeof path !== "string") return true;
|
|
145
|
+
const normalizedPath = path.trim().toLowerCase();
|
|
146
|
+
if (!normalizedPath) return true;
|
|
147
|
+
if (normalizedPath.startsWith("javascript:") || normalizedPath.startsWith("vbscript:") || normalizedPath.startsWith("data:")) return true;
|
|
148
|
+
if (normalizedPath.startsWith("file:")) return true;
|
|
149
|
+
if (typeof window !== "undefined" && window.location && window.location.href) return false;
|
|
150
|
+
const localPatterns = [
|
|
151
|
+
"localhost",
|
|
152
|
+
"127.0.0.1",
|
|
153
|
+
"::1",
|
|
154
|
+
"10.",
|
|
155
|
+
"172.16.",
|
|
156
|
+
"172.17.",
|
|
157
|
+
"172.18.",
|
|
158
|
+
"172.19.",
|
|
159
|
+
"172.20.",
|
|
160
|
+
"172.21.",
|
|
161
|
+
"172.22.",
|
|
162
|
+
"172.23.",
|
|
163
|
+
"172.24.",
|
|
164
|
+
"172.25.",
|
|
165
|
+
"172.26.",
|
|
166
|
+
"172.27.",
|
|
167
|
+
"172.28.",
|
|
168
|
+
"172.29.",
|
|
169
|
+
"172.30.",
|
|
170
|
+
"172.31.",
|
|
171
|
+
"192.168.",
|
|
172
|
+
"169.254.",
|
|
173
|
+
".local",
|
|
174
|
+
".internal",
|
|
175
|
+
".intranet",
|
|
176
|
+
".corp",
|
|
177
|
+
".home",
|
|
178
|
+
".lan"
|
|
179
|
+
];
|
|
180
|
+
try {
|
|
181
|
+
const url = new URL(normalizedPath.startsWith("//") ? "http:" + normalizedPath : normalizedPath);
|
|
182
|
+
const hostname = url.hostname.toLowerCase();
|
|
183
|
+
for (const pattern of localPatterns) if (hostname === pattern || hostname.startsWith(pattern) || hostname.endsWith(pattern)) return true;
|
|
184
|
+
if (isPrivateIP(hostname)) return true;
|
|
185
|
+
const port = url.port;
|
|
186
|
+
if (port && isInternalPort(parseInt(port))) return true;
|
|
187
|
+
} catch {
|
|
188
|
+
if (normalizedPath.startsWith("/") && !normalizedPath.startsWith("//")) return false;
|
|
189
|
+
for (const pattern of localPatterns) if (normalizedPath.includes(pattern)) return true;
|
|
190
|
+
}
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Helper function to check if an IP address is in a private range
|
|
195
|
+
*/
|
|
196
|
+
function isPrivateIP(ip) {
|
|
197
|
+
const match = ip.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
198
|
+
if (!match) return false;
|
|
199
|
+
const [, a, b, c, d] = match.map(Number);
|
|
200
|
+
if (a > 255 || b > 255 || c > 255 || d > 255) return false;
|
|
201
|
+
return a === 10 || a === 127 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 169 && b === 254;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Helper function to check if a port is typically used for internal services
|
|
205
|
+
*/
|
|
206
|
+
function isInternalPort(port) {
|
|
207
|
+
return [
|
|
208
|
+
22,
|
|
209
|
+
23,
|
|
210
|
+
25,
|
|
211
|
+
53,
|
|
212
|
+
135,
|
|
213
|
+
139,
|
|
214
|
+
445,
|
|
215
|
+
993,
|
|
216
|
+
995,
|
|
217
|
+
1433,
|
|
218
|
+
1521,
|
|
219
|
+
3306,
|
|
220
|
+
3389,
|
|
221
|
+
5432,
|
|
222
|
+
5900,
|
|
223
|
+
6379,
|
|
224
|
+
8080,
|
|
225
|
+
8443,
|
|
226
|
+
9200,
|
|
227
|
+
27017
|
|
228
|
+
].includes(port);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Determines whether the given path is a filesystem path.
|
|
232
|
+
* This includes "file://" URLs.
|
|
233
|
+
*
|
|
234
|
+
* @param path
|
|
235
|
+
* @returns
|
|
236
|
+
*/
|
|
237
|
+
function isFileSystemPath(path) {
|
|
238
|
+
if (typeof window !== "undefined" || typeof process !== "undefined" && process.browser) return false;
|
|
239
|
+
const protocol = getProtocol(path);
|
|
240
|
+
return protocol === void 0 || protocol === "file";
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Converts a filesystem path to a properly-encoded URL.
|
|
244
|
+
*
|
|
245
|
+
* This is intended to handle situations where JSON Schema $Ref Parser is called
|
|
246
|
+
* with a filesystem path that contains characters which are not allowed in URLs.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* The following filesystem paths would be converted to the following URLs:
|
|
250
|
+
*
|
|
251
|
+
* <"!@#$%^&*+=?'>.json ==> %3C%22!@%23$%25%5E&*+=%3F\'%3E.json
|
|
252
|
+
* C:\\My Documents\\File (1).json ==> C:/My%20Documents/File%20(1).json
|
|
253
|
+
* file://Project #42/file.json ==> file://Project%20%2342/file.json
|
|
254
|
+
*
|
|
255
|
+
* @param path
|
|
256
|
+
* @returns
|
|
257
|
+
*/
|
|
258
|
+
function fromFileSystemPath(path) {
|
|
259
|
+
if (isWindows()) {
|
|
260
|
+
const projectDir = cwd();
|
|
261
|
+
const upperPath = path.toUpperCase();
|
|
262
|
+
const posixUpper = convertPathToPosix(projectDir).toUpperCase();
|
|
263
|
+
const hasProjectDir = upperPath.includes(posixUpper);
|
|
264
|
+
const hasProjectUri = upperPath.includes(posixUpper);
|
|
265
|
+
const isAbsolutePath = isAbsoluteWin32Path.test(path) || path.startsWith("http://") || path.startsWith("https://") || path.startsWith("file://");
|
|
266
|
+
if (!(hasProjectDir || hasProjectUri || isAbsolutePath) && !projectDir.startsWith("http")) {
|
|
267
|
+
const join = (a, b) => {
|
|
268
|
+
if (a.endsWith("/") || a.endsWith("\\")) return a + b;
|
|
269
|
+
else return a + "/" + b;
|
|
270
|
+
};
|
|
271
|
+
path = join(projectDir, path);
|
|
272
|
+
}
|
|
273
|
+
path = convertPathToPosix(path);
|
|
274
|
+
}
|
|
275
|
+
path = encodeURI(path);
|
|
276
|
+
for (const pattern of urlEncodePatterns) path = path.replace(pattern[0], pattern[1]);
|
|
277
|
+
return path;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Converts a URL to a local filesystem path.
|
|
281
|
+
*/
|
|
282
|
+
function toFileSystemPath(path, keepFileProtocol) {
|
|
283
|
+
path = path.replace(/%(?![0-9A-Fa-f]{2})/g, "%25");
|
|
284
|
+
path = decodeURI(path);
|
|
285
|
+
for (let i = 0; i < urlDecodePatterns.length; i += 2) path = path.replace(urlDecodePatterns[i], urlDecodePatterns[i + 1]);
|
|
286
|
+
let isFileUrl = path.toLowerCase().startsWith("file://");
|
|
287
|
+
if (isFileUrl) {
|
|
288
|
+
path = path.replace(/^file:\/\//, "").replace(/^\//, "");
|
|
289
|
+
if (isWindows() && path[1] === "/") path = `${path[0]}:${path.substring(1)}`;
|
|
290
|
+
if (keepFileProtocol) path = "file:///" + path;
|
|
291
|
+
else {
|
|
292
|
+
isFileUrl = false;
|
|
293
|
+
path = isWindows() ? path : "/" + path;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (isWindows() && !isFileUrl) {
|
|
297
|
+
path = path.replace(forwardSlashPattern, "\\");
|
|
298
|
+
if (path.match(/^[a-z]:\\/i)) path = path[0].toUpperCase() + path.substring(1);
|
|
299
|
+
}
|
|
300
|
+
return path;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Converts a $ref pointer to a valid JSON Path.
|
|
304
|
+
*
|
|
305
|
+
* @param pointer
|
|
306
|
+
* @returns
|
|
307
|
+
*/
|
|
308
|
+
function safePointerToPath(pointer) {
|
|
309
|
+
if (pointer.length <= 1 || pointer[0] !== "#" || pointer[1] !== "/") return [];
|
|
310
|
+
return pointer.slice(2).split("/").map((value) => {
|
|
311
|
+
return value.replace(jsonPointerSlash, "/").replace(jsonPointerTilde, "~");
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
//#endregion
|
|
315
|
+
export { cwd, fromFileSystemPath, getExtension, getHash, isFileSystemPath, isHttp, isUnsafeUrl, parse, resolve, safePointerToPath, stripHash, toFileSystemPath };
|
|
@@ -50,7 +50,7 @@ interface PlaygroundClientOptions {
|
|
|
50
50
|
* for updating values, use:
|
|
51
51
|
* - the `Custom.useController()` from `fumadocs-openapi/playground/client`.
|
|
52
52
|
*
|
|
53
|
-
* Recommended types packages: `json-schema-typed
|
|
53
|
+
* Recommended types packages: `json-schema-typed`.
|
|
54
54
|
*/
|
|
55
55
|
renderParameterField?: (fieldName: FieldKey, param: ParameterObject) => ReactNode;
|
|
56
56
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CodeUsageGeneratorRegistry } from "./index.js";
|
|
2
2
|
|
|
3
3
|
//#region src/requests/generators/all.d.ts
|
|
4
|
-
declare function registerDefault(registry: CodeUsageGeneratorRegistry):
|
|
4
|
+
declare function registerDefault(registry: CodeUsageGeneratorRegistry): CodeUsageGeneratorRegistry;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { registerDefault };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { MediaAdapter } from "./requests/media/adapter.js";
|
|
2
1
|
import { InlineCodeUsageGenerator } from "./requests/generators/index.js";
|
|
3
2
|
import { boundary_d_exports } from "./ui/client/boundary.js";
|
|
4
|
-
import {
|
|
3
|
+
import { OpenAPIV3_2 } from "./_openapi/types.js";
|
|
5
4
|
import { CreateAPIPageOptions } from "./ui/base.js";
|
|
6
5
|
import { OpenAPIOptions } from "./server/index.js";
|
|
7
6
|
import { NoReference } from "./utils/schema/index.js";
|
|
8
7
|
import { DereferencedDocument } from "./utils/document/dereference.js";
|
|
9
|
-
import { ReactNode } from "react";
|
|
10
8
|
|
|
11
9
|
//#region src/types.d.ts
|
|
12
10
|
type Document = OpenAPIV3_2.Document;
|
|
@@ -17,14 +15,8 @@ type ReferenceObject = OpenAPIV3_2.ReferenceObject;
|
|
|
17
15
|
type PathItemObject = OpenAPIV3_2.PathItemObject;
|
|
18
16
|
type TagObject = OpenAPIV3_2.TagObject;
|
|
19
17
|
type ServerObject = OpenAPIV3_2.ServerObject;
|
|
20
|
-
type CallbackObject = OpenAPIV3_2.CallbackObject;
|
|
21
|
-
type ServerVariableObject = OpenAPIV3.ServerVariableObject;
|
|
22
18
|
type ResponseObject = OpenAPIV3_2.ResponseObject;
|
|
23
|
-
type OAuth2SecurityScheme = OpenAPIV3_2.OAuth2SecurityScheme;
|
|
24
19
|
type HttpMethods = OpenAPIV3_2.HttpMethods;
|
|
25
|
-
type ExampleObject = OpenAPIV3_2.ExampleObject;
|
|
26
|
-
type MediaTypeObject = OpenAPIV3_2.MediaTypeObject;
|
|
27
|
-
type RequestBodyObject = OpenAPIV3_2.RequestBodyObject;
|
|
28
20
|
type MethodInformation = NoReference<OperationObject> & {
|
|
29
21
|
method: HttpMethods;
|
|
30
22
|
'x-codeSamples'?: InlineCodeUsageGenerator[];
|
|
@@ -32,16 +24,14 @@ type MethodInformation = NoReference<OperationObject> & {
|
|
|
32
24
|
'x-exclusiveCodeSample'?: string;
|
|
33
25
|
};
|
|
34
26
|
type RequireKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
35
|
-
interface RenderContext extends Pick<OpenAPIOptions, 'proxyUrl'>, Omit<RequireKeys<CreateAPIPageOptions, 'renderMarkdown' | 'generateTypeScriptDefinitions'
|
|
27
|
+
interface RenderContext extends Pick<OpenAPIOptions, 'proxyUrl'>, Omit<RequireKeys<CreateAPIPageOptions, 'renderMarkdown' | 'generateTypeScriptDefinitions' | 'renderCodeBlock' | 'mediaAdapters' | 'codeUsages'>, 'renderHeading' | 'generateTypeScriptSchema'> {
|
|
36
28
|
/**
|
|
37
29
|
* dereferenced schema
|
|
38
30
|
*/
|
|
39
31
|
schema: DereferencedDocument;
|
|
40
32
|
clientBoundary: typeof boundary_d_exports;
|
|
41
|
-
mediaAdapters: Record<string, MediaAdapter>;
|
|
42
|
-
renderCodeBlock: (lang: string, code: string) => ReactNode;
|
|
43
33
|
}
|
|
44
34
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
45
35
|
type Awaitable<T> = T | Promise<T>;
|
|
46
36
|
//#endregion
|
|
47
|
-
export { Awaitable,
|
|
37
|
+
export { Awaitable, DistributiveOmit, Document, HttpMethods, MethodInformation, OperationObject, ParameterObject, PathItemObject, ReferenceObject, RenderContext, ResponseObject, SecuritySchemeObject, ServerObject, TagObject };
|
package/dist/ui/base.d.ts
CHANGED
package/dist/ui/base.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { parseSecurities } from "../utils/schema/index.js";
|
|
2
2
|
import { defaultAdapters } from "../requests/media/adapter.js";
|
|
3
|
+
import { createCodeUsageGeneratorRegistry } from "../requests/generators/index.js";
|
|
4
|
+
import { registerDefault } from "../requests/generators/all.js";
|
|
3
5
|
import { ClientCodeBlockProvider } from "./components/codeblock.js";
|
|
4
6
|
import { encodeInternalRef } from "../utils/schema/ref.js";
|
|
5
7
|
import { APIPage } from "./api-page.js";
|
|
6
8
|
import { pickSchema } from "../utils/schema/pick.js";
|
|
7
9
|
import { PlaygroundAuthProvider } from "./client/boundary.lazy.js";
|
|
8
|
-
import Slugger from "github-slugger";
|
|
9
10
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
10
11
|
import { jsx } from "react/jsx-runtime";
|
|
11
12
|
import { createRehypeCode } from "fumadocs-core/mdx-plugins/rehype-code.core";
|
|
@@ -61,7 +62,6 @@ function createAPIPage(server, options) {
|
|
|
61
62
|
let processed;
|
|
62
63
|
if (typeof document === "string") processed = await server.getSchema(document);
|
|
63
64
|
else processed = document;
|
|
64
|
-
new Slugger();
|
|
65
65
|
const { ApiProvider, PlaygroundClient, SchemaUI, ServerProvider, UsageTab, UsageTabsSelector } = await import("./client/boundary.lazy.js");
|
|
66
66
|
const ctx = {
|
|
67
67
|
schema: processed,
|
|
@@ -75,6 +75,7 @@ function createAPIPage(server, options) {
|
|
|
75
75
|
UsageTabsSelector
|
|
76
76
|
},
|
|
77
77
|
...options,
|
|
78
|
+
codeUsages: options.codeUsages ?? registerDefault(createCodeUsageGeneratorRegistry()),
|
|
78
79
|
mediaAdapters: {
|
|
79
80
|
...defaultAdapters,
|
|
80
81
|
...options.mediaAdapters
|
|
@@ -106,7 +107,7 @@ function createAPIPage(server, options) {
|
|
|
106
107
|
processor ??= createMarkdownProcessor();
|
|
107
108
|
return (await processor.process({ value: text })).result;
|
|
108
109
|
},
|
|
109
|
-
async renderCodeBlock(lang, code) {
|
|
110
|
+
async renderCodeBlock({ lang, code }) {
|
|
110
111
|
if (options.renderCodeBlock) return options.renderCodeBlock({
|
|
111
112
|
lang,
|
|
112
113
|
code
|
|
@@ -2,12 +2,24 @@ import { MediaAdapter } from "../../requests/media/adapter.js";
|
|
|
2
2
|
import { PlaygroundClientOptions } from "../../playground/client.js";
|
|
3
3
|
import { CodeUsageGeneratorRegistry } from "../../requests/generators/index.js";
|
|
4
4
|
import { ExampleRequestItem } from "../operation/get-example-requests.js";
|
|
5
|
-
import { FC } from "react";
|
|
5
|
+
import { ComponentProps, FC } from "react";
|
|
6
6
|
|
|
7
7
|
//#region src/ui/client/index.d.ts
|
|
8
8
|
interface APIPageClientOptions {
|
|
9
9
|
playground?: PlaygroundClientOptions;
|
|
10
|
-
operation?:
|
|
10
|
+
operation?: {
|
|
11
|
+
APIExampleSelector?: FC<{
|
|
12
|
+
items: ExampleRequestItem[];
|
|
13
|
+
value: string | undefined;
|
|
14
|
+
onValueChange: (id: string) => void;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
components?: {
|
|
18
|
+
Heading?: FC<ComponentProps<'h1'> & {
|
|
19
|
+
id: string;
|
|
20
|
+
depth: number;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
11
23
|
/**
|
|
12
24
|
* Set a prefix for `localStorage` keys.
|
|
13
25
|
*
|
|
@@ -25,13 +37,6 @@ interface APIPageClientOptions {
|
|
|
25
37
|
*/
|
|
26
38
|
codeUsages?: CodeUsageGeneratorRegistry;
|
|
27
39
|
}
|
|
28
|
-
interface OperationClientOptions {
|
|
29
|
-
APIExampleSelector?: FC<{
|
|
30
|
-
items: ExampleRequestItem[];
|
|
31
|
-
value: string | undefined;
|
|
32
|
-
onValueChange: (id: string) => void;
|
|
33
|
-
}>;
|
|
34
|
-
}
|
|
35
40
|
declare function defineClientConfig(options?: APIPageClientOptions): APIPageClientOptions;
|
|
36
41
|
//#endregion
|
|
37
|
-
export { APIPageClientOptions,
|
|
42
|
+
export { APIPageClientOptions, defineClientConfig };
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useApiContext } from "../contexts/api.js";
|
|
2
3
|
import { useAnchorId } from "../../utils/auto-anchor.client.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import { Heading } from "fumadocs-ui/components/heading";
|
|
5
6
|
//#region src/ui/components/heading.tsx
|
|
6
7
|
function Heading$1({ id: _id, depth, ...props }) {
|
|
8
|
+
const id = useAnchorId([_id]);
|
|
9
|
+
const Component = useApiContext().client.components?.Heading;
|
|
10
|
+
if (Component) return /* @__PURE__ */ jsx(Component, {
|
|
11
|
+
id,
|
|
12
|
+
depth,
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
7
15
|
return /* @__PURE__ */ jsx(Heading, {
|
|
8
|
-
id
|
|
16
|
+
id,
|
|
9
17
|
as: `h${depth}`,
|
|
10
18
|
...props
|
|
11
19
|
});
|
package/dist/ui/contexts/api.js
CHANGED
|
@@ -21,16 +21,10 @@ function useServerContext() {
|
|
|
21
21
|
function ApiProvider({ children, shikiOptions, client, schemes }) {
|
|
22
22
|
return /* @__PURE__ */ jsx(ApiContext, {
|
|
23
23
|
value: useMemo(() => {
|
|
24
|
-
let codeUsages;
|
|
25
|
-
if (client.codeUsages) codeUsages = createCodeUsageGeneratorRegistry(client.codeUsages);
|
|
26
|
-
else {
|
|
27
|
-
codeUsages = createCodeUsageGeneratorRegistry();
|
|
28
|
-
registerDefault(codeUsages);
|
|
29
|
-
}
|
|
30
24
|
return {
|
|
31
25
|
shikiOptions,
|
|
32
26
|
client,
|
|
33
|
-
codeUsages,
|
|
27
|
+
codeUsages: client.codeUsages ?? registerDefault(createCodeUsageGeneratorRegistry()),
|
|
34
28
|
schemes,
|
|
35
29
|
mediaAdapters: {
|
|
36
30
|
...defaultAdapters,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { APIPageClientOptions } from "./client/index.js";
|
|
1
2
|
import { ApiPageProps } from "./api-page.js";
|
|
2
3
|
import { CreateAPIPageOptions } from "./base.js";
|
|
3
4
|
import { Document } from "../types.js";
|
|
@@ -11,7 +12,7 @@ interface ClientApiPagePayload {
|
|
|
11
12
|
bundled: Document;
|
|
12
13
|
proxyUrl?: string;
|
|
13
14
|
}
|
|
14
|
-
type CreateClientAPIPageOptions = Omit<
|
|
15
|
+
type CreateClientAPIPageOptions = Partial<Omit<CreateAPIPageOptions, 'generateTypeScriptSchema' | 'client'> & Omit<APIPageClientOptions, 'mediaAdapters' | 'codeUsages'>>;
|
|
15
16
|
/**
|
|
16
17
|
* Create `<APIPage />` for non-RSC environment, note that this may be unstable, and doesn't support the full set of features.
|
|
17
18
|
*/
|
package/dist/ui/create-client.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { parseSecurities } from "../utils/schema/index.js";
|
|
2
3
|
import { defaultAdapters } from "../requests/media/adapter.js";
|
|
4
|
+
import { createCodeUsageGeneratorRegistry } from "../requests/generators/index.js";
|
|
5
|
+
import { registerDefault } from "../requests/generators/all.js";
|
|
3
6
|
import { ClientCodeBlock, ClientCodeBlockProvider } from "./components/codeblock.js";
|
|
4
7
|
import { AuthProvider } from "../playground/auth.js";
|
|
5
8
|
import { dereferenceDocument } from "../utils/document/dereference.js";
|
|
@@ -78,7 +81,9 @@ function createClientAPIPage({ shiki = defaultShikiFactory, shikiOptions = { the
|
|
|
78
81
|
shikiOptions,
|
|
79
82
|
generateTypeScriptDefinitions,
|
|
80
83
|
clientBoundary: boundary_exports,
|
|
84
|
+
client: options,
|
|
81
85
|
...options,
|
|
86
|
+
codeUsages: options.codeUsages ?? registerDefault(createCodeUsageGeneratorRegistry()),
|
|
82
87
|
mediaAdapters: {
|
|
83
88
|
...defaultAdapters,
|
|
84
89
|
...options.mediaAdapters
|
|
@@ -93,15 +98,9 @@ function createClientAPIPage({ shiki = defaultShikiFactory, shikiOptions = { the
|
|
|
93
98
|
processor ??= createMarkdownProcessor();
|
|
94
99
|
return processor.processSync({ value: text }).result;
|
|
95
100
|
},
|
|
96
|
-
renderCodeBlock(
|
|
97
|
-
if (options.renderCodeBlock) return options.renderCodeBlock(
|
|
98
|
-
|
|
99
|
-
code
|
|
100
|
-
});
|
|
101
|
-
return /* @__PURE__ */ jsx(ClientCodeBlock, {
|
|
102
|
-
lang,
|
|
103
|
-
code
|
|
104
|
-
});
|
|
101
|
+
renderCodeBlock(props) {
|
|
102
|
+
if (options.renderCodeBlock) return options.renderCodeBlock(props);
|
|
103
|
+
return /* @__PURE__ */ jsx(ClientCodeBlock, { ...props });
|
|
105
104
|
}
|
|
106
105
|
}), [payload.proxyUrl, processed]);
|
|
107
106
|
return /* @__PURE__ */ jsx(ClientCodeBlockProvider, {
|
|
@@ -73,7 +73,10 @@ function RequestTabsItem({ item, ctx }) {
|
|
|
73
73
|
value: k,
|
|
74
74
|
children: [/* @__PURE__ */ jsx(AccordionHeader, { children: /* @__PURE__ */ jsx(AccordionTrigger, { children: v }) }), /* @__PURE__ */ jsx(AccordionContent, {
|
|
75
75
|
className: "prose-no-margin",
|
|
76
|
-
children: ctx.renderCodeBlock(
|
|
76
|
+
children: ctx.renderCodeBlock({
|
|
77
|
+
lang: "json",
|
|
78
|
+
code: JSON.stringify(data, null, 2)
|
|
79
|
+
})
|
|
77
80
|
})]
|
|
78
81
|
}, k);
|
|
79
82
|
})
|
|
@@ -45,7 +45,10 @@ function ResponseTabs({ operation, ctx }) {
|
|
|
45
45
|
}
|
|
46
46
|
function renderResponseTabsDefault(tabs, ctx) {
|
|
47
47
|
function renderExampleContent(example) {
|
|
48
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [example.description && ctx.renderMarkdown(example.description), ctx.renderCodeBlock(
|
|
48
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [example.description && ctx.renderMarkdown(example.description), ctx.renderCodeBlock({
|
|
49
|
+
lang: "json",
|
|
50
|
+
code: JSON.stringify(example.sample, null, 2)
|
|
51
|
+
})] });
|
|
49
52
|
}
|
|
50
53
|
return /* @__PURE__ */ jsx(Tabs, {
|
|
51
54
|
groupId: "fumadocs_openapi_responses",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createCodeUsageGeneratorRegistry } from "../../../requests/generators/index.js";
|
|
2
|
-
import { registerDefault } from "../../../requests/generators/all.js";
|
|
3
2
|
import { ResponseTabs } from "../response-tabs.js";
|
|
4
3
|
import { useMemo } from "react";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -37,13 +36,8 @@ function UsageTabs({ method, ctx }) {
|
|
|
37
36
|
});
|
|
38
37
|
};
|
|
39
38
|
const registry = useMemo(() => {
|
|
40
|
-
|
|
41
|
-
if (ctx.
|
|
42
|
-
else {
|
|
43
|
-
registry = createCodeUsageGeneratorRegistry();
|
|
44
|
-
registerDefault(registry);
|
|
45
|
-
}
|
|
46
|
-
for (const gen of ctx.generateCodeSamples?.(method) ?? []) registry.addInline(gen);
|
|
39
|
+
const registry = createCodeUsageGeneratorRegistry(ctx.codeUsages);
|
|
40
|
+
if (ctx.generateCodeSamples) for (const gen of ctx.generateCodeSamples(method)) registry.addInline(gen);
|
|
47
41
|
if (method["x-codeSamples"]) for (const sample of method["x-codeSamples"]) registry.addInline(sample);
|
|
48
42
|
return registry;
|
|
49
43
|
}, [ctx, method]);
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
import { bundle } from "../../node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/bundle.js";
|
|
2
1
|
import { upgrade } from "../../node_modules/.pnpm/@scalar_openapi-upgrader@0.2.8/node_modules/@scalar/openapi-upgrader/dist/upgrade.js";
|
|
3
|
-
import { fetchUrls } from "../../node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/fetch-urls/index.js";
|
|
4
|
-
import { readFiles } from "../../node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/read-files/index.js";
|
|
5
|
-
import "../../node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/node.js";
|
|
6
2
|
import { dereferenceDocument } from "./dereference.js";
|
|
3
|
+
import { bundle } from "../../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";
|
|
7
4
|
//#region src/utils/document/process.ts
|
|
8
5
|
/**
|
|
9
6
|
* process & reference input document to a Fumadocs OpenAPI compatible format
|
|
10
7
|
*/
|
|
11
8
|
async function processDocument(input) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} }
|
|
18
|
-
}).then((v) => upgrade(v, "3.2")).catch((e) => {
|
|
9
|
+
try {
|
|
10
|
+
let bundled = await bundle(input);
|
|
11
|
+
bundled = upgrade(bundled, "3.2");
|
|
12
|
+
return dereferenceDocument(bundled);
|
|
13
|
+
} catch (e) {
|
|
19
14
|
throw new Error(`[OpenAPI] Failed to resolve input: ${input}`, { cause: e });
|
|
20
|
-
}
|
|
15
|
+
}
|
|
21
16
|
}
|
|
22
17
|
//#endregion
|
|
23
18
|
export { processDocument };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OperationItem, WebhookItem } from "../../ui/api-page.js";
|
|
2
2
|
import { OperationObject, PathItemObject, TagObject } from "../../types.js";
|
|
3
3
|
import { NoReference } from "../schema/index.js";
|
|
4
4
|
import { DereferencedDocument } from "../document/dereference.js";
|
|
@@ -82,7 +82,5 @@ interface ExtractedInfo {
|
|
|
82
82
|
tags?: string[];
|
|
83
83
|
})[];
|
|
84
84
|
}
|
|
85
|
-
declare function fromSchema(schemaId: string, processed: DereferencedDocument, config: PagesBuilderConfig): OutputEntry[];
|
|
86
|
-
declare function getPageProps(entry: PageOutput | OperationOutput | WebhookOutput): ApiPageProps;
|
|
87
85
|
//#endregion
|
|
88
|
-
export { OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput
|
|
86
|
+
export { OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput };
|