fumadocs-openapi 12.5.5 → 12.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +1 -1
- package/dist/.translations/index.d.ts +6 -3
- package/dist/.translations/keys.js +6 -2
- package/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/generate-file.d.ts +1 -3
- package/dist/generate-file.js +3 -3
- package/dist/i18n.d.ts +1 -3
- package/dist/i18n.js +1 -2
- package/dist/index.browser.d.ts +0 -2
- package/dist/index.browser.js +1 -2
- package/dist/node_modules/.pnpm/fast-content-type-parse@4.0.1/node_modules/fast-content-type-parse/index.js +1 -2
- package/dist/node_modules/.pnpm/xml-js@1.6.11/node_modules/xml-js/lib/array-helper.js +1 -2
- package/dist/node_modules/.pnpm/xml-js@1.6.11/node_modules/xml-js/lib/js2xml.js +1 -2
- package/dist/node_modules/.pnpm/xml-js@1.6.11/node_modules/xml-js/lib/options-helper.js +1 -2
- package/dist/operation.d.ts +1 -3
- package/dist/operation.js +1 -2
- package/dist/packages/shared-api/dist/.translations/index.d.ts +2 -5
- package/dist/packages/shared-api/dist/.translations/keys.js +2 -2
- package/dist/packages/shared-api/dist/auto-anchor/index.js +1 -2
- package/dist/packages/shared-api/dist/codegen.d.ts +0 -3
- package/dist/packages/shared-api/dist/codegen.js +1 -2
- package/dist/packages/shared-api/dist/components/badge.js +1 -2
- package/dist/packages/shared-api/dist/components/collapsible.js +1 -2
- package/dist/packages/shared-api/dist/components/copy-typescript.js +1 -2
- package/dist/packages/shared-api/dist/components/defaults.d.ts +1 -4
- package/dist/packages/shared-api/dist/components/defaults.js +1 -2
- package/dist/packages/shared-api/dist/components/dialog.js +1 -2
- package/dist/packages/shared-api/dist/components/example.js +3 -3
- package/dist/packages/shared-api/dist/components/playground/fields.js +27 -9
- package/dist/packages/shared-api/dist/components/playground/json-editor.js +1 -2
- package/dist/packages/shared-api/dist/components/playground/panels.js +1 -2
- package/dist/packages/shared-api/dist/components/playground/param-input.js +1 -2
- package/dist/packages/shared-api/dist/components/playground/result.js +1 -2
- package/dist/packages/shared-api/dist/components/playground/schema.js +1 -2
- package/dist/packages/shared-api/dist/components/playground/server-select.js +1 -2
- package/dist/packages/shared-api/dist/components/schema/client.d.ts +1 -4
- package/dist/packages/shared-api/dist/components/schema/client.js +3 -2
- package/dist/packages/shared-api/dist/components/schema/index.d.ts +0 -3
- package/dist/packages/shared-api/dist/components/schema/index.js +1 -2
- package/dist/packages/shared-api/dist/components/segmented.js +1 -2
- package/dist/packages/shared-api/dist/components/select-tab.js +1 -2
- package/dist/packages/shared-api/dist/components/select.js +1 -2
- package/dist/packages/shared-api/dist/components/spinner.js +1 -2
- package/dist/packages/shared-api/dist/i18n.js +1 -2
- package/dist/packages/shared-api/dist/source.d.ts +1 -4
- package/dist/packages/shared-api/dist/source.js +1 -2
- package/dist/packages/shared-api/dist/utils/document-cache.js +1 -2
- package/dist/packages/shared-api/dist/utils/id-to-title.js +1 -2
- package/dist/packages/shared-api/dist/utils/is-plain-object.js +1 -2
- package/dist/packages/shared-api/dist/utils/url.js +1 -2
- package/dist/packages/shared-api/dist/utils/use-query.js +1 -2
- package/dist/packages/shared-api/dist/utils/use-server-store.js +1 -2
- package/dist/playground/auth.d.ts +0 -2
- package/dist/playground/auth.js +1 -2
- package/dist/playground/fetcher.d.ts +1 -3
- package/dist/playground/fetcher.js +1 -2
- package/dist/playground/use-playground.d.ts +1 -3
- package/dist/playground/use-playground.js +1 -2
- package/dist/requests/generators/all.d.ts +1 -3
- package/dist/requests/generators/all.js +1 -2
- package/dist/requests/generators/csharp.d.ts +1 -3
- package/dist/requests/generators/csharp.js +1 -2
- package/dist/requests/generators/curl.d.ts +1 -3
- package/dist/requests/generators/curl.js +1 -2
- package/dist/requests/generators/go.d.ts +1 -3
- package/dist/requests/generators/go.js +1 -2
- package/dist/requests/generators/index.d.ts +1 -3
- package/dist/requests/generators/index.js +1 -2
- package/dist/requests/generators/java.d.ts +1 -3
- package/dist/requests/generators/java.js +1 -2
- package/dist/requests/generators/javascript.d.ts +1 -3
- package/dist/requests/generators/javascript.js +1 -2
- package/dist/requests/generators/python.d.ts +1 -3
- package/dist/requests/generators/python.js +1 -2
- package/dist/requests/generators/rust.d.ts +1 -3
- package/dist/requests/generators/rust.js +1 -2
- package/dist/requests/media/adapter.d.ts +0 -2
- package/dist/requests/media/adapter.js +1 -2
- package/dist/requests/media/encode.d.ts +1 -3
- package/dist/requests/media/encode.js +1 -2
- package/dist/requests/media/resolve-adapter.d.ts +1 -3
- package/dist/requests/media/resolve-adapter.js +1 -2
- package/dist/requests/string-utils.js +1 -2
- package/dist/requests/types.d.ts +1 -3
- package/dist/server/index.d.ts +0 -2
- package/dist/server/index.js +1 -2
- package/dist/server/oauth.d.ts +1 -3
- package/dist/server/oauth.js +1 -2
- package/dist/server/proxy.d.ts +0 -2
- package/dist/server/proxy.js +8 -4
- package/dist/types/openapi.d.ts +1 -3
- package/dist/types.d.ts +1 -3
- package/dist/ui/base.d.ts +1 -3
- package/dist/ui/base.js +1 -2
- package/dist/ui/components/codeblock.js +1 -2
- package/dist/ui/components/endpoint.js +1 -2
- package/dist/ui/components/heading.js +1 -2
- package/dist/ui/components/markdown.js +1 -2
- package/dist/ui/components/method-label.js +1 -2
- package/dist/ui/components/schema.js +1 -2
- package/dist/ui/index.d.ts +0 -2
- package/dist/ui/index.js +1 -2
- package/dist/ui/operation/index.js +14 -5
- package/dist/ui/operation/usage-tabs.js +12 -5
- package/dist/ui/playground/client.d.ts +5 -4
- package/dist/ui/playground/client.js +1 -2
- package/dist/ui/playground/components/auth.js +1 -2
- package/dist/ui/playground/components/request-panel.d.ts +8 -0
- package/dist/ui/playground/components/request-panel.js +16 -10
- package/dist/ui/playground/components/response-panel.js +1 -2
- package/dist/ui/playground/components/result-display.d.ts +1 -3
- package/dist/ui/playground/components/result-display.js +1 -2
- package/dist/ui/playground/components/server-select.js +1 -2
- package/dist/ui/playground/components/url-bar.js +1 -2
- package/dist/ui/scalar/client.js +1 -2
- package/dist/ui/scalar/index.d.ts +1 -3
- package/dist/ui/scalar/index.js +1 -2
- package/dist/utils/create-page.d.ts +1 -3
- package/dist/utils/create-page.js +1 -2
- package/dist/utils/document/dereference.d.ts +1 -3
- package/dist/utils/document/dereference.js +1 -2
- package/dist/utils/document/load.js +1 -2
- package/dist/utils/get-example-requests.js +1 -2
- package/dist/utils/pages/builder.d.ts +0 -2
- package/dist/utils/pages/builder.js +1 -2
- package/dist/utils/pages/preset-auto.d.ts +0 -2
- package/dist/utils/pages/preset-auto.js +1 -2
- package/dist/utils/pages/to-static-data.d.ts +1 -3
- package/dist/utils/pages/to-static-data.js +1 -2
- package/dist/utils/pages/to-text.d.ts +1 -3
- package/dist/utils/pages/to-text.js +1 -2
- package/dist/utils/schema.js +1 -2
- package/dist/utils/use-server.d.ts +0 -2
- package/dist/utils/use-server.js +1 -2
- package/package.json +3 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ParameterObject } from "../../types.js";
|
|
2
2
|
import { DefaultResultDisplay, ResultDisplayProps } from "./components/result-display.js";
|
|
3
3
|
import { PlaygroundOptions, RequestBodyInfo } from "../../playground/use-playground.js";
|
|
4
|
+
import { ParameterFieldContext } from "./components/request-panel.js";
|
|
4
5
|
import { ComponentProps, FC, ReactNode } from "react";
|
|
5
6
|
import { FieldKey } from "@fumari/stf";
|
|
6
|
-
//#region src/ui/playground/client.d.ts
|
|
7
7
|
export interface PlaygroundClientProps extends ComponentProps<'div'>, PlaygroundClientOptions {
|
|
8
8
|
/** @deprecated it defaults to `true` for requests */
|
|
9
9
|
writeOnly?: boolean;
|
|
@@ -25,12 +25,14 @@ export interface PlaygroundClientOptions extends PlaygroundOptions {
|
|
|
25
25
|
/**
|
|
26
26
|
* render the parameter inputs of API endpoint, return `undefined` to keep the default input of a parameter.
|
|
27
27
|
*
|
|
28
|
+
* `ctx.renderDefault(schema)` renders the default input with another schema, like an `enum` of values loaded at runtime.
|
|
29
|
+
*
|
|
28
30
|
* for updating values, use:
|
|
29
31
|
* - the `Custom.useController()` from `fumadocs-openapi/ui/playground/client`.
|
|
30
32
|
*
|
|
31
33
|
* Recommended types packages: `json-schema-typed`.
|
|
32
34
|
*/
|
|
33
|
-
renderParameterField?: (fieldName: FieldKey, param: ParameterObject) => ReactNode;
|
|
35
|
+
renderParameterField?: (fieldName: FieldKey, param: ParameterObject, ctx: ParameterFieldContext) => ReactNode;
|
|
34
36
|
/**
|
|
35
37
|
* render the input for API endpoint body.
|
|
36
38
|
*
|
|
@@ -47,5 +49,4 @@ export declare const Custom: {
|
|
|
47
49
|
setValue: (newValue: unknown) => boolean;
|
|
48
50
|
};
|
|
49
51
|
};
|
|
50
|
-
|
|
51
|
-
export { DefaultResultDisplay, type ResultDisplayProps };
|
|
52
|
+
export { DefaultResultDisplay, type ParameterFieldContext, type ResultDisplayProps };
|
|
@@ -20,7 +20,7 @@ import { useTranslations } from "@fuma-translate/react";
|
|
|
20
20
|
import { X } from "lucide-react";
|
|
21
21
|
import { Dialog } from "@base-ui/react/dialog";
|
|
22
22
|
import { useOnChange } from "fumadocs-core/utils/use-on-change";
|
|
23
|
-
|
|
23
|
+
// src/ui/playground/client.tsx
|
|
24
24
|
function PlaygroundClient({ writeOnly = true, readOnly = false, authProviders, transformAuthInputs, fetchOptions, components, renderParameterField, renderBodyField, ...rest }) {
|
|
25
25
|
const { doc } = useOpenAPI();
|
|
26
26
|
const { path, method, operation } = useOperation();
|
|
@@ -162,5 +162,4 @@ const Custom = { useController(fieldName, options) {
|
|
|
162
162
|
setValue
|
|
163
163
|
};
|
|
164
164
|
} };
|
|
165
|
-
//#endregion
|
|
166
165
|
export { Custom, DefaultResultDisplay, PlaygroundClient as default };
|
|
@@ -15,7 +15,7 @@ import { useTranslations } from "@fuma-translate/react";
|
|
|
15
15
|
import { Check, Copy, ExternalLink, ShieldCheck } from "lucide-react";
|
|
16
16
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
17
17
|
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
|
|
18
|
-
|
|
18
|
+
// src/ui/playground/components/auth.tsx
|
|
19
19
|
/** the rows of OAuth and mutual TLS schemes in the built-in UI, after the providers of page */
|
|
20
20
|
const builtinAuthProviders = [{
|
|
21
21
|
on: ({ scheme }) => scheme.type === "oauth2" || scheme.type === "openIdConnect",
|
|
@@ -351,5 +351,4 @@ function DeviceVerification({ code, onCancel }) {
|
|
|
351
351
|
})]
|
|
352
352
|
})] });
|
|
353
353
|
}
|
|
354
|
-
//#endregion
|
|
355
354
|
export { builtinAuthProviders };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../../../playground/use-playground.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { JsonSchema } from "@fumadocs/json-schema";
|
|
4
|
+
import { FieldKey } from "@fumari/stf";
|
|
5
|
+
export interface ParameterFieldContext {
|
|
6
|
+
/** the default input of parameter, `schema` replaces its schema, like an `enum` of values loaded at runtime */
|
|
7
|
+
renderDefault: (schema?: JsonSchema) => ReactNode;
|
|
8
|
+
}
|
|
@@ -12,7 +12,7 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
import { stringifyFieldKey } from "@fumari/stf/lib/utils";
|
|
13
13
|
import { useTranslations } from "@fuma-translate/react";
|
|
14
14
|
import { Braces, Cookie, KeyRound, PlusIcon, Route, Rows3, SlidersHorizontal } from "lucide-react";
|
|
15
|
-
|
|
15
|
+
// src/ui/playground/components/request-panel.tsx
|
|
16
16
|
const sectionIcons = {
|
|
17
17
|
path: Route,
|
|
18
18
|
query: SlidersHorizontal,
|
|
@@ -101,14 +101,21 @@ function Overview({ auth, body, sectionNames, onNavigate, onAuthorize, renderPar
|
|
|
101
101
|
title: sectionNames[type],
|
|
102
102
|
count: items.length,
|
|
103
103
|
children: items.map((param, i) => {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
const renderDefault = (schema) => {
|
|
105
|
+
const entry = schema === void 0 ? entries[i] : {
|
|
106
|
+
...entries[i],
|
|
107
|
+
schema
|
|
108
|
+
};
|
|
109
|
+
const siblings = schema === void 0 ? entries : entries.map((item, index) => index === i ? entry : item);
|
|
110
|
+
return /* @__PURE__ */ jsx(FieldRow, {
|
|
111
|
+
entry,
|
|
112
|
+
required: param.required,
|
|
113
|
+
description: param.description,
|
|
114
|
+
onNavigate: () => onNavigate(entry, siblings)
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
const custom = renderParameterField?.(entries[i].fieldName, param, { renderDefault });
|
|
118
|
+
return /* @__PURE__ */ jsx(Fragment, { children: custom === void 0 ? renderDefault() : custom }, param.name);
|
|
112
119
|
})
|
|
113
120
|
}, type);
|
|
114
121
|
}),
|
|
@@ -236,5 +243,4 @@ function BodySection({ body, renderBodyField, onNavigate }) {
|
|
|
236
243
|
children: content
|
|
237
244
|
});
|
|
238
245
|
}
|
|
239
|
-
//#endregion
|
|
240
246
|
export { RequestPanel };
|
|
@@ -12,7 +12,7 @@ import { useState } from "react";
|
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useTranslations } from "@fuma-translate/react";
|
|
14
14
|
import { SendHorizontal } from "lucide-react";
|
|
15
|
-
|
|
15
|
+
// src/ui/playground/components/response-panel.tsx
|
|
16
16
|
function ResponsePanel({ response, loading, onReset, ResultDisplay = DefaultResultDisplay, className }) {
|
|
17
17
|
const t = useTranslations({ note: "playground" });
|
|
18
18
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -100,5 +100,4 @@ function ResponseExamples() {
|
|
|
100
100
|
]
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
//#endregion
|
|
104
103
|
export { ResponsePanel };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { FetchResult } from "../../../playground/fetcher.js";
|
|
2
2
|
import { ComponentProps } from "react";
|
|
3
|
-
//#region src/ui/playground/components/result-display.d.ts
|
|
4
3
|
export interface ResultDisplayProps extends ComponentProps<'div'> {
|
|
5
4
|
data: FetchResult;
|
|
6
5
|
reset: () => void;
|
|
7
6
|
}
|
|
8
|
-
export declare function DefaultResultDisplay({ data, reset, ...rest }: ResultDisplayProps): import("react").JSX.Element;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare function DefaultResultDisplay({ data, reset, ...rest }: ResultDisplayProps): import("react").JSX.Element;
|
|
@@ -6,7 +6,7 @@ import { useCallback, useMemo } from "react";
|
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { useTranslations } from "@fuma-translate/react";
|
|
8
8
|
import { DownloadIcon, FileIcon } from "lucide-react";
|
|
9
|
-
|
|
9
|
+
// src/ui/playground/components/result-display.tsx
|
|
10
10
|
function DefaultResultDisplay({ data, reset, ...rest }) {
|
|
11
11
|
if (data.type === "client_error") return /* @__PURE__ */ jsx(RequestError, {
|
|
12
12
|
...rest,
|
|
@@ -109,5 +109,4 @@ function TextResult({ lang, data }) {
|
|
|
109
109
|
codeblock: panelCodeBlock
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
//#endregion
|
|
113
112
|
export { DefaultResultDisplay };
|
|
@@ -4,7 +4,7 @@ import { cn } from "../../../utils/cn.js";
|
|
|
4
4
|
import { ServerPopover, ServerVariables } from "../../../packages/shared-api/dist/components/playground/server-select.js";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { useTranslations } from "@fuma-translate/react";
|
|
7
|
-
|
|
7
|
+
// src/ui/playground/components/server-select.tsx
|
|
8
8
|
/** the base URL of requests, selects the server and edits its variables */
|
|
9
9
|
function ServerSelect({ className }) {
|
|
10
10
|
const { servers, server, resolveUrl, setServer, setServerVariables } = useServer();
|
|
@@ -39,5 +39,4 @@ function ServerSelect({ className }) {
|
|
|
39
39
|
}, server.url)
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
//#endregion
|
|
43
42
|
export { ServerSelect as default };
|
|
@@ -5,7 +5,7 @@ import { SendButton } from "../../../packages/shared-api/dist/components/playgro
|
|
|
5
5
|
import { ParamInput } from "../../../packages/shared-api/dist/components/playground/param-input.js";
|
|
6
6
|
import ServerSelect from "./server-select.js";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
|
|
8
|
+
// src/ui/playground/components/url-bar.tsx
|
|
9
9
|
function UrlBar({ method, route, parameters, deprecated = false, loading }) {
|
|
10
10
|
return /* @__PURE__ */ jsxs("div", {
|
|
11
11
|
className: "flex items-center gap-2",
|
|
@@ -34,5 +34,4 @@ function UrlBar({ method, route, parameters, deprecated = false, loading }) {
|
|
|
34
34
|
}), /* @__PURE__ */ jsx(SendButton, { sending: loading })]
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
//#endregion
|
|
38
37
|
export { UrlBar };
|
package/dist/ui/scalar/client.js
CHANGED
|
@@ -9,7 +9,7 @@ import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
|
9
9
|
import { useApiClient } from "@scalar/api-client-react";
|
|
10
10
|
import { useTheme } from "fumadocs-ui/provider/base";
|
|
11
11
|
import "@scalar/api-client-react/style.css";
|
|
12
|
-
|
|
12
|
+
// src/ui/scalar/client.tsx
|
|
13
13
|
const noop = () => () => {};
|
|
14
14
|
function ScalarPlayground({ path, method }) {
|
|
15
15
|
const { resolvedTheme } = useTheme();
|
|
@@ -43,5 +43,4 @@ function ScalarPlayground({ path, method }) {
|
|
|
43
43
|
]
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
//#endregion
|
|
47
46
|
export { ScalarPlayground as default };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { CreateOpenAPIPageOptions } from "../index.js";
|
|
2
|
-
//#region src/ui/scalar/index.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Enable Scalar for API playgrounds by wrapping your options inside.
|
|
5
4
|
*
|
|
6
5
|
* Requires `@scalar/api-client-react` to be installed, it imports the styles automatically.
|
|
7
6
|
*/
|
|
8
|
-
export declare function withScalar(options?: CreateOpenAPIPageOptions): CreateOpenAPIPageOptions;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare function withScalar(options?: CreateOpenAPIPageOptions): CreateOpenAPIPageOptions;
|
package/dist/ui/scalar/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { lazy } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/ui/scalar/index.tsx
|
|
5
5
|
const Client = lazy(() => import("./client.js"));
|
|
6
6
|
/**
|
|
7
7
|
* Enable Scalar for API playgrounds by wrapping your options inside.
|
|
@@ -22,5 +22,4 @@ function withScalar(options = {}) {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
//#endregion
|
|
26
25
|
export { withScalar };
|
|
@@ -11,7 +11,6 @@ import { FC, ReactNode } from "react";
|
|
|
11
11
|
import { JsonSchema } from "@fumadocs/json-schema";
|
|
12
12
|
import { ShikiFactory } from "fumadocs-core/highlight/shiki";
|
|
13
13
|
import { Highlighter } from "fumadocs-core/highlight";
|
|
14
|
-
//#region src/utils/create-page.d.ts
|
|
15
14
|
/** components the UI renders through, so a page can replace them */
|
|
16
15
|
export interface OpenAPIComponents extends PageComponents {
|
|
17
16
|
SchemaUI: FC<SchemaUIOptions>;
|
|
@@ -216,5 +215,4 @@ export declare function useTypeScriptDefinitions(schema: JsonSchema | undefined,
|
|
|
216
215
|
* `createOpenAPIRenderer()` with nothing built in: it highlights through the `highlighter` you pass,
|
|
217
216
|
* and generates code usages and TypeScript definitions only when you pass them.
|
|
218
217
|
*/
|
|
219
|
-
export declare function createOpenAPIBaseRenderer({ components, loadDocument, ...rest }: CreateOpenAPIRendererOptions): FC<OpenAPIPageProps>;
|
|
220
|
-
//#endregion
|
|
218
|
+
export declare function createOpenAPIBaseRenderer({ components, loadDocument, ...rest }: CreateOpenAPIRendererOptions): FC<OpenAPIPageProps>;
|
|
@@ -11,7 +11,7 @@ import { createContext, use, useMemo } from "react";
|
|
|
11
11
|
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
12
12
|
import { generate } from "@fumari/json-schema-ts";
|
|
13
13
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
|
|
14
|
+
// src/utils/create-page.tsx
|
|
15
15
|
const OpenAPIContext = createContext(null);
|
|
16
16
|
const ComponentsContext = createContext(null);
|
|
17
17
|
const OptionsContext = createContext(null);
|
|
@@ -230,5 +230,4 @@ function createOpenAPIBaseRenderer({ components, loadDocument, ...rest }) {
|
|
|
230
230
|
function DefaultLayout({ operations, webhooks }) {
|
|
231
231
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [operations?.map((item) => item.children), webhooks?.map((item) => item.children)] });
|
|
232
232
|
}
|
|
233
|
-
//#endregion
|
|
234
233
|
export { createOpenAPIBaseRenderer, createRenderer, useComponents, useOpenAPI, useRenderContext, useTypeScriptDefinitions };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Document } from "../../types.js";
|
|
2
2
|
import { DereferencedShallow } from "@fumadocs/json-schema";
|
|
3
|
-
//#region src/utils/document/dereference.d.ts
|
|
4
3
|
export interface DereferencedDocument {
|
|
5
4
|
/**
|
|
6
5
|
* document wrapped in a magic proxy (`@scalar/json-magic`).
|
|
@@ -15,5 +14,4 @@ export interface DereferencedDocument {
|
|
|
15
14
|
*/
|
|
16
15
|
resolve: <T>(node: T) => DereferencedShallow<T>;
|
|
17
16
|
bundled: Document;
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
17
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMagicProxy } from "@scalar/json-magic/magic-proxy";
|
|
2
2
|
import { dereference } from "@fumadocs/json-schema";
|
|
3
|
-
|
|
3
|
+
// src/utils/document/dereference.ts
|
|
4
4
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
function dereferenceBundledDocument(bundled) {
|
|
6
6
|
const cached = cache.get(bundled);
|
|
@@ -15,5 +15,4 @@ function dereferenceBundledDocument(bundled) {
|
|
|
15
15
|
cache.set(bundled, doc);
|
|
16
16
|
return doc;
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { dereferenceBundledDocument };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { upgrade } from "@scalar/openapi-upgrader";
|
|
2
2
|
import { bundle } from "@fumadocs/json-schema/bundle";
|
|
3
|
-
|
|
3
|
+
// src/utils/document/load.ts
|
|
4
4
|
/**
|
|
5
5
|
* Process input document to a Fumadocs OpenAPI compatible format
|
|
6
6
|
*/
|
|
@@ -11,5 +11,4 @@ async function loadDocument(input) {
|
|
|
11
11
|
throw new Error(`[OpenAPI] Failed to resolve input: ${input}`, { cause: e });
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { loadDocument };
|
|
@@ -2,7 +2,7 @@ import { encodeRequestData } from "../requests/media/encode.js";
|
|
|
2
2
|
import { getExampleValue, getPreferredType, pickExample } from "./schema.js";
|
|
3
3
|
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
4
4
|
import { dereference, sample } from "@fumadocs/json-schema";
|
|
5
|
-
|
|
5
|
+
// src/utils/get-example-requests.ts
|
|
6
6
|
function getExampleRequests({ path, method, mediaAdapters, operation, parameters }) {
|
|
7
7
|
const requestBody = dereference(operation.requestBody);
|
|
8
8
|
const media = requestBody?.content ? getPreferredType(requestBody.content) : null;
|
|
@@ -91,5 +91,4 @@ function getRequestData({ method, path, parameters, sampleKey, body }) {
|
|
|
91
91
|
}
|
|
92
92
|
return result;
|
|
93
93
|
}
|
|
94
|
-
//#endregion
|
|
95
94
|
export { getExampleRequests };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Document, HttpMethods, OperationObject, PathItemObject, TagObject } from "../../types.js";
|
|
2
2
|
import { DereferencedShallow } from "@fumadocs/json-schema";
|
|
3
|
-
//#region src/utils/pages/builder.d.ts
|
|
4
3
|
interface BaseEntry {
|
|
5
4
|
path: string;
|
|
6
5
|
schemaId: string;
|
|
@@ -123,5 +122,4 @@ export type OpenAPIPageProps_Preloaded = GeneratedPageProps & {
|
|
|
123
122
|
proxyUrl?: string;
|
|
124
123
|
};
|
|
125
124
|
};
|
|
126
|
-
//#endregion
|
|
127
125
|
export {};
|
|
@@ -2,7 +2,7 @@ import { dereferenceBundledDocument } from "../document/dereference.js";
|
|
|
2
2
|
import { idToTitle } from "../../packages/shared-api/dist/utils/id-to-title.js";
|
|
3
3
|
import { getTagDisplayName, methodKeys } from "../schema.js";
|
|
4
4
|
import { dereference } from "@fumadocs/json-schema";
|
|
5
|
-
|
|
5
|
+
// src/utils/pages/builder.ts
|
|
6
6
|
function fromSchema(schemaId, bundled, config) {
|
|
7
7
|
const files = [];
|
|
8
8
|
const { toPages } = config;
|
|
@@ -112,5 +112,4 @@ function getPageProps(entry) {
|
|
|
112
112
|
webhooks: entry.webhooks
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
//#endregion
|
|
116
115
|
export { fromSchema, getPageProps };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DistributiveOmit } from "../../types.js";
|
|
2
2
|
import { OperationOutput, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput } from "./builder.js";
|
|
3
|
-
//#region src/utils/pages/preset-auto.d.ts
|
|
4
3
|
interface OperationConfig extends BaseConfig {
|
|
5
4
|
/**
|
|
6
5
|
* Generate a page for each API endpoint/operation (default).
|
|
@@ -64,5 +63,4 @@ interface BaseConfig {
|
|
|
64
63
|
*/
|
|
65
64
|
slugify?: (name: string) => string;
|
|
66
65
|
}
|
|
67
|
-
//#endregion
|
|
68
66
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getTagDisplayName } from "../schema.js";
|
|
2
2
|
import { dereference } from "@fumadocs/json-schema";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
-
|
|
4
|
+
// src/utils/pages/preset-auto.ts
|
|
5
5
|
function createAutoPreset(options) {
|
|
6
6
|
if (options.per === "custom") return options;
|
|
7
7
|
const { slugify = (s) => {
|
|
@@ -208,5 +208,4 @@ function createAutoPreset(options) {
|
|
|
208
208
|
for (const entry of root) builder.create(entry);
|
|
209
209
|
} };
|
|
210
210
|
}
|
|
211
|
-
//#endregion
|
|
212
211
|
export { createAutoPreset };
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import "./builder.js";
|
|
2
2
|
import { TOCItemType } from "fumadocs-core/toc";
|
|
3
3
|
import "fumadocs-core/mdx-plugins";
|
|
4
|
-
//#region src/utils/pages/to-static-data.d.ts
|
|
5
4
|
/** the `_openapi` data of pages */
|
|
6
5
|
export interface InternalOpenAPIMeta {
|
|
7
6
|
method?: string;
|
|
8
7
|
webhook?: boolean;
|
|
9
8
|
deprecated?: boolean;
|
|
10
9
|
preload?: string[];
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
10
|
+
}
|
|
@@ -2,7 +2,7 @@ import { dereferenceBundledDocument } from "../document/dereference.js";
|
|
|
2
2
|
import { idToTitle } from "../../packages/shared-api/dist/utils/id-to-title.js";
|
|
3
3
|
import { dereference } from "@fumadocs/json-schema";
|
|
4
4
|
import Slugger from "github-slugger";
|
|
5
|
-
|
|
5
|
+
// src/utils/pages/to-static-data.ts
|
|
6
6
|
function toStaticData(page, doc) {
|
|
7
7
|
const proxied = dereferenceBundledDocument(doc).dereferenced;
|
|
8
8
|
const slugger = new Slugger();
|
|
@@ -45,5 +45,4 @@ function toStaticData(page, doc) {
|
|
|
45
45
|
structuredData
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
//#endregion
|
|
49
48
|
export { toStaticData };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TagObject } from "../../types.js";
|
|
2
2
|
import "./builder.js";
|
|
3
|
-
//#region src/utils/pages/to-text.d.ts
|
|
4
3
|
export interface PagesToTextOptions {
|
|
5
4
|
/**
|
|
6
5
|
* Additional imports of your MDX components.
|
|
@@ -40,5 +39,4 @@ export type DocumentContext = {
|
|
|
40
39
|
type: 'operation';
|
|
41
40
|
} | {
|
|
42
41
|
type: 'file';
|
|
43
|
-
};
|
|
44
|
-
//#endregion
|
|
42
|
+
};
|
|
@@ -2,7 +2,7 @@ import { doubleQuote, jsxString } from "../../requests/string-utils.js";
|
|
|
2
2
|
import { getPageProps } from "./builder.js";
|
|
3
3
|
import { toStaticData } from "./to-static-data.js";
|
|
4
4
|
import { stringify } from "yaml";
|
|
5
|
-
|
|
5
|
+
// src/utils/pages/to-text.ts
|
|
6
6
|
function toText(entry, doc, options = {}) {
|
|
7
7
|
const { frontmatter, includeDescription = false } = options;
|
|
8
8
|
const extend = frontmatter?.(entry.info.title, entry.info.description, entry.type === "page" ? entry.tag ? {
|
|
@@ -70,5 +70,4 @@ function pageContent({ showTitle, showDescription, document, webhooks, operation
|
|
|
70
70
|
);
|
|
71
71
|
}`;
|
|
72
72
|
}
|
|
73
|
-
//#endregion
|
|
74
73
|
export { generateDocument, toText };
|
package/dist/utils/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { idToTitle } from "../packages/shared-api/dist/utils/id-to-title.js";
|
|
2
2
|
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
3
3
|
import { dereference } from "@fumadocs/json-schema";
|
|
4
|
-
|
|
4
|
+
// src/utils/schema.ts
|
|
5
5
|
const methodKeys = [
|
|
6
6
|
"get",
|
|
7
7
|
"post",
|
|
@@ -39,5 +39,4 @@ function pickExample(value) {
|
|
|
39
39
|
function getExampleValue(example) {
|
|
40
40
|
return getRaw(example.dataValue ?? example.value);
|
|
41
41
|
}
|
|
42
|
-
//#endregion
|
|
43
42
|
export { getExampleValue, getPreferredType, getTagDisplayName, methodKeys, pickExample };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ServerObject } from "../types.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
//#region src/utils/use-server.d.ts
|
|
4
3
|
export interface SelectedServer {
|
|
5
4
|
url: string;
|
|
6
5
|
name?: string;
|
|
@@ -21,5 +20,4 @@ interface ServerContextType {
|
|
|
21
20
|
setServerVariables: (value: Record<string, string>) => void;
|
|
22
21
|
}
|
|
23
22
|
export declare function useServer(): ServerContextType;
|
|
24
|
-
//#endregion
|
|
25
23
|
export {};
|
package/dist/utils/use-server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useServerStore } from "../packages/shared-api/dist/utils/use-server-sto
|
|
|
3
3
|
import { joinURL, resolveServerUrl } from "../packages/shared-api/dist/utils/url.js";
|
|
4
4
|
import { createContext, use, useCallback, useMemo, useSyncExternalStore } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
|
|
6
|
+
// src/utils/use-server.tsx
|
|
7
7
|
const ServerContext = createContext(null);
|
|
8
8
|
const keyOfServer = (server) => server.url;
|
|
9
9
|
const noop = () => () => {};
|
|
@@ -53,5 +53,4 @@ function getDefaultValues(server) {
|
|
|
53
53
|
for (const [k, v] of Object.entries(server.variables)) if (v.default !== void 0) out[k] = String(v.default);
|
|
54
54
|
return out;
|
|
55
55
|
}
|
|
56
|
-
//#endregion
|
|
57
56
|
export { ServerProvider, useServer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "12.5.
|
|
3
|
+
"version": "12.5.6",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"@types/react-dom": "^19.3.0",
|
|
79
79
|
"fast-content-type-parse": "^4.0.1",
|
|
80
80
|
"fuma-cli": "^0.3.1",
|
|
81
|
-
"fumadocs-core": "16.17.
|
|
82
|
-
"fumadocs-ui": "npm:@fumadocs/base-ui@16.17.
|
|
81
|
+
"fumadocs-core": "16.17.9",
|
|
82
|
+
"fumadocs-ui": "npm:@fumadocs/base-ui@16.17.9",
|
|
83
83
|
"json-schema-typed": "^9.0.0",
|
|
84
84
|
"shared-api": "0.2.16",
|
|
85
85
|
"tsconfig": "0.0.0",
|