fumadocs-openapi 11.1.0 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +1 -1
- package/dist/generate-file.d.ts +0 -1
- package/dist/i18n.d.ts +0 -1
- package/dist/node_modules/.pnpm/xml-js@1.6.11/node_modules/xml-js/lib/js2xml.js +2 -1
- package/dist/playground/auth.js +4 -3
- package/dist/playground/client.d.ts +4 -18
- package/dist/playground/client.js +52 -42
- package/dist/playground/components/oauth-dialog.js +3 -2
- package/dist/playground/components/result-display.d.ts +1 -6
- package/dist/playground/components/server-select.js +8 -1
- package/dist/playground/fetcher.d.ts +1 -1
- package/dist/requests/generators/all.d.ts +0 -1
- package/dist/requests/generators/csharp.d.ts +0 -1
- package/dist/requests/generators/curl.d.ts +0 -1
- package/dist/requests/generators/go.d.ts +0 -1
- package/dist/requests/generators/index.d.ts +1 -5
- package/dist/requests/generators/java.d.ts +0 -1
- package/dist/requests/generators/javascript.d.ts +0 -1
- package/dist/requests/generators/python.d.ts +0 -1
- package/dist/requests/generators/rust.d.ts +0 -1
- package/dist/requests/media/encode.d.ts +2 -0
- package/dist/requests/types.d.ts +0 -1
- package/dist/scalar/index.d.ts +0 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/types/openapi.d.ts +4 -4
- package/dist/types.d.ts +0 -1
- package/dist/ui/base.d.ts +1 -9
- package/dist/ui/base.js +10 -13
- package/dist/ui/create-client.d.ts +0 -1
- package/dist/ui/index.d.ts +6 -8
- package/dist/ui/operation/index.js +41 -30
- package/dist/ui/operation/request-tabs.d.ts +2 -4
- package/dist/ui/operation/response-tabs.d.ts +1 -3
- package/dist/ui/operation/response-tabs.js +19 -9
- package/dist/utils/document/dereference.d.ts +9 -6
- package/dist/utils/document/dereference.js +5 -7
- package/dist/utils/get-example-requests.d.ts +1 -2
- package/dist/utils/get-example-requests.js +19 -14
- package/dist/utils/pages/builder.d.ts +0 -1
- package/dist/utils/pages/builder.js +10 -8
- package/dist/utils/pages/preset-auto.d.ts +0 -1
- package/dist/utils/pages/preset-auto.js +2 -2
- package/dist/utils/pages/to-static-data.js +4 -2
- package/dist/utils/pages/to-text.d.ts +1 -1
- package/dist/utils/pages/to-text.js +5 -3
- package/dist/utils/schema.d.ts +1 -0
- package/dist/utils/schema.js +7 -4
- package/package.json +13 -12
- package/dist/utils/remove-undefined.js +0 -24
package/css/generated/shared.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@source inline("--- --fd-docs-row-1 -mode -ms-2 @4xl:flex-row @4xl:items-start @4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px] @container @default @defaultValue @deprecated @fuma-translate/react @fumari/json-schema-ts @fumari/stf @param @private @scalar/api-client-react @see @typescript-eslint/no-explicit-any a access access_token active adapter adapters addListener all allFlows allow already alt an anchorSegments and animate-spin apiExample apiKey apiPlayground application/javascript application/json application/x-javascript application/x-www-form-urlencoded application/xml apply array as assume async at auth-specific authCodeQuery authCtx authNode authSchemes authorization authorizationCode authorization_code authorize autoComplete avoid await backward badgeVariants base baseDir basic be because before between bg-fd-card bg-fd-muted bg-fd-primary/10 bg-fd-secondary binary blob blue body bodyMediaType bodyNode boolean border border-b border-current border-fd-border border-s border-t border-y buffer builderOptions built-in bundled but button buttonVariants by byteLength bytes cache cached call callback callbacks callbacksNode can cannot case catch changes charset check children class-variance-authority className client clientCredentials clientId clientSecret client_credentials client_error client_id client_secret cloned cn code codeProps codeUsages codegen codegens collapsible color com compatibility
|
|
1
|
+
@source inline("--- --fd-docs-row-1 -mode -ms-2 @4xl:flex-row @4xl:items-start @4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px] @container @default @defaultValue @deprecated @fuma-translate/react @fumari/json-schema-ts @fumari/stf @param @private @scalar/api-client-react @see @typescript-eslint/no-explicit-any a access access_token active adapter adapters addListener against all allFlows allow already alt an anchorSegments and animate-spin apiExample apiKey apiPlayground application/javascript application/json application/x-javascript application/x-www-form-urlencoded application/xml apply are array as assume async at auth-specific authCodeQuery authCtx authNode authSchemes authorization authorizationCode authorization_code authorize autoComplete avoid await backward badgeVariants base baseDir basic be because before between bg-fd-card bg-fd-muted bg-fd-primary/10 bg-fd-secondary binary blob blue body bodyMediaType bodyNode boolean border border-b border-current border-fd-border border-s border-t border-y buffer builderOptions built-in bundled but button buttonVariants by byteLength bytes cache cached call callback callbacks callbacksNode can cannot case catch changes charset check children class-variance-authority className client clientCredentials clientId clientSecret client_credentials client_error client_id client_secret cloned cn code codeProps codeUsages codegen codegens collapsible color com compatibility compiler component components conditions configuration const content contentTypes context cookie cookies core could createAutoPreset createClientAPIPage createCodeUsageGeneratorRegistry createContext createOpenAPIPageBase createProxy credentials css csv ctx current currentValue custom customization cva dark dark:text-blue-400 dark:text-green-400 dark:text-orange-400 dark:text-red-400 dark:text-yellow-400 data data-[open]:border-b-0 data-type default defaultAdapters defaultExampleId defaultItem defaultMdxComponents defaultOpen defaultShikiFactory defaultValue defaultValues default_processMarkdown definitions deprecated depth dereferenceBundledDocument dereferenceShallow dereferenced description descriptionNode development deviceAuthorization dialog didn disable disableCache disabled display displayNames div do doc docRoot docs document documents domain downloaded dynamicSource e each else empty:hidden enabled encodeRequestData encoded endpoint enforce engine ensure entire entries entry error eslint-disable eslint-disable-next-line example exampleId exampleRequests examples export exported extends fall fallback false fast-content-type-parse fd-page-tree-item-name fetch fetcher field fieldName fields file filePath files fine first first:border-t-0 flex flex-1 flex-col flex-col-reverse flex-row flex-wrap flow flows folder folderStyle font-medium font-mono font-semibold for form formData format found from fromSchema fs full fumadocs-core/source fumadocs-core/toc fumadocs-openapi/ui fumadocs-ui/mdx fumadocs:openapi fumadocs_openapi_requests fumadocs_openapi_responses function gap-0.5 gap-1 gap-1.5 gap-2 gap-2.5 gap-24 gap-3 gap-4 gap-6 gap-x-6 gap-y-4 gen generate generateTypeScriptDefinitions generated generated/defined generators get getAPIPageProps getClientAPIPageProps getExampleRequests getOpenAPIPageProps getPreferredType getRaw getSchema getSchemas getWatchPaths github-dark github-light given grant_type green group group-data-[panel-open]:rotate-180 groupId h1 handling hasHead hash hast-util-to-jsx-runtime headNode header headers headingLevel highlighter hook hover:bg-fd-accent hover:text-fd-accent-foreground href html htmlFor http icon id idToTitle idx if ignore img implicit import imports in in-document info initAuthInputs initial inline-flex input inputs instanceof instances instead insteawd interface internal into invalid is isLoading isMediaTypeSupported isRequired issues it item items items-center items-start js json json-schema-typed justify-between kept key keyof label labelVariants lang last:border-b-0 last:mb-0 latest layout lazy length let light line-through list list-disc list-inside listed listener listeners load loadDocument loaderPlugin localStorage lucide-react make map max-age may mb-1 mb-2 md mdxComponents me-auto media mediaAdapters mediaType message meta metaData method methodKeys mime min-w-0 modify mounted ms-auto mt-0! mt-10 mt-2 mt-3 multipart/form-data multiple must my-0! my-1.5 my-4 name name! named necessary need never new newKey no-cache node:fs node:path not not-last:pb-0 not-prose note null number oauth2 obj object of off omit on onChange onClick onCopy onOpenChange onSubmit onValueChange one only open openApiData openIdConnect openapi openapiMeta openid operation operationDescription operationId operations options or orange origin other out outline output overflow-auto overflow-hidden p p-2 p-3 packages page page-level pageData pages panelVariants param paramTypeKeys parameter parameterLabel parameterNode parameters params parent parsed parsedState parts party pass password path pathItem pathnameFromRequest payload pb-2 pe-3 persist persisted persistent place placeholder playground playgrounds please plugins pre prefix preloadOpenAPIPage preloaded prevent primary processed processor prop properties props prose-no-margin provider proxy proxyForwardCookie proxyUrl ps-2 ps-4.5 pt-1 pt-2 pt-2.5 px-1 px-2 px-3 py-0.5 py-1 py-1.5 py-2 query race raw react react-hooks/exhaustive-deps react/jsx-runtime readOnly readonly record red redirect_uri reference refs registerDefault registry rehype-react relativePath remark remark-rehype remarkGfm remarkRehype removeListener render renderAPIExampleLayout renderAPIExampleUsageTabs renderOperationLayout renderPageLayout renderParameterField renderRequestTabs renderRequestTabsDefault renderResponseTabs renderResponseTabsDefault renderWebhookLayout renderer replace request request-body requestData requestInit requestTimeout requestUrl requests required requirement requirementId requirements res reset resolvable resolve resolveMediaAdapter resolveServerUrl resolvedInput resolvedTheme resolves response response-body responseNode responseOfType responseTabs response_type responses rest result return returned returning root rounded-2xl rounded-lg rounded-md rounded-xl route s safeParse same sample satisfies scalar scan schema schemaId schemaMap schemaUI schemaUIShared schemas scheme schemeId schemes scope scopes search secondary seconds secret securities security securityEntries securityId securitySchemes segments segs select selector separator server server-to-server server-url serverSchema servers services set setData setExample setExampleData setIsJson setIsMounted setMounted setObjectUrl setOpen setRequirementId setSecurityId setServer setServerVariables setStore setToken setType setValue shadow-md shadow-sm shiki shikiOptions showDescription showExample showResponseSchema showTitle shrink-0 side signal single size size-3.5 size-4 slot slots sm so source spec specify spread src state staticSource status statusInfo statuses stf stfSync still storageKey storageKeys store stored string stringifyFieldKey structuredData styles submit summary supported sure switch t tab tabs testQuery text text-[0.8125rem] text-blue-600 text-fd-card-foreground text-fd-foreground text-fd-muted-foreground text-fd-primary text-fd-secondary-foreground text-green-500 text-green-600 text-nowrap text-orange-600 text-red-400 text-red-500 text-red-600 text-sm text-start text-xs text-yellow-600 text/css text/csv text/html text/plain the their them themes this through throw timeout timerRef tips title to toJsxRuntime toStaticData toc token tokenInfo token_type transform transformAuthInputs transformPageTree transition-colors tree true truncate try ts type typeof types typescript unchanged under unexpected unknown unlisted update updated updatedSchemeId updating url usage usageTabs usages use useAnchorId useApiClient useAuth useCopyButton useMemo useOnChange useOperationContext useQuery useRef useRenderContext useServerContext useState useStatusInfo useStf useStorageKey useTheme useTranslations used username using utf-8 v value values variable variables variant variants via virtual void w-14 w-fit w-full warn we webhook webhookCallbacks webhooks when whitespace-pre-wrap will with without won wrapping writeOnly x-codeSamples x-exclusiveCodeSample x-selectedCodeSample xml yellow you your");
|
package/dist/generate-file.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { SchemaToPagesOptions } from "./utils/pages/preset-auto.js";
|
|
|
3
3
|
import { OpenAPIServer } from "./server/index.js";
|
|
4
4
|
import { DistributiveOmit } from "./types.js";
|
|
5
5
|
import { PagesToTextOptions } from "./utils/pages/to-text.js";
|
|
6
|
-
|
|
7
6
|
//#region src/generate-file.d.ts
|
|
8
7
|
interface OutputFile {
|
|
9
8
|
path: string;
|
package/dist/i18n.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { Translations } from "./.translations/index.js";
|
|
|
2
2
|
import { Translations as Translations$1 } from "@fumadocs/api-docs/i18n";
|
|
3
3
|
import { TranslationExtension } from "fumadocs-core/i18n";
|
|
4
4
|
import { I18nUIConfig } from "fumadocs-ui/i18n";
|
|
5
|
-
|
|
6
5
|
//#region src/i18n.d.ts
|
|
7
6
|
declare function openapiTranslations(): TranslationExtension<keyof Translations | keyof Translations$1>;
|
|
8
7
|
/** @deprecated use `i18n.translations()` & `openapiTranslations()` instead */
|
|
@@ -5,7 +5,8 @@ import { require_options_helper } from "./options-helper.js";
|
|
|
5
5
|
var require_js2xml = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
6
|
var helper = require_options_helper();
|
|
7
7
|
var isArray = require_array_helper().isArray;
|
|
8
|
-
var currentElement
|
|
8
|
+
var currentElement;
|
|
9
|
+
var currentElementName;
|
|
9
10
|
function validateOptions(userOptions) {
|
|
10
11
|
var options = helper.copyOptions(userOptions);
|
|
11
12
|
helper.ensureFlagExists("ignoreDeclaration", options);
|
package/dist/playground/auth.js
CHANGED
|
@@ -11,10 +11,11 @@ function useAuth() {
|
|
|
11
11
|
return ctx;
|
|
12
12
|
}
|
|
13
13
|
function AuthProvider({ children }) {
|
|
14
|
-
const
|
|
14
|
+
const { dereferenced, resolve } = useRenderContext().schema;
|
|
15
|
+
const schemes = dereferenced.components?.securitySchemes;
|
|
15
16
|
const [store, setStore] = useState({});
|
|
16
17
|
const authCodeQuery = useQuery(async (code, state) => {
|
|
17
|
-
const scheme = schemes?.[state.scheme];
|
|
18
|
+
const scheme = resolve(schemes?.[state.scheme]);
|
|
18
19
|
if (!scheme || scheme.type !== "oauth2") return;
|
|
19
20
|
const value = scheme.flows?.authorizationCode;
|
|
20
21
|
if (!value) return;
|
|
@@ -58,7 +59,7 @@ function AuthProvider({ children }) {
|
|
|
58
59
|
const type = hash.get("token_type") ?? "Bearer";
|
|
59
60
|
if (!state || !token) return;
|
|
60
61
|
const parsedState = JSON.parse(state);
|
|
61
|
-
const scheme = schemes?.[parsedState.scheme];
|
|
62
|
+
const scheme = resolve(schemes?.[parsedState.scheme]);
|
|
62
63
|
if (!scheme || scheme.type !== "oauth2" || !scheme.flows?.implicit) return;
|
|
63
64
|
const info = {
|
|
64
65
|
type: "implicit",
|
|
@@ -5,8 +5,6 @@ import { HttpMethods, OperationObject, ParameterObject, PathItemObject } from ".
|
|
|
5
5
|
import { ComponentProps, FC, ReactNode } from "react";
|
|
6
6
|
import { Collapsible } from "@fumadocs/api-docs/components/collapsible";
|
|
7
7
|
import { FieldKey } from "@fumari/stf";
|
|
8
|
-
import { NoReference } from "@fumadocs/api-docs/schema";
|
|
9
|
-
|
|
10
8
|
//#region src/playground/client.d.ts
|
|
11
9
|
interface FormValues extends Record<string, unknown> {
|
|
12
10
|
path: Record<string, unknown>;
|
|
@@ -18,8 +16,8 @@ interface FormValues extends Record<string, unknown> {
|
|
|
18
16
|
interface PlaygroundClientProps extends Omit<ComponentProps<'form'>, 'method'> {
|
|
19
17
|
route: string;
|
|
20
18
|
method: HttpMethods;
|
|
21
|
-
operation:
|
|
22
|
-
pathItem:
|
|
19
|
+
operation: OperationObject;
|
|
20
|
+
pathItem: PathItemObject;
|
|
23
21
|
writeOnly: boolean;
|
|
24
22
|
readOnly: boolean;
|
|
25
23
|
}
|
|
@@ -57,15 +55,7 @@ interface RequestBodyInfo {
|
|
|
57
55
|
schema: ParsedSchema;
|
|
58
56
|
mediaType: string;
|
|
59
57
|
}
|
|
60
|
-
declare function PlaygroundClient({
|
|
61
|
-
route,
|
|
62
|
-
method,
|
|
63
|
-
operation,
|
|
64
|
-
pathItem,
|
|
65
|
-
writeOnly,
|
|
66
|
-
readOnly,
|
|
67
|
-
...rest
|
|
68
|
-
}: PlaygroundClientProps): import("react").JSX.Element;
|
|
58
|
+
declare function PlaygroundClient({ route, method, operation, pathItem, writeOnly, readOnly, ...rest }: PlaygroundClientProps): import("react").JSX.Element;
|
|
69
59
|
declare const ParamTypes: readonly ["path", "header", "cookie", "query"];
|
|
70
60
|
type ParamType = (typeof ParamTypes)[number];
|
|
71
61
|
interface AuthField {
|
|
@@ -76,11 +66,7 @@ interface AuthField {
|
|
|
76
66
|
children: ReactNode;
|
|
77
67
|
mapOutput?: (values: unknown) => unknown;
|
|
78
68
|
}
|
|
79
|
-
declare function DefaultCollapsiblePanel({
|
|
80
|
-
title,
|
|
81
|
-
children,
|
|
82
|
-
...props
|
|
83
|
-
}: CollapsiblePanelProps): import("react").JSX.Element;
|
|
69
|
+
declare function DefaultCollapsiblePanel({ title, children, ...props }: CollapsiblePanelProps): import("react").JSX.Element;
|
|
84
70
|
declare const Custom: {
|
|
85
71
|
useController(fieldName: FieldKey, options?: {
|
|
86
72
|
defaultValue?: unknown;
|
|
@@ -15,7 +15,7 @@ import { OAuthDialog, OAuthDialogContent, OAuthDialogTrigger } from "./component
|
|
|
15
15
|
import { dereferenceShallow } from "@fumadocs/api-docs/schema/dereference";
|
|
16
16
|
import { Fragment, useEffect, useMemo, useRef, useState } from "react";
|
|
17
17
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
-
import { ChevronDown, LoaderCircle } from "lucide-react";
|
|
18
|
+
import { ChevronDown, LoaderCircle, PlusIcon } from "lucide-react";
|
|
19
19
|
import { useTranslations } from "@fuma-translate/react";
|
|
20
20
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
21
21
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@fumadocs/api-docs/components/collapsible";
|
|
@@ -32,29 +32,25 @@ import { Spinner } from "@fumadocs/api-docs/components/spinner";
|
|
|
32
32
|
function PlaygroundClient({ route, method, operation, pathItem, writeOnly, readOnly, ...rest }) {
|
|
33
33
|
const t = useTranslations({ note: "playground" });
|
|
34
34
|
const ctx = useRenderContext();
|
|
35
|
-
const {
|
|
35
|
+
const { dereferenced } = ctx.schema;
|
|
36
36
|
const { parameters, body } = useMemo(() => {
|
|
37
37
|
const parameters = [];
|
|
38
|
-
if (operation.parameters) for (const p of operation.parameters) parameters.push(dereferenceShallow(p
|
|
39
|
-
if (pathItem.parameters) for (const p of pathItem.parameters) parameters.push(dereferenceShallow(p
|
|
38
|
+
if (operation.parameters) for (const p of operation.parameters) parameters.push(dereferenceShallow(p));
|
|
39
|
+
if (pathItem.parameters) for (const p of pathItem.parameters) parameters.push(dereferenceShallow(p));
|
|
40
40
|
let body;
|
|
41
41
|
if (operation.requestBody) {
|
|
42
|
-
const content = dereferenceShallow(operation.requestBody
|
|
42
|
+
const content = dereferenceShallow(operation.requestBody).content;
|
|
43
43
|
const mediaType = content ? getPreferredType(content) : void 0;
|
|
44
44
|
if (content && mediaType) body = {
|
|
45
45
|
mediaType,
|
|
46
|
-
schema: dereferenceShallow(content[mediaType]
|
|
46
|
+
schema: dereferenceShallow(content[mediaType]).schema ?? true
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
return {
|
|
50
50
|
body,
|
|
51
51
|
parameters
|
|
52
52
|
};
|
|
53
|
-
}, [
|
|
54
|
-
bundled,
|
|
55
|
-
operation,
|
|
56
|
-
pathItem
|
|
57
|
-
]);
|
|
53
|
+
}, [operation, pathItem]);
|
|
58
54
|
const securityEntries = useMemo(() => {
|
|
59
55
|
const result = [];
|
|
60
56
|
const security = operation.security ?? dereferenced.security ?? [];
|
|
@@ -130,7 +126,7 @@ function PlaygroundClient({ route, method, operation, pathItem, writeOnly, readO
|
|
|
130
126
|
return /* @__PURE__ */ jsx(StfProvider, {
|
|
131
127
|
value: stf,
|
|
132
128
|
children: /* @__PURE__ */ jsx(SchemaProvider, {
|
|
133
|
-
docRoot:
|
|
129
|
+
docRoot: dereferenced,
|
|
134
130
|
writeOnly,
|
|
135
131
|
readOnly,
|
|
136
132
|
children: /* @__PURE__ */ jsxs("form", {
|
|
@@ -187,10 +183,42 @@ function SecurityRequirements({ securities, setSecurityId, securityId, children
|
|
|
187
183
|
const { isLoading, error } = useAuth();
|
|
188
184
|
const defaultOpen = isLoading || error != null;
|
|
189
185
|
const [open, setOpen] = useState(defaultOpen);
|
|
190
|
-
const { CollapsiblePanel = DefaultCollapsiblePanel } =
|
|
186
|
+
const { schema: { dereferenced, resolve }, playground: { components: { CollapsiblePanel = DefaultCollapsiblePanel } = {} } = {} } = useRenderContext();
|
|
187
|
+
const schemes = dereferenced.components?.securitySchemes;
|
|
191
188
|
useOnChange(defaultOpen, () => {
|
|
192
189
|
if (defaultOpen) setOpen(true);
|
|
193
190
|
});
|
|
191
|
+
const items = securities.map((requirement, i) => {
|
|
192
|
+
if (requirement.length === 1) {
|
|
193
|
+
const scheme = resolve(schemes?.[requirement[0].id]);
|
|
194
|
+
return {
|
|
195
|
+
value: i,
|
|
196
|
+
label: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
197
|
+
className: cn("font-mono font-medium", scheme?.deprecated && "text-fd-muted-foreground line-through"),
|
|
198
|
+
children: requirement[0].id
|
|
199
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
200
|
+
className: "text-fd-muted-foreground whitespace-pre-wrap",
|
|
201
|
+
children: scheme?.description
|
|
202
|
+
})] })
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
value: i,
|
|
207
|
+
label: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
208
|
+
className: "inline-flex items-center gap-1 font-mono font-medium",
|
|
209
|
+
children: requirement.map((item, i) => /* @__PURE__ */ jsxs(Fragment, { children: [i > 0 && /* @__PURE__ */ jsx(PlusIcon, { className: "text-fd-muted-foreground size-3.5" }), /* @__PURE__ */ jsx("span", {
|
|
210
|
+
className: cn(resolve(schemes?.[item.id])?.deprecated && "text-fd-muted-foreground line-through"),
|
|
211
|
+
children: item.id
|
|
212
|
+
})] }, i))
|
|
213
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
214
|
+
className: "text-fd-muted-foreground whitespace-pre-wrap list-disc list-inside",
|
|
215
|
+
children: requirement.map((item, i) => /* @__PURE__ */ jsx("li", {
|
|
216
|
+
className: "empty:hidden",
|
|
217
|
+
children: resolve(schemes?.[item.id])?.description
|
|
218
|
+
}, i))
|
|
219
|
+
})] })
|
|
220
|
+
};
|
|
221
|
+
});
|
|
194
222
|
return /* @__PURE__ */ jsxs(CollapsiblePanel, {
|
|
195
223
|
title: /* @__PURE__ */ jsxs(Fragment$1, { children: [t("Authorization"), isLoading && /* @__PURE__ */ jsxs("span", {
|
|
196
224
|
className: "border-s ps-2 inline-flex items-center gap-1.5 text-fd-muted-foreground text-xs font-mono",
|
|
@@ -212,38 +240,18 @@ function SecurityRequirements({ securities, setSecurityId, securityId, children
|
|
|
212
240
|
}), /* @__PURE__ */ jsx("p", { children: String(error) })]
|
|
213
241
|
}),
|
|
214
242
|
/* @__PURE__ */ jsxs(Select, {
|
|
215
|
-
items
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
})),
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
value: i.toString(),
|
|
223
|
-
children: /* @__PURE__ */ jsx(SecurityRequirement, { requirement: security })
|
|
224
|
-
}, i)) })]
|
|
243
|
+
items,
|
|
244
|
+
value: securityId,
|
|
245
|
+
onValueChange: (v) => v !== null && setSecurityId(v),
|
|
246
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }), /* @__PURE__ */ jsx(SelectContent, { children: items.map(({ value, label }) => /* @__PURE__ */ jsx(SelectItem, {
|
|
247
|
+
value,
|
|
248
|
+
children: label
|
|
249
|
+
}, value)) })]
|
|
225
250
|
}),
|
|
226
251
|
children
|
|
227
252
|
]
|
|
228
253
|
});
|
|
229
254
|
}
|
|
230
|
-
function SecurityRequirement({ requirement }) {
|
|
231
|
-
const schemes = useRenderContext().schema.dereferenced.components?.securitySchemes;
|
|
232
|
-
return /* @__PURE__ */ jsx("div", {
|
|
233
|
-
className: "flex flex-col gap-2 max-w-[600px]",
|
|
234
|
-
children: requirement.map((item) => {
|
|
235
|
-
const scheme = schemes?.[item.id];
|
|
236
|
-
if (!scheme) return;
|
|
237
|
-
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
238
|
-
className: cn("font-mono font-medium", scheme.deprecated && "text-fd-muted-foreground line-through"),
|
|
239
|
-
children: item.id
|
|
240
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
241
|
-
className: "text-fd-muted-foreground whitespace-pre-wrap",
|
|
242
|
-
children: scheme.description
|
|
243
|
-
})] }, item.id);
|
|
244
|
-
})
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
255
|
const ParamTypes = [
|
|
248
256
|
"path",
|
|
249
257
|
"header",
|
|
@@ -328,18 +336,19 @@ function useAuthInputs(engine, requirements) {
|
|
|
328
336
|
const storageKeys = useStorageKey();
|
|
329
337
|
const t = useTranslations({ note: "playground" });
|
|
330
338
|
const ctx = useRenderContext();
|
|
339
|
+
const { resolve } = ctx.schema;
|
|
331
340
|
const schemes = ctx.schema.dereferenced.components?.securitySchemes;
|
|
332
341
|
const { transformAuthInputs } = ctx.playground ?? {};
|
|
333
342
|
const [requirementId, setRequirementId] = useState(() => {
|
|
334
343
|
if (!schemes || requirements.length === 0) return -1;
|
|
335
|
-
const idx = requirements.findIndex((s) => s.every((item) => !schemes[item.id].deprecated));
|
|
344
|
+
const idx = requirements.findIndex((s) => s.every((item) => !resolve(schemes[item.id]).deprecated));
|
|
336
345
|
return idx !== -1 ? idx : 0;
|
|
337
346
|
});
|
|
338
347
|
const requirement = requirementId === -1 ? null : requirements[requirementId];
|
|
339
348
|
let inputs = useMemo(() => {
|
|
340
349
|
if (!requirement || !schemes) return [];
|
|
341
350
|
return requirement.map((item) => {
|
|
342
|
-
const scheme = schemes?.[item.id];
|
|
351
|
+
const scheme = resolve(schemes?.[item.id]);
|
|
343
352
|
if (scheme.type === "http" && scheme.scheme === "basic") {
|
|
344
353
|
const fieldName = ["header", "Authorization"];
|
|
345
354
|
return {
|
|
@@ -430,6 +439,7 @@ function useAuthInputs(engine, requirements) {
|
|
|
430
439
|
requirement,
|
|
431
440
|
storageKeys,
|
|
432
441
|
schemes,
|
|
442
|
+
resolve,
|
|
433
443
|
t
|
|
434
444
|
]);
|
|
435
445
|
if (transformAuthInputs) inputs = transformAuthInputs(inputs);
|
|
@@ -16,9 +16,10 @@ function OAuthDialogContent(props) {
|
|
|
16
16
|
return /* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: t("Authorization") }), /* @__PURE__ */ jsx(DialogDescription, { children: t("Obtain the access token for API.") })] }), /* @__PURE__ */ jsx(Content, { ...props })] });
|
|
17
17
|
}
|
|
18
18
|
function Content({ schemeId, scopes, setToken, setOpen }) {
|
|
19
|
-
const
|
|
19
|
+
const { dereferenced, resolve } = useRenderContext().schema;
|
|
20
|
+
const schemes = dereferenced.components?.securitySchemes;
|
|
20
21
|
const tokenInfo = useAuth().store[schemeId];
|
|
21
|
-
const scheme = schemes?.[schemeId];
|
|
22
|
+
const scheme = resolve(schemes?.[schemeId]);
|
|
22
23
|
if (!scheme || scheme.type !== "oauth2") throw new Error("unexpected schemaId: must be type oauth2");
|
|
23
24
|
const [type, setType] = useState(() => {
|
|
24
25
|
return Object.keys(scheme.flows)[0];
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { FetchResult } from "../fetcher.js";
|
|
2
2
|
import { ComponentProps } from "react";
|
|
3
|
-
|
|
4
3
|
//#region src/playground/components/result-display.d.ts
|
|
5
4
|
interface ResultDisplayProps extends ComponentProps<'div'> {
|
|
6
5
|
data: FetchResult;
|
|
7
6
|
reset: () => void;
|
|
8
7
|
}
|
|
9
|
-
declare function DefaultResultDisplay({
|
|
10
|
-
data,
|
|
11
|
-
reset,
|
|
12
|
-
...rest
|
|
13
|
-
}: ResultDisplayProps): import("react").JSX.Element;
|
|
8
|
+
declare function DefaultResultDisplay({ data, reset, ...rest }: ResultDisplayProps): import("react").JSX.Element;
|
|
14
9
|
//#endregion
|
|
15
10
|
export { DefaultResultDisplay, ResultDisplayProps };
|
|
@@ -41,6 +41,13 @@ function ServerSelect(props) {
|
|
|
41
41
|
}), /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
42
42
|
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: t("Server URL") }), /* @__PURE__ */ jsx(DialogDescription, { children: t("The base URL of your API endpoint.") })] }),
|
|
43
43
|
/* @__PURE__ */ jsxs(Select, {
|
|
44
|
+
items: servers.map((server) => ({
|
|
45
|
+
value: server.url,
|
|
46
|
+
label: /* @__PURE__ */ jsx("code", {
|
|
47
|
+
className: "text-[0.8125rem]",
|
|
48
|
+
children: server.url
|
|
49
|
+
})
|
|
50
|
+
})),
|
|
44
51
|
value: server?.url ?? null,
|
|
45
52
|
onValueChange: (v) => v !== null && setServer(v),
|
|
46
53
|
children: [/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }), /* @__PURE__ */ jsx(SelectContent, { children: servers.map((item) => /* @__PURE__ */ jsxs(SelectItem, {
|
|
@@ -111,7 +118,7 @@ function Field({ fieldName, variable }) {
|
|
|
111
118
|
id: fieldName,
|
|
112
119
|
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
113
120
|
}), /* @__PURE__ */ jsx(SelectContent, { children: variable.enum.map((value) => /* @__PURE__ */ jsx(SelectItem, {
|
|
114
|
-
value
|
|
121
|
+
value,
|
|
115
122
|
children: value
|
|
116
123
|
}, value)) })]
|
|
117
124
|
});
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { MediaAdapter } from "../media/adapter.js";
|
|
2
2
|
import { RequestData } from "../types.js";
|
|
3
3
|
import * as Shared from "@fumadocs/api-docs/codegen";
|
|
4
|
-
|
|
5
4
|
//#region src/requests/generators/index.d.ts
|
|
6
|
-
declare function pathnameFromRequest(pathname: string, {
|
|
7
|
-
path,
|
|
8
|
-
query
|
|
9
|
-
}: RequestData): string;
|
|
5
|
+
declare function pathnameFromRequest(pathname: string, { path, query }: RequestData): string;
|
|
10
6
|
type CodeUsageGeneratorRegistry = Shared.CodeUsageGeneratorRegistry<RequestData & {
|
|
11
7
|
url: string;
|
|
12
8
|
}, {
|
package/dist/requests/types.d.ts
CHANGED
package/dist/scalar/index.d.ts
CHANGED
package/dist/server/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { Awaitable, Document } from "../types.js";
|
|
|
5
5
|
import { DynamicSource, LoaderPlugin, MetaData, Page, PageData, Source } from "fumadocs-core/source";
|
|
6
6
|
import { StructuredData } from "fumadocs-core/mdx-plugins/remark-structure";
|
|
7
7
|
import { TOCItemType } from "fumadocs-core/toc";
|
|
8
|
-
|
|
9
8
|
//#region src/server/index.d.ts
|
|
10
9
|
/**
|
|
11
10
|
* schema ID -> file path, URL, downloaded schema object, or a function returning them
|
|
@@ -70,7 +69,8 @@ interface OpenAPIPageData extends PageData {
|
|
|
70
69
|
getClientAPIPageProps: () => OpenAPIPageProps_Spec;
|
|
71
70
|
}
|
|
72
71
|
type OpenAPISourceOptions = SchemaToPagesOptions & {
|
|
73
|
-
baseDir?: string;
|
|
72
|
+
baseDir?: string;
|
|
73
|
+
/** Generate `meta.json` files */
|
|
74
74
|
meta?: boolean | {
|
|
75
75
|
folderStyle?: 'folder' | 'separator';
|
|
76
76
|
};
|
package/dist/types/openapi.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ declare namespace OpenAPIV3_2 {
|
|
|
42
42
|
}>;
|
|
43
43
|
type PathsObject<T = {}, P extends {} = {}> = Record<string, (PathItemObject<T> & P) | undefined>;
|
|
44
44
|
type HttpMethods = OpenAPIV3_1.HttpMethods | 'query';
|
|
45
|
-
type PathItemObject<T = {}> = Modify<OpenAPIV3_1.PathItemObject<T>, { [method in HttpMethods]?: OperationObject<T
|
|
45
|
+
type PathItemObject<T = {}> = Modify<OpenAPIV3_1.PathItemObject<T>, { [method in HttpMethods]?: OperationObject<T>; }> & {
|
|
46
46
|
additionalOperations?: Record<string, OperationObject<T>>;
|
|
47
47
|
parameters?: (ReferenceObject | ParameterObject)[];
|
|
48
48
|
};
|
|
@@ -220,7 +220,7 @@ declare namespace OpenAPIV3_1 {
|
|
|
220
220
|
type PathItemObject<T = {}> = Modify<OpenAPIV3.PathItemObject<T>, {
|
|
221
221
|
servers?: ServerObject[];
|
|
222
222
|
parameters?: (ReferenceObject | ParameterObject)[];
|
|
223
|
-
}> & { [method in HttpMethods]?: OperationObject<T
|
|
223
|
+
}> & { [method in HttpMethods]?: OperationObject<T>; };
|
|
224
224
|
type OperationObject<T = {}> = Modify<OpenAPIV3.OperationObject<T>, {
|
|
225
225
|
parameters?: (ReferenceObject | ParameterObject)[];
|
|
226
226
|
requestBody?: ReferenceObject | RequestBodyObject;
|
|
@@ -392,7 +392,7 @@ declare namespace OpenAPIV3 {
|
|
|
392
392
|
description?: string;
|
|
393
393
|
servers?: ServerObject[];
|
|
394
394
|
parameters?: (ReferenceObject | ParameterObject)[];
|
|
395
|
-
} & { [method in HttpMethods]?: OperationObject<T
|
|
395
|
+
} & { [method in HttpMethods]?: OperationObject<T>; } & T;
|
|
396
396
|
type OperationObject<T = {}> = {
|
|
397
397
|
tags?: string[];
|
|
398
398
|
summary?: string;
|
|
@@ -768,7 +768,7 @@ declare namespace OpenAPIV2 {
|
|
|
768
768
|
type PathItemObject<T = {}> = {
|
|
769
769
|
$ref?: string;
|
|
770
770
|
parameters?: Parameters;
|
|
771
|
-
} & { [method in HttpMethods]?: OperationObject<T
|
|
771
|
+
} & { [method in HttpMethods]?: OperationObject<T>; };
|
|
772
772
|
type PathsObject<T = {}> = {
|
|
773
773
|
[index: string]: PathItemObject<T>;
|
|
774
774
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { CreateOpenAPIPageOptions } from "./ui/index.js";
|
|
|
5
5
|
import { OpenAPIOptions } from "./server/index.js";
|
|
6
6
|
import { FC, ReactNode } from "react";
|
|
7
7
|
import { SchemaUIOptions } from "@fumadocs/api-docs/components/schema";
|
|
8
|
-
|
|
9
8
|
//#region src/types.d.ts
|
|
10
9
|
type Document = OpenAPIV3_2.Document;
|
|
11
10
|
type OperationObject = OpenAPIV3_2.OperationObject & {
|
package/dist/ui/base.d.ts
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { CreateOpenAPIPageOptions, OpenAPIPageProps } from "./index.js";
|
|
2
2
|
import { FC } from "react";
|
|
3
3
|
import { ShikiFactory } from "fumadocs-core/highlight/shiki";
|
|
4
|
-
|
|
5
4
|
//#region src/ui/base.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Create `<OpenAPIPage />` (a client component) without the full Shiki bundle.
|
|
8
7
|
*/
|
|
9
|
-
declare function createOpenAPIPageBase({
|
|
10
|
-
shiki,
|
|
11
|
-
shikiOptions,
|
|
12
|
-
schemaUI: schemaUIOptions,
|
|
13
|
-
codeUsages,
|
|
14
|
-
generateTypeScriptDefinitions,
|
|
15
|
-
...options
|
|
16
|
-
}: CreateOpenAPIPageOptions & {
|
|
8
|
+
declare function createOpenAPIPageBase({ shiki, shikiOptions, schemaUI: schemaUIOptions, codeUsages, generateTypeScriptDefinitions, ...options }: CreateOpenAPIPageOptions & {
|
|
17
9
|
shiki: ShikiFactory;
|
|
18
10
|
}): FC<OpenAPIPageProps>;
|
|
19
11
|
//#endregion
|
package/dist/ui/base.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Markdown } from "./components/markdown.js";
|
|
|
8
8
|
import { Operation } from "./operation/index.js";
|
|
9
9
|
import { dereferenceBundledDocument } from "../utils/document/dereference.js";
|
|
10
10
|
import { registerDefault } from "../requests/generators/all.js";
|
|
11
|
+
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
11
12
|
import { Children, useMemo } from "react";
|
|
12
13
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
13
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -16,7 +17,7 @@ import defaultMdxComponents from "fumadocs-ui/mdx";
|
|
|
16
17
|
import { remark } from "remark";
|
|
17
18
|
import remarkRehype from "remark-rehype";
|
|
18
19
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
19
|
-
import {
|
|
20
|
+
import { generate } from "@fumari/json-schema-ts";
|
|
20
21
|
import { Schema } from "@fumadocs/api-docs/components/schema";
|
|
21
22
|
//#region src/ui/base.tsx
|
|
22
23
|
/**
|
|
@@ -28,11 +29,13 @@ function createOpenAPIPageBase({ shiki, shikiOptions = { themes: {
|
|
|
28
29
|
} }, schemaUI: schemaUIOptions, codeUsages = registerDefault(createCodeUsageGeneratorRegistry()), generateTypeScriptDefinitions = (schema, ctx) => {
|
|
29
30
|
if (typeof schema !== "object") return;
|
|
30
31
|
try {
|
|
31
|
-
return
|
|
32
|
+
return generate({
|
|
33
|
+
...ctx.ctx.schema.bundled,
|
|
34
|
+
...getRaw(schema)
|
|
35
|
+
}, {
|
|
32
36
|
name: ctx.name,
|
|
33
37
|
readOnly: ctx.readOnly,
|
|
34
|
-
writeOnly: ctx.writeOnly
|
|
35
|
-
getSchemaId: ctx.ctx.schema.getRawRef
|
|
38
|
+
writeOnly: ctx.writeOnly
|
|
36
39
|
});
|
|
37
40
|
} catch (e) {
|
|
38
41
|
console.warn("Failed to generate typescript schema:", e);
|
|
@@ -76,12 +79,6 @@ function createOpenAPIPageBase({ shiki, shikiOptions = { themes: {
|
|
|
76
79
|
},
|
|
77
80
|
renderMarkdown(md) {
|
|
78
81
|
return /* @__PURE__ */ jsx(Markdown, { md });
|
|
79
|
-
},
|
|
80
|
-
resolver(v) {
|
|
81
|
-
return {
|
|
82
|
-
dereferenced: v,
|
|
83
|
-
$ref: typeof v === "object" ? processed.getRawRef(v) : void 0
|
|
84
|
-
};
|
|
85
82
|
}
|
|
86
83
|
};
|
|
87
84
|
return {
|
|
@@ -118,7 +115,7 @@ function createOpenAPIPageBase({ shiki, shikiOptions = { themes: {
|
|
|
118
115
|
}
|
|
119
116
|
function PageContent({ showTitle: hasHead = false, showDescription, operations, webhooks }) {
|
|
120
117
|
const ctx = useRenderContext();
|
|
121
|
-
const { dereferenced } = ctx.schema;
|
|
118
|
+
const { dereferenced, resolve } = ctx.schema;
|
|
122
119
|
let { renderPageLayout } = ctx.content ?? {};
|
|
123
120
|
renderPageLayout ??= (slots) => /* @__PURE__ */ jsxs("div", {
|
|
124
121
|
className: "flex flex-col gap-24 text-sm @container",
|
|
@@ -126,7 +123,7 @@ function PageContent({ showTitle: hasHead = false, showDescription, operations,
|
|
|
126
123
|
});
|
|
127
124
|
let content = renderPageLayout({
|
|
128
125
|
operations: operations?.map((item) => {
|
|
129
|
-
const pathItem = dereferenced.paths?.[item.path];
|
|
126
|
+
const pathItem = resolve(dereferenced.paths?.[item.path]);
|
|
130
127
|
if (!pathItem) throw new Error(`[Fumadocs OpenAPI] Path not found in OpenAPI schema: ${item.path}`);
|
|
131
128
|
const operation = pathItem[item.method];
|
|
132
129
|
if (!operation) throw new Error(`[Fumadocs OpenAPI] Method ${item.method} not found in operation: ${item.path}`);
|
|
@@ -143,7 +140,7 @@ function PageContent({ showTitle: hasHead = false, showDescription, operations,
|
|
|
143
140
|
};
|
|
144
141
|
}),
|
|
145
142
|
webhooks: webhooks?.map((item) => {
|
|
146
|
-
const webhook = dereferenced.webhooks?.[item.name];
|
|
143
|
+
const webhook = resolve(dereferenced.webhooks?.[item.name]);
|
|
147
144
|
if (!webhook) throw new Error(`[Fumadocs OpenAPI] Webhook not found in OpenAPI schema: ${item.name}`);
|
|
148
145
|
const hook = webhook[item.method];
|
|
149
146
|
if (!hook) throw new Error(`[Fumadocs OpenAPI] Method ${item.method} not found in webhook: ${item.name}`);
|