fumadocs-openapi 11.4.3 → 12.0.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/css/preset.css +0 -1
- package/dist/_virtual/_rolldown/runtime.js +10 -1
- package/dist/generate-file.d.ts +2 -2
- package/dist/generate-file.js +1 -1
- package/dist/i18n.d.ts +6 -8
- package/dist/i18n.js +2 -17
- package/dist/index.browser.d.ts +13 -0
- package/dist/index.browser.js +11 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -1
- package/dist/operation.d.ts +133 -0
- package/dist/operation.js +296 -0
- package/dist/packages/shared-api/dist/.translations/index.d.ts +29 -0
- package/dist/packages/shared-api/dist/.translations/keys.js +28 -0
- package/dist/packages/shared-api/dist/auto-anchor/client.js +20 -0
- package/dist/packages/shared-api/dist/auto-anchor/index.js +17 -0
- package/dist/packages/shared-api/dist/codegen.d.ts +42 -0
- package/dist/packages/shared-api/dist/codegen.js +35 -0
- package/dist/packages/shared-api/dist/components/accordion.js +71 -0
- package/dist/packages/shared-api/dist/components/badge.js +21 -0
- package/dist/packages/shared-api/dist/components/collapsible.d.ts +7 -0
- package/dist/packages/shared-api/dist/components/collapsible.js +16 -0
- package/dist/packages/shared-api/dist/components/defaults.d.ts +20 -0
- package/dist/packages/shared-api/dist/components/defaults.js +70 -0
- package/dist/packages/shared-api/dist/components/dialog.js +55 -0
- package/dist/packages/shared-api/dist/components/input.js +14 -0
- package/dist/packages/shared-api/dist/components/label.js +11 -0
- package/dist/packages/shared-api/dist/components/playground/inputs.js +439 -0
- package/dist/packages/shared-api/dist/components/playground/schema.js +112 -0
- package/dist/packages/shared-api/dist/components/popover.js +23 -0
- package/dist/packages/shared-api/dist/components/schema/client.d.ts +12 -0
- package/dist/packages/shared-api/dist/components/schema/client.js +508 -0
- package/dist/packages/shared-api/dist/components/schema/index.d.ts +9 -0
- package/dist/packages/shared-api/dist/components/schema/index.js +28 -0
- package/dist/packages/shared-api/dist/components/select-tab.js +54 -0
- package/dist/packages/shared-api/dist/components/select.js +70 -0
- package/dist/packages/shared-api/dist/components/spinner.js +14 -0
- package/dist/packages/shared-api/dist/i18n.d.ts +3 -0
- package/dist/packages/shared-api/dist/i18n.js +7 -0
- package/dist/packages/shared-api/dist/utils/cn.js +2 -0
- package/dist/packages/shared-api/dist/utils/id-to-title.js +12 -0
- package/dist/packages/shared-api/dist/utils/is-plain-object.js +8 -0
- package/dist/packages/shared-api/dist/utils/merge-refs.js +11 -0
- package/dist/packages/shared-api/dist/utils/url.js +13 -0
- package/dist/{utils → packages/shared-api/dist/utils}/use-query.js +2 -1
- package/dist/packages/shared-api/dist/utils/use-server-store.js +56 -0
- package/dist/playground/auth.d.ts +37 -0
- package/dist/playground/auth.js +216 -21
- package/dist/playground/fetcher.d.ts +11 -1
- package/dist/playground/index.d.ts +3 -0
- package/dist/playground/index.js +3 -0
- package/dist/requests/generators/index.d.ts +4 -4
- package/dist/requests/generators/index.js +2 -2
- package/dist/requests/index.d.ts +4 -0
- package/dist/requests/index.js +3 -0
- package/dist/requests/media/adapter.d.ts +1 -0
- package/dist/requests/media/encode.d.ts +7 -2
- package/dist/requests/media/resolve-adapter.d.ts +20 -0
- package/dist/server/index.d.ts +4 -7
- package/dist/server/index.js +1 -7
- package/dist/types.d.ts +0 -14
- package/dist/ui/base.d.ts +3 -2
- package/dist/ui/base.js +15 -166
- package/dist/ui/components/codeblock.js +3 -10
- package/dist/ui/components/heading.js +10 -19
- package/dist/ui/components/markdown.js +4 -6
- package/dist/ui/components/method-label.js +2 -17
- package/dist/ui/components/schema.js +28 -0
- package/dist/ui/index.d.ts +7 -198
- package/dist/ui/index.js +1 -3
- package/dist/ui/operation/index.js +142 -229
- package/dist/ui/operation/request-tabs.js +15 -23
- package/dist/ui/operation/response-tabs.js +9 -53
- package/dist/ui/operation/usage-tabs.js +35 -93
- package/dist/{playground → ui/playground}/client.d.ts +10 -21
- package/dist/ui/playground/client.js +432 -0
- package/dist/{playground → ui/playground}/components/oauth-dialog.js +26 -91
- package/dist/{playground → ui/playground}/components/result-display.d.ts +2 -2
- package/dist/{playground → ui/playground}/components/result-display.js +7 -7
- package/dist/{playground → ui/playground}/components/server-select.js +12 -13
- package/dist/{playground → ui/playground}/status-info.js +2 -2
- package/dist/{scalar → ui/scalar}/client.js +7 -5
- package/dist/{scalar → ui/scalar}/index.d.ts +2 -2
- package/dist/{scalar → ui/scalar}/index.js +3 -7
- package/dist/utils/create-page.d.ts +216 -0
- package/dist/utils/create-page.js +221 -0
- package/dist/utils/document/dereference.d.ts +2 -2
- package/dist/utils/document/dereference.js +8 -3
- package/dist/utils/document/load.js +2 -2
- package/dist/utils/get-example-requests.js +11 -13
- package/dist/utils/pages/builder.d.ts +15 -2
- package/dist/utils/pages/builder.js +6 -6
- package/dist/utils/pages/preset-auto.d.ts +1 -1
- package/dist/utils/pages/preset-auto.js +3 -3
- package/dist/utils/pages/to-static-data.js +4 -4
- package/dist/utils/pages/to-text.d.ts +1 -1
- package/dist/utils/pages/to-text.js +3 -5
- package/dist/utils/schema.js +5 -5
- package/dist/utils/use-server.d.ts +24 -0
- package/dist/utils/use-server.js +57 -0
- package/package.json +28 -20
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/2.0-to-3.0/upgrade-from-two-to-three.js +0 -508
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/3.0-to-3.1/upgrade-from-three-to-three-one.js +0 -152
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.js +0 -61
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/helpers/traverse.js +0 -25
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/upgrade.js +0 -15
- package/dist/playground/client.js +0 -574
- package/dist/ui/contexts/api.d.ts +0 -17
- package/dist/ui/contexts/api.js +0 -84
- package/dist/ui/create-client.d.ts +0 -9
- package/dist/ui/create-client.js +0 -7
- package/dist/ui/operation/context.d.ts +0 -15
- package/dist/ui/operation/context.js +0 -48
- package/dist/ui/operation/request-tabs.d.ts +0 -12
- package/dist/ui/operation/response-tabs.d.ts +0 -30
- package/dist/utils/get-example-requests.d.ts +0 -11
- package/dist/utils/schema.d.ts +0 -3
- package/dist/utils/storage-key.js +0 -15
package/dist/ui/contexts/api.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useStorageKey } from "../../utils/storage-key.js";
|
|
3
|
-
import { createContext, use, useEffect, useMemo, useState } from "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
//#region src/ui/contexts/api.tsx
|
|
6
|
-
const Context = createContext(null);
|
|
7
|
-
const ServerContext = createContext(null);
|
|
8
|
-
function useRenderContext() {
|
|
9
|
-
const ctx = use(Context);
|
|
10
|
-
if (!ctx) throw new Error("Component must be used under <ApiProvider />");
|
|
11
|
-
return ctx;
|
|
12
|
-
}
|
|
13
|
-
function useServerContext() {
|
|
14
|
-
const ctx = use(ServerContext);
|
|
15
|
-
if (!ctx) throw new Error("Component must be used under <ApiProvider />");
|
|
16
|
-
return ctx;
|
|
17
|
-
}
|
|
18
|
-
function RenderContextProvider({ children, ctx }) {
|
|
19
|
-
return /* @__PURE__ */ jsx(Context, {
|
|
20
|
-
value: ctx,
|
|
21
|
-
children
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function ServerProvider({ servers, children }) {
|
|
25
|
-
const storageKey = useStorageKey().of("server-url");
|
|
26
|
-
const [server, setServer] = useState(() => {
|
|
27
|
-
if (!servers || servers.length === 0) return null;
|
|
28
|
-
const defaultItem = servers[0];
|
|
29
|
-
return {
|
|
30
|
-
name: defaultItem.name,
|
|
31
|
-
url: defaultItem.url,
|
|
32
|
-
variables: getDefaultValues(defaultItem)
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const cached = localStorage.getItem(storageKey);
|
|
37
|
-
if (!cached) return;
|
|
38
|
-
try {
|
|
39
|
-
const obj = JSON.parse(cached);
|
|
40
|
-
if (typeof obj === "object" && obj !== null && "url" in obj && typeof obj.url === "string" && "variables" in obj && typeof obj.variables === "object" && obj.variables !== null) setServer(obj);
|
|
41
|
-
} catch {}
|
|
42
|
-
}, [storageKey]);
|
|
43
|
-
return /* @__PURE__ */ jsx(ServerContext, {
|
|
44
|
-
value: useMemo(() => ({
|
|
45
|
-
servers,
|
|
46
|
-
server,
|
|
47
|
-
setServerVariables(variables) {
|
|
48
|
-
setServer((prev) => {
|
|
49
|
-
if (!prev) return null;
|
|
50
|
-
const updated = {
|
|
51
|
-
...prev,
|
|
52
|
-
variables
|
|
53
|
-
};
|
|
54
|
-
localStorage.setItem(storageKey, JSON.stringify(updated));
|
|
55
|
-
return updated;
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
setServer(value) {
|
|
59
|
-
const obj = servers?.find((item) => item.url === value);
|
|
60
|
-
if (!obj) return;
|
|
61
|
-
const result = {
|
|
62
|
-
name: obj.name,
|
|
63
|
-
url: value,
|
|
64
|
-
variables: getDefaultValues(obj)
|
|
65
|
-
};
|
|
66
|
-
localStorage.setItem(storageKey, JSON.stringify(result));
|
|
67
|
-
setServer(result);
|
|
68
|
-
}
|
|
69
|
-
}), [
|
|
70
|
-
server,
|
|
71
|
-
servers,
|
|
72
|
-
storageKey
|
|
73
|
-
]),
|
|
74
|
-
children
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function getDefaultValues(server) {
|
|
78
|
-
const out = {};
|
|
79
|
-
if (!server.variables) return out;
|
|
80
|
-
for (const [k, v] of Object.entries(server.variables)) if (v.default !== void 0) out[k] = String(v.default);
|
|
81
|
-
return out;
|
|
82
|
-
}
|
|
83
|
-
//#endregion
|
|
84
|
-
export { RenderContextProvider, ServerProvider, useRenderContext, useServerContext };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CreateOpenAPIPageOptions, OpenAPIPageProps, createOpenAPIPage } from "./index.js";
|
|
2
|
-
//#region src/ui/create-client.d.ts
|
|
3
|
-
/** @deprecated Use `CreateOpenAPIPageOptions` insteawd */
|
|
4
|
-
export type CreateClientAPIPageOptions = CreateOpenAPIPageOptions;
|
|
5
|
-
/** @deprecated Use `OpenAPIPageProps` instead */
|
|
6
|
-
export type ClientApiPageProps = OpenAPIPageProps;
|
|
7
|
-
/** @deprecated use `createOpenAPIPage()` from `fumadocs-openapi/ui` instead */
|
|
8
|
-
export declare const createClientAPIPage: typeof createOpenAPIPage;
|
|
9
|
-
//#endregion
|
package/dist/ui/create-client.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { createOpenAPIPage } from "./index.js";
|
|
3
|
-
//#region src/ui/create-client.tsx
|
|
4
|
-
/** @deprecated use `createOpenAPIPage()` from `fumadocs-openapi/ui` instead */
|
|
5
|
-
const createClientAPIPage = createOpenAPIPage;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { createClientAPIPage };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { RawRequestData, RequestData } from "../../requests/types.js";
|
|
2
|
-
import { ExampleRequestItem } from "../../utils/get-example-requests.js";
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
|
-
//#region src/ui/operation/context.d.ts
|
|
5
|
-
export type ExampleUpdateListener = (data: RawRequestData, encoded: RequestData) => void;
|
|
6
|
-
export declare function useOperationContext(): {
|
|
7
|
-
route: string;
|
|
8
|
-
examples: ExampleRequestItem[];
|
|
9
|
-
example: string | undefined;
|
|
10
|
-
setExample: (id: string) => void;
|
|
11
|
-
setExampleData: (data: RawRequestData, encoded: RequestData) => void;
|
|
12
|
-
addListener: (listener: ExampleUpdateListener) => void;
|
|
13
|
-
removeListener: (listener: ExampleUpdateListener) => void;
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { createContext, use, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
//#region src/ui/operation/context.tsx
|
|
5
|
-
const OperationContext = createContext(null);
|
|
6
|
-
function OperationProvider({ route, examples, defaultExampleId, children }) {
|
|
7
|
-
const [example, setExample] = useState(() => defaultExampleId ?? examples.at(0)?.id);
|
|
8
|
-
const listeners = useRef([]);
|
|
9
|
-
return /* @__PURE__ */ jsx(OperationContext, {
|
|
10
|
-
value: useMemo(() => ({
|
|
11
|
-
example,
|
|
12
|
-
route,
|
|
13
|
-
setExample(newKey) {
|
|
14
|
-
const example = examples.find((example) => example.id === newKey);
|
|
15
|
-
if (!example) return;
|
|
16
|
-
setExample(newKey);
|
|
17
|
-
for (const listener of listeners.current) listener(example.data, example.encoded);
|
|
18
|
-
},
|
|
19
|
-
examples,
|
|
20
|
-
setExampleData(data, encoded) {
|
|
21
|
-
for (const item of examples) if (item.id === example) {
|
|
22
|
-
item.data = data;
|
|
23
|
-
item.encoded = encoded;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
for (const listener of listeners.current) listener(data, encoded);
|
|
27
|
-
},
|
|
28
|
-
removeListener(listener) {
|
|
29
|
-
listeners.current = listeners.current.filter((item) => item !== listener);
|
|
30
|
-
},
|
|
31
|
-
addListener(listener) {
|
|
32
|
-
const active = examples.find((item) => item.id === example);
|
|
33
|
-
listener(active.data, active.encoded);
|
|
34
|
-
listeners.current.push(listener);
|
|
35
|
-
}
|
|
36
|
-
}), [
|
|
37
|
-
example,
|
|
38
|
-
route,
|
|
39
|
-
examples
|
|
40
|
-
]),
|
|
41
|
-
children
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function useOperationContext() {
|
|
45
|
-
return use(OperationContext);
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
export { OperationProvider, useOperationContext };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ExampleRequestItem } from "../../utils/get-example-requests.js";
|
|
2
|
-
import { HttpMethods, OperationObject, PathItemObject } from "../../types.js";
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
|
-
//#region src/ui/operation/request-tabs.d.ts
|
|
5
|
-
export interface RequestTabsRenderOptions {
|
|
6
|
-
route: string;
|
|
7
|
-
items: ExampleRequestItem[];
|
|
8
|
-
method: HttpMethods;
|
|
9
|
-
pathItem: PathItemObject;
|
|
10
|
-
operation: OperationObject;
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ResponseObject } from "../../types.js";
|
|
2
|
-
import { ReactNode } from "react";
|
|
3
|
-
//#region src/ui/operation/response-tabs.d.ts
|
|
4
|
-
export interface ResponseTab {
|
|
5
|
-
/**
|
|
6
|
-
* HTTP response code
|
|
7
|
-
*/
|
|
8
|
-
code: string;
|
|
9
|
-
response: ResponseObject;
|
|
10
|
-
/**
|
|
11
|
-
* media type of response
|
|
12
|
-
*/
|
|
13
|
-
mediaType: string | null;
|
|
14
|
-
examples?: ResponseExample[];
|
|
15
|
-
}
|
|
16
|
-
interface ResponseExample {
|
|
17
|
-
/**
|
|
18
|
-
* generated/defined example data
|
|
19
|
-
*/
|
|
20
|
-
sample: unknown;
|
|
21
|
-
label: ReactNode;
|
|
22
|
-
/**
|
|
23
|
-
* description (in Markdown)
|
|
24
|
-
*/
|
|
25
|
-
description?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface ResponseTabsRenderOptions {
|
|
28
|
-
tabs: ResponseTab[];
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { RawRequestData, RequestData } from "../requests/types.js";
|
|
2
|
-
import "../types.js";
|
|
3
|
-
//#region src/utils/get-example-requests.d.ts
|
|
4
|
-
export interface ExampleRequestItem {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
data: RawRequestData;
|
|
9
|
-
encoded: RequestData;
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
package/dist/utils/schema.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useRenderContext } from "../ui/contexts/api.js";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
//#region src/utils/storage-key.ts
|
|
4
|
-
function useStorageKey() {
|
|
5
|
-
const { storageKeyPrefix } = useRenderContext();
|
|
6
|
-
return useMemo(() => ({
|
|
7
|
-
of: (name) => getStorageKey(storageKeyPrefix, name),
|
|
8
|
-
AuthField: (schemeId) => getStorageKey(storageKeyPrefix, `auth-${schemeId}`)
|
|
9
|
-
}), [storageKeyPrefix]);
|
|
10
|
-
}
|
|
11
|
-
function getStorageKey(prefix = "fumadocs-openapi-", name) {
|
|
12
|
-
return prefix + name;
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { useStorageKey };
|