fumadocs-openapi 10.6.4 → 10.6.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 +34 -7
- package/dist/_openapi/types.d.ts +1 -2
- package/dist/generate-file.d.ts +1 -2
- package/dist/generate-file.js +3 -4
- package/dist/i18n.d.ts +2 -2
- package/dist/i18n.js +1 -2
- package/dist/playground/auth.js +92 -0
- package/dist/playground/client.d.ts +5 -10
- package/dist/playground/client.js +280 -199
- package/dist/playground/components/inputs.js +0 -2
- package/dist/playground/components/oauth-dialog.js +125 -164
- package/dist/playground/components/server-select.js +0 -2
- package/dist/playground/components/spinner.js +14 -0
- package/dist/playground/fetcher.d.ts +1 -2
- package/dist/playground/fetcher.js +0 -2
- package/dist/playground/schema.d.ts +1 -2
- package/dist/playground/schema.js +24 -15
- package/dist/playground/status-info.js +0 -2
- package/dist/requests/generators/all.d.ts +1 -2
- package/dist/requests/generators/all.js +0 -2
- package/dist/requests/generators/csharp.d.ts +1 -2
- package/dist/requests/generators/csharp.js +2 -3
- package/dist/requests/generators/curl.d.ts +1 -2
- package/dist/requests/generators/curl.js +5 -7
- package/dist/requests/generators/go.d.ts +1 -2
- package/dist/requests/generators/go.js +5 -7
- package/dist/requests/generators/index.d.ts +1 -2
- package/dist/requests/generators/index.js +0 -2
- package/dist/requests/generators/java.d.ts +1 -2
- package/dist/requests/generators/java.js +4 -6
- package/dist/requests/generators/javascript.d.ts +1 -2
- package/dist/requests/generators/javascript.js +3 -5
- package/dist/requests/generators/python.d.ts +1 -2
- package/dist/requests/generators/python.js +5 -6
- package/dist/requests/media/adapter.d.ts +1 -2
- package/dist/requests/media/adapter.js +7 -9
- package/dist/requests/media/encode.d.ts +1 -2
- package/dist/requests/media/encode.js +0 -2
- package/dist/requests/media/resolve-adapter.js +0 -2
- package/dist/requests/string-utils.js +25 -6
- package/dist/requests/types.d.ts +4 -4
- package/dist/scalar/client.js +0 -2
- package/dist/scalar/index.d.ts +1 -2
- package/dist/scalar/index.js +0 -2
- package/dist/server/create.d.ts +2 -3
- package/dist/server/create.js +0 -2
- package/dist/server/proxy.d.ts +1 -2
- package/dist/server/proxy.js +0 -2
- package/dist/server/source-api.d.ts +1 -2
- package/dist/server/source-api.js +0 -2
- package/dist/types.d.ts +1 -2
- package/dist/ui/api-page.d.ts +1 -2
- package/dist/ui/api-page.js +3 -3
- package/dist/ui/base.d.ts +9 -6
- package/dist/ui/base.js +8 -5
- package/dist/ui/client/boundary.d.ts +1 -2
- package/dist/ui/client/boundary.js +0 -2
- package/dist/ui/client/boundary.lazy.js +2 -3
- package/dist/ui/client/full.js +0 -2
- package/dist/ui/client/i18n.js +0 -2
- package/dist/ui/client/index.d.ts +1 -2
- package/dist/ui/client/index.js +0 -2
- package/dist/ui/client/storage-key.js +1 -3
- package/dist/ui/components/accordion.js +0 -2
- package/dist/ui/components/codeblock.d.ts +1 -2
- package/dist/ui/components/codeblock.js +0 -2
- package/dist/ui/components/dialog.js +0 -2
- package/dist/ui/components/input.js +0 -2
- package/dist/ui/components/method-label.js +0 -2
- package/dist/ui/components/select-tab.js +0 -2
- package/dist/ui/components/select.js +0 -2
- package/dist/ui/contexts/api.d.ts +7 -5
- package/dist/ui/contexts/api.js +7 -4
- package/dist/ui/create-client.d.ts +1 -2
- package/dist/ui/create-client.js +6 -3
- package/dist/ui/index.d.ts +1 -2
- package/dist/ui/index.js +0 -2
- package/dist/ui/operation/client.js +0 -2
- package/dist/ui/operation/get-example-requests.d.ts +1 -2
- package/dist/ui/operation/get-example-requests.js +0 -2
- package/dist/ui/operation/index.js +0 -2
- package/dist/ui/operation/request-tabs.d.ts +10 -0
- package/dist/ui/operation/request-tabs.js +43 -39
- package/dist/ui/operation/response-tabs.d.ts +1 -2
- package/dist/ui/operation/response-tabs.js +0 -2
- package/dist/ui/operation/usage-tabs/client.d.ts +1 -2
- package/dist/ui/operation/usage-tabs/client.js +0 -2
- package/dist/ui/operation/usage-tabs/index.js +0 -2
- package/dist/ui/schema/client.d.ts +1 -2
- package/dist/ui/schema/client.js +0 -2
- package/dist/ui/schema/index.d.ts +3 -4
- package/dist/ui/schema/index.js +1 -3
- package/dist/utils/deep-equal.js +0 -2
- package/dist/utils/document/dereference.d.ts +1 -2
- package/dist/utils/document/dereference.js +0 -2
- package/dist/utils/document/process.d.ts +1 -2
- package/dist/utils/document/process.js +0 -2
- package/dist/utils/id-to-title.js +0 -2
- package/dist/utils/is-plain-object.js +0 -2
- package/dist/utils/pages/builder.d.ts +1 -2
- package/dist/utils/pages/builder.js +0 -2
- package/dist/utils/pages/preset-auto.d.ts +1 -2
- package/dist/utils/pages/preset-auto.js +0 -2
- package/dist/utils/pages/to-static-data.js +0 -2
- package/dist/utils/pages/to-text.d.ts +1 -2
- package/dist/utils/pages/to-text.js +5 -6
- package/dist/utils/remove-undefined.js +0 -2
- package/dist/utils/schema/dereference.js +22 -14
- package/dist/utils/schema/index.d.ts +4 -10
- package/dist/utils/schema/index.js +4 -11
- package/dist/utils/{merge-schema.js → schema/merge.js} +2 -4
- package/dist/utils/schema/pick.js +0 -2
- package/dist/utils/schema/ref.js +0 -2
- package/dist/utils/schema/resolve-ref.js +0 -2
- package/dist/utils/schema/to-string.js +4 -7
- package/dist/utils/url.js +0 -2
- package/dist/utils/use-query.js +2 -3
- package/package.json +2 -2
- package/dist/_openapi/types.d.ts.map +0 -1
- package/dist/generate-file.d.ts.map +0 -1
- package/dist/generate-file.js.map +0 -1
- package/dist/i18n.d.ts.map +0 -1
- package/dist/i18n.js.map +0 -1
- package/dist/playground/client.d.ts.map +0 -1
- package/dist/playground/client.js.map +0 -1
- package/dist/playground/components/inputs.js.map +0 -1
- package/dist/playground/components/oauth-dialog.js.map +0 -1
- package/dist/playground/components/server-select.js.map +0 -1
- package/dist/playground/fetcher.d.ts.map +0 -1
- package/dist/playground/fetcher.js.map +0 -1
- package/dist/playground/schema.d.ts.map +0 -1
- package/dist/playground/schema.js.map +0 -1
- package/dist/playground/status-info.js.map +0 -1
- package/dist/requests/generators/all.d.ts.map +0 -1
- package/dist/requests/generators/all.js.map +0 -1
- package/dist/requests/generators/csharp.d.ts.map +0 -1
- package/dist/requests/generators/csharp.js.map +0 -1
- package/dist/requests/generators/curl.d.ts.map +0 -1
- package/dist/requests/generators/curl.js.map +0 -1
- package/dist/requests/generators/go.d.ts.map +0 -1
- package/dist/requests/generators/go.js.map +0 -1
- package/dist/requests/generators/index.d.ts.map +0 -1
- package/dist/requests/generators/index.js.map +0 -1
- package/dist/requests/generators/java.d.ts.map +0 -1
- package/dist/requests/generators/java.js.map +0 -1
- package/dist/requests/generators/javascript.d.ts.map +0 -1
- package/dist/requests/generators/javascript.js.map +0 -1
- package/dist/requests/generators/python.d.ts.map +0 -1
- package/dist/requests/generators/python.js.map +0 -1
- package/dist/requests/media/adapter.d.ts.map +0 -1
- package/dist/requests/media/adapter.js.map +0 -1
- package/dist/requests/media/encode.d.ts.map +0 -1
- package/dist/requests/media/encode.js.map +0 -1
- package/dist/requests/media/resolve-adapter.js.map +0 -1
- package/dist/requests/string-utils.js.map +0 -1
- package/dist/requests/types.d.ts.map +0 -1
- package/dist/scalar/client.js.map +0 -1
- package/dist/scalar/index.d.ts.map +0 -1
- package/dist/scalar/index.js.map +0 -1
- package/dist/server/create.d.ts.map +0 -1
- package/dist/server/create.js.map +0 -1
- package/dist/server/proxy.d.ts.map +0 -1
- package/dist/server/proxy.js.map +0 -1
- package/dist/server/source-api.d.ts.map +0 -1
- package/dist/server/source-api.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/ui/api-page.d.ts.map +0 -1
- package/dist/ui/api-page.js.map +0 -1
- package/dist/ui/base.d.ts.map +0 -1
- package/dist/ui/base.js.map +0 -1
- package/dist/ui/client/boundary.d.ts.map +0 -1
- package/dist/ui/client/boundary.js.map +0 -1
- package/dist/ui/client/boundary.lazy.js.map +0 -1
- package/dist/ui/client/full.js.map +0 -1
- package/dist/ui/client/i18n.js.map +0 -1
- package/dist/ui/client/index.d.ts.map +0 -1
- package/dist/ui/client/index.js.map +0 -1
- package/dist/ui/client/storage-key.js.map +0 -1
- package/dist/ui/components/accordion.js.map +0 -1
- package/dist/ui/components/codeblock.d.ts.map +0 -1
- package/dist/ui/components/codeblock.js.map +0 -1
- package/dist/ui/components/dialog.js.map +0 -1
- package/dist/ui/components/input.js.map +0 -1
- package/dist/ui/components/method-label.js.map +0 -1
- package/dist/ui/components/select-tab.js.map +0 -1
- package/dist/ui/components/select.js.map +0 -1
- package/dist/ui/contexts/api.d.ts.map +0 -1
- package/dist/ui/contexts/api.js.map +0 -1
- package/dist/ui/create-client.d.ts.map +0 -1
- package/dist/ui/create-client.js.map +0 -1
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/operation/client.js.map +0 -1
- package/dist/ui/operation/get-example-requests.d.ts.map +0 -1
- package/dist/ui/operation/get-example-requests.js.map +0 -1
- package/dist/ui/operation/index.js.map +0 -1
- package/dist/ui/operation/request-tabs.js.map +0 -1
- package/dist/ui/operation/response-tabs.d.ts.map +0 -1
- package/dist/ui/operation/response-tabs.js.map +0 -1
- package/dist/ui/operation/usage-tabs/client.d.ts.map +0 -1
- package/dist/ui/operation/usage-tabs/client.js.map +0 -1
- package/dist/ui/operation/usage-tabs/index.js.map +0 -1
- package/dist/ui/schema/client.d.ts.map +0 -1
- package/dist/ui/schema/client.js.map +0 -1
- package/dist/ui/schema/index.d.ts.map +0 -1
- package/dist/ui/schema/index.js.map +0 -1
- package/dist/utils/deep-equal.js.map +0 -1
- package/dist/utils/document/dereference.d.ts.map +0 -1
- package/dist/utils/document/dereference.js.map +0 -1
- package/dist/utils/document/process.d.ts.map +0 -1
- package/dist/utils/document/process.js.map +0 -1
- package/dist/utils/id-to-title.js.map +0 -1
- package/dist/utils/is-plain-object.js.map +0 -1
- package/dist/utils/merge-schema.js.map +0 -1
- package/dist/utils/pages/builder.d.ts.map +0 -1
- package/dist/utils/pages/builder.js.map +0 -1
- package/dist/utils/pages/preset-auto.d.ts.map +0 -1
- package/dist/utils/pages/preset-auto.js.map +0 -1
- package/dist/utils/pages/to-static-data.js.map +0 -1
- package/dist/utils/pages/to-text.d.ts.map +0 -1
- package/dist/utils/pages/to-text.js.map +0 -1
- package/dist/utils/remove-undefined.js.map +0 -1
- package/dist/utils/schema/dereference.js.map +0 -1
- package/dist/utils/schema/index.d.ts.map +0 -1
- package/dist/utils/schema/index.js.map +0 -1
- package/dist/utils/schema/pick.js.map +0 -1
- package/dist/utils/schema/ref.js.map +0 -1
- package/dist/utils/schema/resolve-ref.js.map +0 -1
- package/dist/utils/schema/to-string.js.map +0 -1
- package/dist/utils/url.js.map +0 -1
- package/dist/utils/use-query.js.map +0 -1
package/dist/ui/contexts/api.js
CHANGED
|
@@ -18,7 +18,7 @@ function useServerContext() {
|
|
|
18
18
|
if (!ctx) throw new Error("Component must be used under <ApiProvider />");
|
|
19
19
|
return ctx;
|
|
20
20
|
}
|
|
21
|
-
function ApiProvider({ children, shikiOptions, client }) {
|
|
21
|
+
function ApiProvider({ children, shikiOptions, client, schemes }) {
|
|
22
22
|
return /* @__PURE__ */ jsx(ApiContext, {
|
|
23
23
|
value: useMemo(() => {
|
|
24
24
|
let codeUsages;
|
|
@@ -31,12 +31,17 @@ function ApiProvider({ children, shikiOptions, client }) {
|
|
|
31
31
|
shikiOptions,
|
|
32
32
|
client,
|
|
33
33
|
codeUsages,
|
|
34
|
+
schemes,
|
|
34
35
|
mediaAdapters: {
|
|
35
36
|
...defaultAdapters,
|
|
36
37
|
...client.mediaAdapters
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
|
-
}, [
|
|
40
|
+
}, [
|
|
41
|
+
client,
|
|
42
|
+
schemes,
|
|
43
|
+
shikiOptions
|
|
44
|
+
]),
|
|
40
45
|
children
|
|
41
46
|
});
|
|
42
47
|
}
|
|
@@ -101,5 +106,3 @@ function getDefaultValues(server) {
|
|
|
101
106
|
}
|
|
102
107
|
//#endregion
|
|
103
108
|
export { ApiProvider, ServerProvider, useApiContext, useServerContext };
|
|
104
|
-
|
|
105
|
-
//# sourceMappingURL=api.js.map
|
|
@@ -22,5 +22,4 @@ declare function createClientAPIPage({
|
|
|
22
22
|
...options
|
|
23
23
|
}?: CreateClientAPIPageOptions): FC<ClientApiPageProps>;
|
|
24
24
|
//#endregion
|
|
25
|
-
export { ClientApiPagePayload, ClientApiPageProps, CreateClientAPIPageOptions, createClientAPIPage };
|
|
26
|
-
//# sourceMappingURL=create-client.d.ts.map
|
|
25
|
+
export { ClientApiPagePayload, ClientApiPageProps, CreateClientAPIPageOptions, createClientAPIPage };
|
package/dist/ui/create-client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseSecurities } from "../utils/schema/index.js";
|
|
2
2
|
import { defaultAdapters } from "../requests/media/adapter.js";
|
|
3
3
|
import { ClientCodeBlock, ClientCodeBlockProvider } from "./components/codeblock.js";
|
|
4
|
+
import { AuthProvider } from "../playground/auth.js";
|
|
4
5
|
import { dereferenceDocument } from "../utils/document/dereference.js";
|
|
5
6
|
import { APIPage } from "./api-page.js";
|
|
6
7
|
import { boundary_exports } from "./client/boundary.js";
|
|
@@ -60,12 +61,15 @@ function createClientAPIPage({ shiki = defaultShikiFactory, shikiOptions = { the
|
|
|
60
61
|
route: path,
|
|
61
62
|
securities: parseSecurities(method, ctx.schema.dereferenced),
|
|
62
63
|
method: method.method,
|
|
63
|
-
doc:
|
|
64
|
+
doc: ctx.schema.bundled,
|
|
64
65
|
proxyUrl: ctx.proxyUrl,
|
|
65
66
|
writeOnly: true,
|
|
66
67
|
readOnly: false
|
|
67
68
|
});
|
|
68
69
|
}
|
|
70
|
+
function renderPlaygroundProviderDefault({ children }) {
|
|
71
|
+
return /* @__PURE__ */ jsx(AuthProvider, { children });
|
|
72
|
+
}
|
|
69
73
|
return function ClientAPIPage({ payload, ...props }) {
|
|
70
74
|
const processed = useMemo(() => dereferenceDocument(payload.bundled), [payload.bundled]);
|
|
71
75
|
const ctx = useMemo(() => ({
|
|
@@ -82,6 +86,7 @@ function createClientAPIPage({ shiki = defaultShikiFactory, shikiOptions = { the
|
|
|
82
86
|
},
|
|
83
87
|
playground: {
|
|
84
88
|
...options.playground,
|
|
89
|
+
provider: options.playground?.provider ?? renderPlaygroundProviderDefault,
|
|
85
90
|
render: options.playground?.render ?? renderPlaygroundDefault
|
|
86
91
|
},
|
|
87
92
|
renderHeading(depth, text, props) {
|
|
@@ -135,5 +140,3 @@ function MarkdownPre(props) {
|
|
|
135
140
|
}
|
|
136
141
|
//#endregion
|
|
137
142
|
export { createClientAPIPage };
|
|
138
|
-
|
|
139
|
-
//# sourceMappingURL=create-client.js.map
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -7,5 +7,4 @@ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
7
7
|
type CreateAPIPageOptions = Partial<CreateAPIPageOptions$1>;
|
|
8
8
|
declare function createAPIPage(server: OpenAPIServer, options?: CreateAPIPageOptions): (props: ServerApiPageProps) => _$react_jsx_runtime0.JSX.Element;
|
|
9
9
|
//#endregion
|
|
10
|
-
export { type ApiPageProps, CreateAPIPageOptions, type OperationItem, type WebhookItem, createAPIPage };
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
10
|
+
export { type ApiPageProps, CreateAPIPageOptions, type OperationItem, type WebhookItem, createAPIPage };
|
package/dist/ui/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MethodInformation, RenderContext } from "../../types.js";
|
|
2
|
+
import { NoReference } from "../../utils/schema/index.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
//#region src/ui/operation/request-tabs.d.ts
|
|
5
|
+
interface RequestTabsRenderContext extends RenderContext {
|
|
6
|
+
route: string;
|
|
7
|
+
operation: NoReference<MethodInformation>;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { RequestTabsRenderContext };
|
|
@@ -15,41 +15,6 @@ function RequestTabs({ path, operation, examples, ctx }) {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
function renderRequestTabsDefault(items, ctx) {
|
|
18
|
-
function renderItem(item) {
|
|
19
|
-
const requestData = item.data;
|
|
20
|
-
const displayNames = {
|
|
21
|
-
body: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(I18nLabel, { label: "titleRequestBody" }), /* @__PURE__ */ jsx("code", {
|
|
22
|
-
className: "text-xs text-fd-muted-foreground ms-auto",
|
|
23
|
-
children: requestData.bodyMediaType
|
|
24
|
-
})] }),
|
|
25
|
-
cookie: /* @__PURE__ */ jsx(I18nLabel, { label: "cookieParameters" }),
|
|
26
|
-
header: /* @__PURE__ */ jsx(I18nLabel, { label: "headerParameters" }),
|
|
27
|
-
query: /* @__PURE__ */ jsx(I18nLabel, { label: "queryParameters" }),
|
|
28
|
-
path: /* @__PURE__ */ jsx(I18nLabel, { label: "pathParameters" })
|
|
29
|
-
};
|
|
30
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
-
item.description && ctx.renderMarkdown(item.description),
|
|
32
|
-
/* @__PURE__ */ jsxs("div", {
|
|
33
|
-
className: "flex flex-row gap-2 items-center justify-between",
|
|
34
|
-
children: [/* @__PURE__ */ jsx(MethodLabel, { children: requestData.method }), /* @__PURE__ */ jsx("code", { children: resolveRequestData(ctx.route, item.encoded) })]
|
|
35
|
-
}),
|
|
36
|
-
/* @__PURE__ */ jsx(Accordions, {
|
|
37
|
-
type: "multiple",
|
|
38
|
-
className: "mt-2",
|
|
39
|
-
children: Object.entries(displayNames).map(([k, v]) => {
|
|
40
|
-
const data = requestData[k];
|
|
41
|
-
if (!data || Object.keys(data).length === 0) return;
|
|
42
|
-
return /* @__PURE__ */ jsxs(AccordionItem, {
|
|
43
|
-
value: k,
|
|
44
|
-
children: [/* @__PURE__ */ jsx(AccordionHeader, { children: /* @__PURE__ */ jsx(AccordionTrigger, { children: v }) }), /* @__PURE__ */ jsx(AccordionContent, {
|
|
45
|
-
className: "prose-no-margin",
|
|
46
|
-
children: ctx.renderCodeBlock("json", JSON.stringify(data, null, 2))
|
|
47
|
-
})]
|
|
48
|
-
}, k);
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
] });
|
|
52
|
-
}
|
|
53
18
|
let children;
|
|
54
19
|
if (items.length > 1) children = /* @__PURE__ */ jsxs(Tabs, {
|
|
55
20
|
defaultValue: items[0].id,
|
|
@@ -58,10 +23,16 @@ function renderRequestTabsDefault(items, ctx) {
|
|
|
58
23
|
children: item.id === "_default" ? /* @__PURE__ */ jsx(I18nLabel, { label: "requestTabNameDefault" }) : item.name
|
|
59
24
|
}, item.id)) }), items.map((item) => /* @__PURE__ */ jsx(TabsContent, {
|
|
60
25
|
value: item.id,
|
|
61
|
-
children:
|
|
26
|
+
children: /* @__PURE__ */ jsx(RequestTabsItem, {
|
|
27
|
+
item,
|
|
28
|
+
ctx
|
|
29
|
+
})
|
|
62
30
|
}, item.id))]
|
|
63
31
|
});
|
|
64
|
-
else if (items.length === 1) children =
|
|
32
|
+
else if (items.length === 1) children = /* @__PURE__ */ jsx(RequestTabsItem, {
|
|
33
|
+
item: items[0],
|
|
34
|
+
ctx
|
|
35
|
+
});
|
|
65
36
|
else children = /* @__PURE__ */ jsx("p", {
|
|
66
37
|
className: "text-fd-muted-foreground text-xs",
|
|
67
38
|
children: /* @__PURE__ */ jsx(I18nLabel, { label: "empty" })
|
|
@@ -74,7 +45,40 @@ function renderRequestTabsDefault(items, ctx) {
|
|
|
74
45
|
}), children]
|
|
75
46
|
});
|
|
76
47
|
}
|
|
48
|
+
function RequestTabsItem({ item, ctx }) {
|
|
49
|
+
const requestData = item.data;
|
|
50
|
+
const displayNames = {
|
|
51
|
+
body: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(I18nLabel, { label: "titleRequestBody" }), /* @__PURE__ */ jsx("code", {
|
|
52
|
+
className: "text-xs text-fd-muted-foreground ms-auto",
|
|
53
|
+
children: requestData.bodyMediaType
|
|
54
|
+
})] }),
|
|
55
|
+
cookie: /* @__PURE__ */ jsx(I18nLabel, { label: "cookieParameters" }),
|
|
56
|
+
header: /* @__PURE__ */ jsx(I18nLabel, { label: "headerParameters" }),
|
|
57
|
+
query: /* @__PURE__ */ jsx(I18nLabel, { label: "queryParameters" }),
|
|
58
|
+
path: /* @__PURE__ */ jsx(I18nLabel, { label: "pathParameters" })
|
|
59
|
+
};
|
|
60
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
61
|
+
item.description && ctx.renderMarkdown(item.description),
|
|
62
|
+
/* @__PURE__ */ jsxs("div", {
|
|
63
|
+
className: "flex flex-row gap-2 items-center justify-between",
|
|
64
|
+
children: [/* @__PURE__ */ jsx(MethodLabel, { children: requestData.method }), /* @__PURE__ */ jsx("code", { children: resolveRequestData(ctx.route, item.encoded) })]
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ jsx(Accordions, {
|
|
67
|
+
type: "multiple",
|
|
68
|
+
className: "mt-2",
|
|
69
|
+
children: Object.entries(displayNames).map(([k, v]) => {
|
|
70
|
+
const data = requestData[k];
|
|
71
|
+
if (!data || Object.keys(data).length === 0) return;
|
|
72
|
+
return /* @__PURE__ */ jsxs(AccordionItem, {
|
|
73
|
+
value: k,
|
|
74
|
+
children: [/* @__PURE__ */ jsx(AccordionHeader, { children: /* @__PURE__ */ jsx(AccordionTrigger, { children: v }) }), /* @__PURE__ */ jsx(AccordionContent, {
|
|
75
|
+
className: "prose-no-margin",
|
|
76
|
+
children: ctx.renderCodeBlock("json", JSON.stringify(data, null, 2))
|
|
77
|
+
})]
|
|
78
|
+
}, k);
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
] });
|
|
82
|
+
}
|
|
77
83
|
//#endregion
|
|
78
84
|
export { RequestTabs };
|
|
79
|
-
|
|
80
|
-
//# sourceMappingURL=request-tabs.js.map
|
package/dist/ui/schema/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SchemaUIProps } from "./client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ParsedSchema } from "../../utils/schema/index.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
//#region src/ui/schema/index.d.ts
|
|
5
5
|
interface FieldBase {
|
|
@@ -42,7 +42,7 @@ type SchemaData = FieldBase & ({
|
|
|
42
42
|
}[];
|
|
43
43
|
});
|
|
44
44
|
interface SchemaUIOptions {
|
|
45
|
-
root:
|
|
45
|
+
root: ParsedSchema;
|
|
46
46
|
client: Omit<SchemaUIProps, 'generated'>;
|
|
47
47
|
/**
|
|
48
48
|
* include read only props
|
|
@@ -58,5 +58,4 @@ interface SchemaUIGeneratedData {
|
|
|
58
58
|
refs: Record<string, SchemaData>;
|
|
59
59
|
}
|
|
60
60
|
//#endregion
|
|
61
|
-
export { SchemaUIGeneratedData, SchemaUIOptions };
|
|
62
|
-
//# sourceMappingURL=index.d.ts.map
|
|
61
|
+
export { SchemaUIGeneratedData, SchemaUIOptions };
|
package/dist/ui/schema/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mergeAllOf } from "../../utils/merge
|
|
1
|
+
import { mergeAllOf } from "../../utils/schema/merge.js";
|
|
2
2
|
import { FormatFlags, schemaToString } from "../../utils/schema/to-string.js";
|
|
3
3
|
import { I18nLabel } from "../client/i18n.js";
|
|
4
4
|
import { useMemo } from "react";
|
|
@@ -254,5 +254,3 @@ function formatRange(value, min, exclusiveMin, max, exclusiveMax) {
|
|
|
254
254
|
}
|
|
255
255
|
//#endregion
|
|
256
256
|
export { Schema };
|
|
257
|
-
|
|
258
|
-
//# sourceMappingURL=index.js.map
|
package/dist/utils/deep-equal.js
CHANGED
|
@@ -85,5 +85,4 @@ interface ExtractedInfo {
|
|
|
85
85
|
declare function fromServer(server: OpenAPIServer, config: PagesBuilderConfig): Promise<Record<string, OutputEntry[]>>;
|
|
86
86
|
declare function fromSchema(schemaId: string, processed: DereferencedDocument, config: PagesBuilderConfig): OutputEntry[];
|
|
87
87
|
//#endregion
|
|
88
|
-
export { OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput, fromSchema, fromServer };
|
|
89
|
-
//# sourceMappingURL=builder.d.ts.map
|
|
88
|
+
export { OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput, fromSchema, fromServer };
|
|
@@ -68,5 +68,4 @@ interface BaseConfig {
|
|
|
68
68
|
}
|
|
69
69
|
declare function createAutoPreset(options: SchemaToPagesOptions): PagesBuilderConfig;
|
|
70
70
|
//#endregion
|
|
71
|
-
export { SchemaToPagesOptions, createAutoPreset };
|
|
72
|
-
//# sourceMappingURL=preset-auto.d.ts.map
|
|
71
|
+
export { SchemaToPagesOptions, createAutoPreset };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { removeUndefined } from "../remove-undefined.js";
|
|
2
2
|
import { toStaticData } from "./to-static-data.js";
|
|
3
|
+
import { doubleQuote } from "../../requests/string-utils.js";
|
|
3
4
|
import { dump } from "js-yaml";
|
|
4
5
|
//#region src/utils/pages/to-text.ts
|
|
5
6
|
function toText(entry, processed, options = {}) {
|
|
@@ -36,7 +37,7 @@ function generateDocument(frontmatter, content, options) {
|
|
|
36
37
|
commentContent = commentContent.replaceAll("/", "\\/");
|
|
37
38
|
out.push(`{/* ${commentContent} */}`);
|
|
38
39
|
}
|
|
39
|
-
if (imports) out.push(...imports.map((item) => `import { ${item.names.join(", ")} } from ${
|
|
40
|
+
if (imports) out.push(...imports.map((item) => `import { ${item.names.join(", ")} } from ${doubleQuote(item.from)};`).join("\n"));
|
|
40
41
|
out.push(content);
|
|
41
42
|
return out.join("\n\n");
|
|
42
43
|
}
|
|
@@ -70,7 +71,7 @@ function generatePage(schemaId, processed, pageProps, options, context) {
|
|
|
70
71
|
}, content.join("\n\n"), options);
|
|
71
72
|
}
|
|
72
73
|
function pageContent({ showTitle, showDescription, document, webhooks, operations }) {
|
|
73
|
-
const propStrs = [`document={${
|
|
74
|
+
const propStrs = [`document={${doubleQuote(document)}}`];
|
|
74
75
|
if (webhooks) propStrs.push(`webhooks={${JSON.stringify(webhooks.map((item) => ({
|
|
75
76
|
name: item.name,
|
|
76
77
|
method: item.method
|
|
@@ -79,11 +80,9 @@ function pageContent({ showTitle, showDescription, document, webhooks, operation
|
|
|
79
80
|
path: item.path,
|
|
80
81
|
method: item.method
|
|
81
82
|
})))}}`);
|
|
82
|
-
if (showTitle) propStrs.push(`showTitle
|
|
83
|
-
if (showDescription) propStrs.push(`showDescription
|
|
83
|
+
if (showTitle) propStrs.push(`showTitle`);
|
|
84
|
+
if (showDescription) propStrs.push(`showDescription`);
|
|
84
85
|
return `<APIPage ${propStrs.join(" ")} />`;
|
|
85
86
|
}
|
|
86
87
|
//#endregion
|
|
87
88
|
export { generateDocument, toText };
|
|
88
|
-
|
|
89
|
-
//# sourceMappingURL=to-text.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPlainObject } from "../is-plain-object.js";
|
|
1
2
|
import { resolveRefSync } from "./resolve-ref.js";
|
|
2
3
|
//#region src/utils/schema/dereference.ts
|
|
3
4
|
/**
|
|
@@ -8,30 +9,37 @@ function dereferenceSync(schema, setOriginalRef) {
|
|
|
8
9
|
const visitedNodes = /* @__PURE__ */ new Set();
|
|
9
10
|
const cloned = structuredClone(schema);
|
|
10
11
|
function resolve(current) {
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return current;
|
|
17
|
-
}
|
|
18
|
-
const obj = current;
|
|
19
|
-
if ("$ref" in current && typeof current["$ref"] === "string") {
|
|
12
|
+
if (visitedNodes.has(current)) return current;
|
|
13
|
+
visitedNodes.add(current);
|
|
14
|
+
if (Array.isArray(current)) for (let index = 0; index < current.length; index++) current[index] = resolve(current[index]);
|
|
15
|
+
else if (isPlainObject(current)) {
|
|
16
|
+
if (typeof current.$ref === "string") {
|
|
20
17
|
const ref = current["$ref"];
|
|
21
18
|
delete current["$ref"];
|
|
22
19
|
const resolved = resolve(resolveRefSync(ref, cloned));
|
|
23
20
|
setOriginalRef(resolved, ref);
|
|
24
21
|
setOriginalRef(current, ref);
|
|
25
22
|
if (typeof resolved === "boolean") throw new Error("invalid schema");
|
|
26
|
-
for (const k in resolved) if (!(k in current))
|
|
23
|
+
for (const k in resolved) if (!(k in current)) current[k] = resolved[k];
|
|
27
24
|
}
|
|
28
|
-
for (const key in current)
|
|
25
|
+
for (const key in current) current[key] = resolve(current[key]);
|
|
29
26
|
}
|
|
30
27
|
return current;
|
|
31
28
|
}
|
|
32
29
|
return resolve(cloned);
|
|
33
30
|
}
|
|
31
|
+
function dereferenceSwallow(schema, full) {
|
|
32
|
+
if (isPlainObject(schema)) {
|
|
33
|
+
if (typeof schema.$ref !== "string") return schema;
|
|
34
|
+
const { $ref, ...rest } = schema;
|
|
35
|
+
const resolved = dereferenceSwallow(resolveRefSync($ref, full), full);
|
|
36
|
+
if (typeof resolved !== "object") throw new Error(`invalid schema referenced via "${$ref}"`);
|
|
37
|
+
return {
|
|
38
|
+
...resolved,
|
|
39
|
+
...rest
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return schema;
|
|
43
|
+
}
|
|
34
44
|
//#endregion
|
|
35
|
-
export { dereferenceSync };
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=dereference.js.map
|
|
45
|
+
export { dereferenceSwallow, dereferenceSync };
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import { ReferenceObject
|
|
1
|
+
import { ReferenceObject } from "../../types.js";
|
|
2
2
|
import { JSONSchema } from "json-schema-typed/draft-2020-12";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/schema/index.d.ts
|
|
5
5
|
type NoReference<T> = T extends (infer I)[] ? NoReference<I>[] : T extends ReferenceObject ? Exclude<T, ReferenceObject> : T extends object ? { [K in keyof T]: NoReference<T[K]> } : T;
|
|
6
|
-
type NoReferenceJSONSchema<T> = T extends (infer I)[] ? NoReference<I>[] : T extends {
|
|
7
|
-
$ref?: string;
|
|
8
|
-
} ? Omit<T, '$ref'> : T;
|
|
9
6
|
type ParsedSchema = (JSONSchema & {
|
|
10
7
|
'x-playground-lazy'?: boolean;
|
|
11
8
|
}) | boolean;
|
|
12
|
-
|
|
13
|
-
/** parsed security scheme objects */
|
|
14
|
-
type SecurityEntry = SecuritySchemeObject & {
|
|
9
|
+
interface SecurityEntry {
|
|
15
10
|
scopes: string[];
|
|
16
11
|
id: string;
|
|
17
|
-
}
|
|
12
|
+
}
|
|
18
13
|
//#endregion
|
|
19
|
-
export { NoReference, ParsedSchema,
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
|
14
|
+
export { NoReference, ParsedSchema, SecurityEntry };
|
|
@@ -51,20 +51,13 @@ function parseSecurities(method, dereferenced) {
|
|
|
51
51
|
if (security.length === 0) return result;
|
|
52
52
|
for (const map of security) {
|
|
53
53
|
const list = [];
|
|
54
|
-
for (const [key, scopes] of Object.entries(map)) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...scheme,
|
|
59
|
-
scopes,
|
|
60
|
-
id: key
|
|
61
|
-
});
|
|
62
|
-
}
|
|
54
|
+
for (const [key, scopes] of Object.entries(map)) list.push({
|
|
55
|
+
id: key,
|
|
56
|
+
scopes
|
|
57
|
+
});
|
|
63
58
|
if (list.length > 0) result.push(list);
|
|
64
59
|
}
|
|
65
60
|
return result;
|
|
66
61
|
}
|
|
67
62
|
//#endregion
|
|
68
63
|
export { createMethod, getPreferredType, getTagDisplayName, methodKeys, parseSecurities, pickExample };
|
|
69
|
-
|
|
70
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { deepEqual } from "
|
|
2
|
-
//#region src/utils/merge
|
|
1
|
+
import { deepEqual } from "../deep-equal.js";
|
|
2
|
+
//#region src/utils/schema/merge.ts
|
|
3
3
|
/**
|
|
4
4
|
* Merge `allOf` object schema
|
|
5
5
|
*/
|
|
@@ -154,5 +154,3 @@ function intersectArray(a, b) {
|
|
|
154
154
|
}
|
|
155
155
|
//#endregion
|
|
156
156
|
export { mergeAllOf };
|
|
157
|
-
|
|
158
|
-
//# sourceMappingURL=merge-schema.js.map
|
package/dist/utils/schema/ref.js
CHANGED
|
@@ -23,15 +23,14 @@ function schemaToString(value, _resolver, flags = FormatFlags.None) {
|
|
|
23
23
|
const result = Array.from(members).join(sep);
|
|
24
24
|
return nullable ? `${result} | null` : result;
|
|
25
25
|
}
|
|
26
|
-
function run(
|
|
27
|
-
const
|
|
28
|
-
schema = resolved.dereferenced;
|
|
26
|
+
function run(input, flags) {
|
|
27
|
+
const { dereferenced: schema, raw } = resolver(input);
|
|
29
28
|
if (schema === true) return "any";
|
|
30
29
|
else if (schema === false) return "never";
|
|
31
30
|
if ((flags & FormatFlags.UseAlias) === FormatFlags.UseAlias) {
|
|
32
31
|
if (schema.title) return schema.title;
|
|
33
|
-
if (typeof
|
|
34
|
-
const ref =
|
|
32
|
+
if (typeof raw === "object" && raw.$ref) {
|
|
33
|
+
const ref = raw.$ref.split("/");
|
|
35
34
|
if (ref.length > 0) return ref[ref.length - 1];
|
|
36
35
|
}
|
|
37
36
|
}
|
|
@@ -54,5 +53,3 @@ function schemaToString(value, _resolver, flags = FormatFlags.None) {
|
|
|
54
53
|
}
|
|
55
54
|
//#endregion
|
|
56
55
|
export { FormatFlags, schemaToString };
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=to-string.js.map
|