fumadocs-openapi 10.2.1 → 10.2.3
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/dist/generate-file.d.ts +53 -49
- package/dist/generate-file.d.ts.map +1 -1
- package/dist/generate-file.js +88 -102
- package/dist/generate-file.js.map +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3 -1
- package/dist/playground/client.d.ts +88 -72
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +446 -296
- package/dist/playground/client.js.map +1 -0
- package/dist/playground/components/inputs.js +395 -172
- package/dist/playground/components/inputs.js.map +1 -0
- package/dist/playground/components/oauth-dialog.js +270 -174
- package/dist/playground/components/oauth-dialog.js.map +1 -0
- package/dist/playground/components/server-select.js +115 -55
- package/dist/playground/components/server-select.js.map +1 -0
- package/dist/playground/fetcher.d.ts +10 -18
- package/dist/playground/fetcher.d.ts.map +1 -1
- package/dist/playground/fetcher.js +67 -75
- package/dist/playground/fetcher.js.map +1 -0
- package/dist/playground/get-default-values.js +23 -26
- package/dist/playground/get-default-values.js.map +1 -0
- package/dist/playground/index.d.ts +23 -13
- package/dist/playground/index.d.ts.map +1 -1
- package/dist/playground/index.js +87 -91
- package/dist/playground/index.js.map +1 -0
- package/dist/playground/lazy.js +9 -2
- package/dist/playground/lazy.js.map +1 -0
- package/dist/playground/schema.d.ts +18 -55
- package/dist/playground/schema.d.ts.map +1 -1
- package/dist/playground/schema.js +117 -106
- package/dist/playground/schema.js.map +1 -0
- package/dist/playground/status-info.js +49 -37
- package/dist/playground/status-info.js.map +1 -0
- package/dist/requests/generators/csharp.js +40 -50
- package/dist/requests/generators/csharp.js.map +1 -0
- package/dist/requests/generators/curl.js +28 -27
- package/dist/requests/generators/curl.js.map +1 -0
- package/dist/requests/generators/go.js +39 -35
- package/dist/requests/generators/go.js.map +1 -0
- package/dist/requests/generators/index.js +49 -43
- package/dist/requests/generators/index.js.map +1 -0
- package/dist/requests/generators/java.js +56 -67
- package/dist/requests/generators/java.js.map +1 -0
- package/dist/requests/generators/javascript.js +38 -45
- package/dist/requests/generators/javascript.js.map +1 -0
- package/dist/requests/generators/python.js +33 -37
- package/dist/requests/generators/python.js.map +1 -0
- package/dist/requests/media/adapter.d.ts +38 -84
- package/dist/requests/media/adapter.d.ts.map +1 -1
- package/dist/requests/media/adapter.js +122 -169
- package/dist/requests/media/adapter.js.map +1 -0
- package/dist/requests/media/encode.d.ts +12 -7
- package/dist/requests/media/encode.d.ts.map +1 -1
- package/dist/requests/media/encode.js +129 -109
- package/dist/requests/media/encode.js.map +1 -0
- package/dist/requests/media/resolve-adapter.js +28 -28
- package/dist/requests/media/resolve-adapter.js.map +1 -0
- package/dist/requests/string-utils.js +28 -35
- package/dist/requests/string-utils.js.map +1 -0
- package/dist/requests/to-python-object.js +16 -28
- package/dist/requests/to-python-object.js.map +1 -0
- package/dist/requests/types.d.ts +25 -21
- package/dist/requests/types.d.ts.map +1 -1
- package/dist/scalar/client.js +57 -20
- package/dist/scalar/client.js.map +1 -0
- package/dist/scalar/index.d.ts +8 -2
- package/dist/scalar/index.d.ts.map +1 -1
- package/dist/scalar/index.js +29 -19
- package/dist/scalar/index.js.map +1 -0
- package/dist/server/create.d.ts +29 -25
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/create.js +42 -39
- package/dist/server/create.js.map +1 -0
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +4 -2
- package/dist/server/proxy.d.ts +28 -28
- package/dist/server/proxy.d.ts.map +1 -1
- package/dist/server/proxy.js +58 -75
- package/dist/server/proxy.js.map +1 -0
- package/dist/server/source-api.d.ts +32 -25
- package/dist/server/source-api.d.ts.map +1 -1
- package/dist/server/source-api.js +82 -69
- package/dist/server/source-api.js.map +1 -0
- package/dist/types.d.ts +41 -36
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/api-page.d.ts +140 -136
- package/dist/ui/api-page.d.ts.map +1 -1
- package/dist/ui/api-page.js +134 -118
- package/dist/ui/api-page.js.map +1 -0
- package/dist/ui/client/index.d.ts +30 -26
- package/dist/ui/client/index.d.ts.map +1 -1
- package/dist/ui/client/index.js +8 -2
- package/dist/ui/client/index.js.map +1 -0
- package/dist/ui/client/storage-key.js +16 -10
- package/dist/ui/client/storage-key.js.map +1 -0
- package/dist/ui/components/accordion.js +40 -14
- package/dist/ui/components/accordion.js.map +1 -0
- package/dist/ui/components/dialog.js +51 -15
- package/dist/ui/components/dialog.js.map +1 -0
- package/dist/ui/components/input.js +18 -8
- package/dist/ui/components/input.js.map +1 -0
- package/dist/ui/components/method-label.js +38 -33
- package/dist/ui/components/method-label.js.map +1 -0
- package/dist/ui/components/select.js +66 -15
- package/dist/ui/components/select.js.map +1 -0
- package/dist/ui/contexts/api.js +96 -85
- package/dist/ui/contexts/api.js.map +1 -0
- package/dist/ui/contexts/api.lazy.js +9 -2
- package/dist/ui/contexts/api.lazy.js.map +1 -0
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +3 -1
- package/dist/ui/operation/client.js +65 -27
- package/dist/ui/operation/client.js.map +1 -0
- package/dist/ui/operation/index.js +403 -186
- package/dist/ui/operation/index.js.map +1 -0
- package/dist/ui/operation/request-tabs.d.ts +15 -16
- package/dist/ui/operation/request-tabs.d.ts.map +1 -1
- package/dist/ui/operation/request-tabs.js +151 -131
- package/dist/ui/operation/request-tabs.js.map +1 -0
- package/dist/ui/operation/response-tabs.d.ts +27 -28
- package/dist/ui/operation/response-tabs.d.ts.map +1 -1
- package/dist/ui/operation/response-tabs.js +73 -56
- package/dist/ui/operation/response-tabs.js.map +1 -0
- package/dist/ui/operation/usage-tabs/client.js +117 -88
- package/dist/ui/operation/usage-tabs/client.js.map +1 -0
- package/dist/ui/operation/usage-tabs/index.d.ts +22 -21
- package/dist/ui/operation/usage-tabs/index.d.ts.map +1 -1
- package/dist/ui/operation/usage-tabs/index.js +63 -48
- package/dist/ui/operation/usage-tabs/index.js.map +1 -0
- package/dist/ui/operation/usage-tabs/lazy.js +11 -4
- package/dist/ui/operation/usage-tabs/lazy.js.map +1 -0
- package/dist/ui/schema/client.d.ts +11 -7
- package/dist/ui/schema/client.d.ts.map +1 -1
- package/dist/ui/schema/client.js +213 -127
- package/dist/ui/schema/client.js.map +1 -0
- package/dist/ui/schema/index.d.ts +51 -50
- package/dist/ui/schema/index.d.ts.map +1 -1
- package/dist/ui/schema/index.js +225 -248
- package/dist/ui/schema/index.js.map +1 -0
- package/dist/ui/schema/lazy.js +9 -2
- package/dist/ui/schema/lazy.js.map +1 -0
- package/dist/utils/cn.js +3 -1
- package/dist/utils/deep-equal.js +18 -26
- package/dist/utils/deep-equal.js.map +1 -0
- package/dist/utils/get-typescript-schema.js +21 -19
- package/dist/utils/get-typescript-schema.js.map +1 -0
- package/dist/utils/id-to-title.js +13 -16
- package/dist/utils/id-to-title.js.map +1 -0
- package/dist/utils/lazy.js +13 -11
- package/dist/utils/lazy.js.map +1 -0
- package/dist/utils/merge-schema.js +130 -174
- package/dist/utils/merge-schema.js.map +1 -0
- package/dist/utils/pages/builder.d.ts +80 -76
- package/dist/utils/pages/builder.d.ts.map +1 -1
- package/dist/utils/pages/builder.js +101 -118
- package/dist/utils/pages/builder.js.map +1 -0
- package/dist/utils/pages/preset-auto.d.ts +58 -55
- package/dist/utils/pages/preset-auto.d.ts.map +1 -1
- package/dist/utils/pages/preset-auto.js +124 -137
- package/dist/utils/pages/preset-auto.js.map +1 -0
- package/dist/utils/pages/to-body.js +21 -18
- package/dist/utils/pages/to-body.js.map +1 -0
- package/dist/utils/pages/to-static-data.js +48 -40
- package/dist/utils/pages/to-static-data.js.map +1 -0
- package/dist/utils/pages/to-text.d.ts +43 -41
- package/dist/utils/pages/to-text.d.ts.map +1 -1
- package/dist/utils/pages/to-text.js +93 -126
- package/dist/utils/pages/to-text.js.map +1 -0
- package/dist/utils/process-document.d.ts +18 -19
- package/dist/utils/process-document.d.ts.map +1 -1
- package/dist/utils/process-document.js +43 -54
- package/dist/utils/process-document.js.map +1 -0
- package/dist/utils/remove-undefined.js +18 -18
- package/dist/utils/remove-undefined.js.map +1 -0
- package/dist/utils/schema-to-string.js +46 -64
- package/dist/utils/schema-to-string.js.map +1 -0
- package/dist/utils/schema.d.ts +11 -27
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +43 -44
- package/dist/utils/schema.js.map +1 -0
- package/dist/utils/url.js +35 -56
- package/dist/utils/url.js.map +1 -0
- package/dist/utils/use-query.js +39 -33
- package/dist/utils/use-query.js.map +1 -0
- package/package.json +35 -34
- package/dist/index.d.ts.map +0 -1
- package/dist/playground/components/inputs.d.ts +0 -25
- package/dist/playground/components/inputs.d.ts.map +0 -1
- package/dist/playground/components/oauth-dialog.d.ts +0 -13
- package/dist/playground/components/oauth-dialog.d.ts.map +0 -1
- package/dist/playground/components/server-select.d.ts +0 -3
- package/dist/playground/components/server-select.d.ts.map +0 -1
- package/dist/playground/get-default-values.d.ts +0 -3
- package/dist/playground/get-default-values.d.ts.map +0 -1
- package/dist/playground/lazy.d.ts +0 -2
- package/dist/playground/lazy.d.ts.map +0 -1
- package/dist/playground/status-info.d.ts +0 -8
- package/dist/playground/status-info.d.ts.map +0 -1
- package/dist/requests/generators/csharp.d.ts +0 -3
- package/dist/requests/generators/csharp.d.ts.map +0 -1
- package/dist/requests/generators/curl.d.ts +0 -3
- package/dist/requests/generators/curl.d.ts.map +0 -1
- package/dist/requests/generators/go.d.ts +0 -3
- package/dist/requests/generators/go.d.ts.map +0 -1
- package/dist/requests/generators/index.d.ts +0 -3
- package/dist/requests/generators/index.d.ts.map +0 -1
- package/dist/requests/generators/java.d.ts +0 -3
- package/dist/requests/generators/java.d.ts.map +0 -1
- package/dist/requests/generators/javascript.d.ts +0 -3
- package/dist/requests/generators/javascript.d.ts.map +0 -1
- package/dist/requests/generators/python.d.ts +0 -3
- package/dist/requests/generators/python.d.ts.map +0 -1
- package/dist/requests/media/resolve-adapter.d.ts +0 -19
- package/dist/requests/media/resolve-adapter.d.ts.map +0 -1
- package/dist/requests/string-utils.d.ts +0 -7
- package/dist/requests/string-utils.d.ts.map +0 -1
- package/dist/requests/to-python-object.d.ts +0 -2
- package/dist/requests/to-python-object.d.ts.map +0 -1
- package/dist/requests/types.js +0 -1
- package/dist/scalar/client.d.ts +0 -7
- package/dist/scalar/client.d.ts.map +0 -1
- package/dist/server/index.d.ts.map +0 -1
- package/dist/types.js +0 -1
- package/dist/ui/client/storage-key.d.ts +0 -9
- package/dist/ui/client/storage-key.d.ts.map +0 -1
- package/dist/ui/components/accordion.d.ts +0 -8
- package/dist/ui/components/accordion.d.ts.map +0 -1
- package/dist/ui/components/dialog.d.ts +0 -20
- package/dist/ui/components/dialog.d.ts.map +0 -1
- package/dist/ui/components/input.d.ts +0 -6
- package/dist/ui/components/input.d.ts.map +0 -1
- package/dist/ui/components/method-label.d.ts +0 -10
- package/dist/ui/components/method-label.d.ts.map +0 -1
- package/dist/ui/components/select.d.ts +0 -14
- package/dist/ui/components/select.d.ts.map +0 -1
- package/dist/ui/contexts/api.d.ts +0 -33
- package/dist/ui/contexts/api.d.ts.map +0 -1
- package/dist/ui/contexts/api.lazy.d.ts +0 -2
- package/dist/ui/contexts/api.lazy.d.ts.map +0 -1
- package/dist/ui/icons.d.ts +0 -49
- package/dist/ui/icons.d.ts.map +0 -1
- package/dist/ui/icons.js +0 -281
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/operation/client.d.ts +0 -19
- package/dist/ui/operation/client.d.ts.map +0 -1
- package/dist/ui/operation/index.d.ts +0 -12
- package/dist/ui/operation/index.d.ts.map +0 -1
- package/dist/ui/operation/usage-tabs/client.d.ts +0 -23
- package/dist/ui/operation/usage-tabs/client.d.ts.map +0 -1
- package/dist/ui/operation/usage-tabs/lazy.d.ts +0 -4
- package/dist/ui/operation/usage-tabs/lazy.d.ts.map +0 -1
- package/dist/ui/schema/lazy.d.ts +0 -2
- package/dist/ui/schema/lazy.d.ts.map +0 -1
- package/dist/utils/cn.d.ts +0 -2
- package/dist/utils/cn.d.ts.map +0 -1
- package/dist/utils/deep-equal.d.ts +0 -2
- package/dist/utils/deep-equal.d.ts.map +0 -1
- package/dist/utils/get-typescript-schema.d.ts +0 -4
- package/dist/utils/get-typescript-schema.d.ts.map +0 -1
- package/dist/utils/id-to-title.d.ts +0 -2
- package/dist/utils/id-to-title.d.ts.map +0 -1
- package/dist/utils/lazy.d.ts +0 -5
- package/dist/utils/lazy.d.ts.map +0 -1
- package/dist/utils/merge-schema.d.ts +0 -7
- package/dist/utils/merge-schema.d.ts.map +0 -1
- package/dist/utils/pages/to-body.d.ts +0 -4
- package/dist/utils/pages/to-body.d.ts.map +0 -1
- package/dist/utils/pages/to-static-data.d.ts +0 -10
- package/dist/utils/pages/to-static-data.d.ts.map +0 -1
- package/dist/utils/remove-undefined.d.ts +0 -2
- package/dist/utils/remove-undefined.d.ts.map +0 -1
- package/dist/utils/schema-to-string.d.ts +0 -8
- package/dist/utils/schema-to-string.d.ts.map +0 -1
- package/dist/utils/url.d.ts +0 -11
- package/dist/utils/url.d.ts.map +0 -1
- package/dist/utils/use-query.d.ts +0 -8
- package/dist/utils/use-query.d.ts.map +0 -1
|
@@ -1,194 +1,411 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { AccordionContent, AccordionHeader, AccordionItem,
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
1
|
+
import { idToTitle } from "../../utils/id-to-title.js";
|
|
2
|
+
import { createMethod, methodKeys } from "../../utils/schema.js";
|
|
3
|
+
import { isMediaTypeSupported } from "../../requests/media/resolve-adapter.js";
|
|
4
|
+
import "../../requests/media/adapter.js";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
import { MethodLabel } from "../components/method-label.js";
|
|
7
|
+
import { APIPlayground } from "../../playground/index.js";
|
|
8
|
+
import { Schema } from "../schema/index.js";
|
|
9
|
+
import { UsageTabsProviderLazy } from "./usage-tabs/lazy.js";
|
|
10
|
+
import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "../components/accordion.js";
|
|
11
|
+
import { UsageTabs } from "./usage-tabs/index.js";
|
|
12
|
+
import { getTypescriptSchema } from "../../utils/get-typescript-schema.js";
|
|
13
|
+
import { CopyResponseTypeScript, SelectTab, SelectTabTrigger, SelectTabs } from "./client.js";
|
|
14
|
+
import { RequestTabs, getExampleRequests } from "./request-tabs.js";
|
|
15
|
+
import { Fragment } from "react";
|
|
16
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
|
|
18
|
+
//#region src/ui/operation/index.tsx
|
|
16
19
|
const ParamTypes = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
path: "Path Parameters",
|
|
21
|
+
query: "Query Parameters",
|
|
22
|
+
header: "Header Parameters",
|
|
23
|
+
cookie: "Cookie Parameters"
|
|
21
24
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
25
|
+
async function Operation({ type = "operation", path, method, ctx, showTitle, showDescription, headingLevel = 2 }) {
|
|
26
|
+
const { schema: { dereferenced } } = ctx;
|
|
27
|
+
const body = method.requestBody;
|
|
28
|
+
let headNode = null;
|
|
29
|
+
const descriptionNode = showDescription && method.description && ctx.renderMarkdown(method.description);
|
|
30
|
+
let bodyNode = null;
|
|
31
|
+
let authNode = null;
|
|
32
|
+
let responseNode = null;
|
|
33
|
+
let callbacksNode = null;
|
|
34
|
+
if (showTitle) {
|
|
35
|
+
const title = method.summary || (method.operationId ? idToTitle(method.operationId) : path);
|
|
36
|
+
headNode = ctx.renderHeading(headingLevel, title);
|
|
37
|
+
headingLevel++;
|
|
38
|
+
}
|
|
39
|
+
const contentTypes = body ? Object.entries(body.content) : null;
|
|
40
|
+
if (body && contentTypes && contentTypes.length > 0) {
|
|
41
|
+
const items = contentTypes.map(([key]) => ({
|
|
42
|
+
label: /* @__PURE__ */ jsx("code", {
|
|
43
|
+
className: "text-xs",
|
|
44
|
+
children: key
|
|
45
|
+
}),
|
|
46
|
+
value: key
|
|
47
|
+
}));
|
|
48
|
+
bodyNode = /* @__PURE__ */ jsxs(SelectTabs, {
|
|
49
|
+
defaultValue: items[0].value,
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsxs("div", {
|
|
52
|
+
className: "flex gap-2 items-center justify-between mt-10",
|
|
53
|
+
children: [ctx.renderHeading(headingLevel, "Request Body", { className: "my-0!" }), contentTypes.length > 1 ? /* @__PURE__ */ jsx(SelectTabTrigger, {
|
|
54
|
+
items,
|
|
55
|
+
className: "font-medium"
|
|
56
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
57
|
+
className: "text-fd-muted-foreground not-prose",
|
|
58
|
+
children: items[0].label
|
|
59
|
+
})]
|
|
60
|
+
}),
|
|
61
|
+
body.description && ctx.renderMarkdown(body.description),
|
|
62
|
+
contentTypes.map(([type$1, content]) => {
|
|
63
|
+
if (!isMediaTypeSupported(type$1, ctx.mediaAdapters)) throw new Error(`Media type ${type$1} is not supported (in ${path})`);
|
|
64
|
+
return /* @__PURE__ */ jsx(SelectTab, {
|
|
65
|
+
value: type$1,
|
|
66
|
+
children: /* @__PURE__ */ jsx(Schema, {
|
|
67
|
+
client: {
|
|
68
|
+
name: "body",
|
|
69
|
+
as: "body",
|
|
70
|
+
required: body.required
|
|
71
|
+
},
|
|
72
|
+
root: content.schema ?? {},
|
|
73
|
+
readOnly: method.method === "GET",
|
|
74
|
+
writeOnly: method.method !== "GET",
|
|
75
|
+
ctx
|
|
76
|
+
})
|
|
77
|
+
}, type$1);
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (method.responses && ctx.showResponseSchema !== false) {
|
|
83
|
+
const statuses = Object.keys(method.responses);
|
|
84
|
+
responseNode = /* @__PURE__ */ jsxs(Fragment$1, { children: [ctx.renderHeading(headingLevel, "Response Body"), /* @__PURE__ */ jsx(Accordions, {
|
|
85
|
+
type: "multiple",
|
|
86
|
+
children: statuses.map((status) => /* @__PURE__ */ jsx(ResponseAccordion, {
|
|
87
|
+
status,
|
|
88
|
+
operation: method,
|
|
89
|
+
ctx
|
|
90
|
+
}, status))
|
|
91
|
+
})] });
|
|
92
|
+
}
|
|
93
|
+
const parameterNode = Object.entries(ParamTypes).map(([type$1, title]) => {
|
|
94
|
+
const params = method.parameters?.filter((param) => param.in === type$1);
|
|
95
|
+
if (!params || params.length === 0) return;
|
|
96
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [ctx.renderHeading(headingLevel, title), /* @__PURE__ */ jsx("div", {
|
|
97
|
+
className: "flex flex-col",
|
|
98
|
+
children: params.map((param) => /* @__PURE__ */ jsx(Schema, {
|
|
99
|
+
client: {
|
|
100
|
+
name: param.name,
|
|
101
|
+
required: param.required
|
|
102
|
+
},
|
|
103
|
+
root: {
|
|
104
|
+
...param.schema,
|
|
105
|
+
description: param.description ?? param.schema?.description,
|
|
106
|
+
deprecated: (param.deprecated ?? false) || (param.schema?.deprecated ?? false)
|
|
107
|
+
},
|
|
108
|
+
readOnly: method.method === "GET",
|
|
109
|
+
writeOnly: method.method !== "GET",
|
|
110
|
+
ctx
|
|
111
|
+
}, param.name))
|
|
112
|
+
})] }, type$1);
|
|
113
|
+
});
|
|
114
|
+
const securities = (method.security ?? dereferenced.security ?? []).filter((v) => Object.keys(v).length > 0);
|
|
115
|
+
if (type === "operation" && securities.length > 0) {
|
|
116
|
+
const securitySchemes = dereferenced.components?.securitySchemes;
|
|
117
|
+
const items = securities.map((security, i) => {
|
|
118
|
+
return {
|
|
119
|
+
value: String(i),
|
|
120
|
+
label: /* @__PURE__ */ jsx("div", {
|
|
121
|
+
className: "flex flex-col text-xs min-w-0",
|
|
122
|
+
children: Object.entries(security).map(([key, scopes]) => /* @__PURE__ */ jsxs("code", {
|
|
123
|
+
className: "truncate",
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ jsx("span", {
|
|
126
|
+
className: "font-medium",
|
|
127
|
+
children: key
|
|
128
|
+
}),
|
|
129
|
+
" ",
|
|
130
|
+
scopes.length > 0 && /* @__PURE__ */ jsx("span", {
|
|
131
|
+
className: "text-fd-muted-foreground",
|
|
132
|
+
children: scopes.join(", ")
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
}, key))
|
|
136
|
+
})
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
authNode = /* @__PURE__ */ jsxs(SelectTabs, {
|
|
140
|
+
defaultValue: items[0].value,
|
|
141
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
142
|
+
className: "flex items-start justify-between gap-2 mt-10",
|
|
143
|
+
children: [ctx.renderHeading(headingLevel, "Authorization", { className: "my-0!" }), items.length > 1 ? /* @__PURE__ */ jsx(SelectTabTrigger, { items }) : /* @__PURE__ */ jsx("div", {
|
|
144
|
+
className: "not-prose",
|
|
145
|
+
children: items[0].label
|
|
146
|
+
})]
|
|
147
|
+
}), securities.map((security, i) => /* @__PURE__ */ jsx(SelectTab, {
|
|
148
|
+
value: items[i].value,
|
|
149
|
+
children: Object.entries(security).map(([key, scopes]) => {
|
|
150
|
+
const scheme = securitySchemes?.[key];
|
|
151
|
+
if (!scheme) return;
|
|
152
|
+
return /* @__PURE__ */ jsx(AuthScheme, {
|
|
153
|
+
scheme,
|
|
154
|
+
scopes,
|
|
155
|
+
ctx
|
|
156
|
+
}, key);
|
|
157
|
+
})
|
|
158
|
+
}, i))]
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const callbacks = method.callbacks ? Object.entries(method.callbacks) : null;
|
|
162
|
+
if (callbacks && callbacks.length > 0) {
|
|
163
|
+
const items = callbacks.map(([key]) => ({
|
|
164
|
+
label: /* @__PURE__ */ jsx("code", {
|
|
165
|
+
className: "text-xs",
|
|
166
|
+
children: key
|
|
167
|
+
}),
|
|
168
|
+
value: key
|
|
169
|
+
}));
|
|
170
|
+
callbacksNode = /* @__PURE__ */ jsxs(SelectTabs, {
|
|
171
|
+
defaultValue: items[0].value,
|
|
172
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
173
|
+
className: "flex justify-between gap-2 items-end mt-10",
|
|
174
|
+
children: [ctx.renderHeading(headingLevel, "Callbacks", { className: "my-0!" }), callbacks.length > 1 ? /* @__PURE__ */ jsx(SelectTabTrigger, {
|
|
175
|
+
items,
|
|
176
|
+
className: "font-medium"
|
|
177
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
178
|
+
className: "text-fd-muted-foreground not-prose",
|
|
179
|
+
children: items[0].label
|
|
180
|
+
})]
|
|
181
|
+
}), callbacks.map(([name, callback]) => /* @__PURE__ */ jsx(SelectTab, {
|
|
182
|
+
value: name,
|
|
183
|
+
children: /* @__PURE__ */ jsx(WebhookCallback, {
|
|
184
|
+
callback,
|
|
185
|
+
ctx,
|
|
186
|
+
headingLevel
|
|
187
|
+
})
|
|
188
|
+
}, name))]
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
let { renderOperationLayout, renderWebhookLayout } = ctx.content ?? {};
|
|
192
|
+
if (type === "operation") {
|
|
193
|
+
renderOperationLayout ??= (slots) => {
|
|
194
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
195
|
+
className: "flex flex-col gap-x-6 gap-y-4 @4xl:flex-row @4xl:items-start",
|
|
196
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
197
|
+
className: "min-w-0 flex-1",
|
|
198
|
+
children: [
|
|
199
|
+
slots.header,
|
|
200
|
+
slots.apiPlayground,
|
|
201
|
+
slots.description,
|
|
202
|
+
slots.authSchemes,
|
|
203
|
+
slots.paremeters,
|
|
204
|
+
slots.body,
|
|
205
|
+
slots.responses,
|
|
206
|
+
slots.callbacks
|
|
207
|
+
]
|
|
208
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
209
|
+
className: "@4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px]",
|
|
210
|
+
children: slots.apiExample
|
|
211
|
+
})]
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
const playgroundEnabled = ctx.playground?.enabled ?? true;
|
|
215
|
+
const content = await renderOperationLayout({
|
|
216
|
+
header: headNode,
|
|
217
|
+
description: descriptionNode,
|
|
218
|
+
authSchemes: authNode,
|
|
219
|
+
body: bodyNode,
|
|
220
|
+
callbacks: callbacksNode,
|
|
221
|
+
paremeters: parameterNode,
|
|
222
|
+
responses: responseNode,
|
|
223
|
+
apiPlayground: playgroundEnabled ? /* @__PURE__ */ jsx(APIPlayground, {
|
|
224
|
+
path,
|
|
225
|
+
method,
|
|
226
|
+
ctx
|
|
227
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
228
|
+
className: "flex flex-row items-center gap-2.5 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose",
|
|
229
|
+
children: [/* @__PURE__ */ jsx(MethodLabel, {
|
|
230
|
+
className: "text-xs",
|
|
231
|
+
children: method.method
|
|
232
|
+
}), /* @__PURE__ */ jsx("code", {
|
|
233
|
+
className: "flex-1 overflow-auto text-nowrap text-[0.8125rem] text-fd-muted-foreground",
|
|
234
|
+
children: path
|
|
235
|
+
})]
|
|
236
|
+
}),
|
|
237
|
+
apiExample: /* @__PURE__ */ jsx(UsageTabs, {
|
|
238
|
+
method,
|
|
239
|
+
ctx
|
|
240
|
+
})
|
|
241
|
+
}, ctx, method);
|
|
242
|
+
return /* @__PURE__ */ jsx(UsageTabsProviderLazy, {
|
|
243
|
+
defaultExampleId: method["x-exclusiveCodeSample"] ?? method["x-selectedCodeSample"],
|
|
244
|
+
route: path,
|
|
245
|
+
examples: getExampleRequests(path, method, ctx),
|
|
246
|
+
children: content
|
|
247
|
+
});
|
|
248
|
+
} else {
|
|
249
|
+
renderWebhookLayout ??= (slots) => /* @__PURE__ */ jsxs("div", {
|
|
250
|
+
className: "flex flex-col-reverse gap-x-6 gap-y-4 @4xl:flex-row @4xl:items-start",
|
|
251
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
252
|
+
className: "min-w-0 flex-1",
|
|
253
|
+
children: [
|
|
254
|
+
slots.header,
|
|
255
|
+
slots.description,
|
|
256
|
+
slots.authSchemes,
|
|
257
|
+
slots.paremeters,
|
|
258
|
+
slots.body,
|
|
259
|
+
slots.responses,
|
|
260
|
+
slots.callbacks
|
|
261
|
+
]
|
|
262
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
263
|
+
className: "@4xl:sticky @4xl:top-[calc(var(--fd-docs-row-1,2rem)+1rem)] @4xl:w-[400px]",
|
|
264
|
+
children: slots.requests
|
|
265
|
+
})]
|
|
266
|
+
});
|
|
267
|
+
return renderWebhookLayout({
|
|
268
|
+
header: headNode,
|
|
269
|
+
description: descriptionNode,
|
|
270
|
+
authSchemes: authNode,
|
|
271
|
+
body: bodyNode,
|
|
272
|
+
callbacks: callbacksNode,
|
|
273
|
+
paremeters: parameterNode,
|
|
274
|
+
responses: responseNode,
|
|
275
|
+
requests: /* @__PURE__ */ jsx(RequestTabs, {
|
|
276
|
+
path,
|
|
277
|
+
operation: method,
|
|
278
|
+
ctx
|
|
279
|
+
})
|
|
280
|
+
});
|
|
281
|
+
}
|
|
136
282
|
}
|
|
137
|
-
async function ResponseAccordion({ status, operation, ctx
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
283
|
+
async function ResponseAccordion({ status, operation, ctx }) {
|
|
284
|
+
const response = operation.responses[status];
|
|
285
|
+
const { generateTypeScriptSchema } = ctx;
|
|
286
|
+
const contentTypes = response.content ? Object.entries(response.content) : [];
|
|
287
|
+
let wrapper = (children) => children;
|
|
288
|
+
let selectorNode = null;
|
|
289
|
+
if (contentTypes.length > 0) {
|
|
290
|
+
const items = contentTypes.map(([key]) => ({
|
|
291
|
+
label: /* @__PURE__ */ jsx("code", {
|
|
292
|
+
className: "text-xs",
|
|
293
|
+
children: key
|
|
294
|
+
}),
|
|
295
|
+
value: key
|
|
296
|
+
}));
|
|
297
|
+
selectorNode = items.length === 1 ? /* @__PURE__ */ jsx("p", {
|
|
298
|
+
className: "text-fd-muted-foreground not-prose",
|
|
299
|
+
children: items[0].label
|
|
300
|
+
}) : /* @__PURE__ */ jsx(SelectTabTrigger, { items });
|
|
301
|
+
wrapper = (children) => /* @__PURE__ */ jsx(SelectTabs, {
|
|
302
|
+
defaultValue: items[0].value,
|
|
303
|
+
children
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
return wrapper(/* @__PURE__ */ jsxs(AccordionItem, {
|
|
307
|
+
value: status,
|
|
308
|
+
children: [/* @__PURE__ */ jsxs(AccordionHeader, { children: [/* @__PURE__ */ jsx(AccordionTrigger, {
|
|
309
|
+
className: "font-mono",
|
|
310
|
+
children: status
|
|
311
|
+
}), selectorNode] }), /* @__PURE__ */ jsxs(AccordionContent, {
|
|
312
|
+
className: "ps-4.5",
|
|
313
|
+
children: [response.description && /* @__PURE__ */ jsx("div", {
|
|
314
|
+
className: "prose-no-margin mb-2",
|
|
315
|
+
children: ctx.renderMarkdown(response.description)
|
|
316
|
+
}), contentTypes.map(async ([type, resType]) => {
|
|
317
|
+
const schema = resType.schema;
|
|
318
|
+
let ts;
|
|
319
|
+
if (generateTypeScriptSchema) ts = await generateTypeScriptSchema(operation, status);
|
|
320
|
+
else if (generateTypeScriptSchema === void 0 && schema) ts = await getTypescriptSchema(schema, ctx);
|
|
321
|
+
return /* @__PURE__ */ jsxs(SelectTab, {
|
|
322
|
+
value: type,
|
|
323
|
+
className: "mb-2",
|
|
324
|
+
children: [ts && /* @__PURE__ */ jsx(CopyResponseTypeScript, { code: ts }), schema && /* @__PURE__ */ jsx("div", {
|
|
325
|
+
className: "border px-3 py-2 rounded-lg",
|
|
326
|
+
children: /* @__PURE__ */ jsx(Schema, {
|
|
327
|
+
client: {
|
|
328
|
+
name: "response",
|
|
329
|
+
as: "body"
|
|
330
|
+
},
|
|
331
|
+
root: schema,
|
|
332
|
+
readOnly: true,
|
|
333
|
+
ctx
|
|
334
|
+
})
|
|
335
|
+
})]
|
|
336
|
+
}, type);
|
|
337
|
+
})]
|
|
338
|
+
})]
|
|
339
|
+
}));
|
|
166
340
|
}
|
|
167
|
-
function WebhookCallback({ callback, ctx, headingLevel
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
341
|
+
function WebhookCallback({ callback, ctx, headingLevel }) {
|
|
342
|
+
return /* @__PURE__ */ jsx(Accordions, {
|
|
343
|
+
type: "single",
|
|
344
|
+
collapsible: true,
|
|
345
|
+
children: Object.entries(callback).map(([path, pathItem]) => {
|
|
346
|
+
const pathNodes = methodKeys.map((method) => {
|
|
347
|
+
const operation = pathItem[method];
|
|
348
|
+
if (!operation) return null;
|
|
349
|
+
return /* @__PURE__ */ jsx("div", {
|
|
350
|
+
className: "border p-3 my-2 @container prose-no-margin rounded-lg",
|
|
351
|
+
children: /* @__PURE__ */ jsx(Operation, {
|
|
352
|
+
type: "webhook",
|
|
353
|
+
path,
|
|
354
|
+
headingLevel: headingLevel + 1,
|
|
355
|
+
method: createMethod(method, pathItem, operation),
|
|
356
|
+
ctx
|
|
357
|
+
})
|
|
358
|
+
}, method);
|
|
359
|
+
});
|
|
360
|
+
return /* @__PURE__ */ jsxs(AccordionItem, {
|
|
361
|
+
value: path,
|
|
362
|
+
children: [/* @__PURE__ */ jsx(AccordionHeader, { children: /* @__PURE__ */ jsx(AccordionTrigger, {
|
|
363
|
+
className: "font-mono",
|
|
364
|
+
children: path
|
|
365
|
+
}) }), /* @__PURE__ */ jsx(AccordionContent, { children: pathNodes })]
|
|
366
|
+
}, path);
|
|
367
|
+
})
|
|
368
|
+
});
|
|
178
369
|
}
|
|
179
|
-
function AuthScheme({ scheme: schema, scopes, ctx
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
370
|
+
function AuthScheme({ scheme: schema, scopes, ctx }) {
|
|
371
|
+
if (schema.type === "http" || schema.type === "oauth2") return /* @__PURE__ */ jsxs(AuthProperty, {
|
|
372
|
+
name: "Authorization",
|
|
373
|
+
type: schema.type === "http" && schema.scheme === "basic" ? `Basic <token>` : "Bearer <token>",
|
|
374
|
+
scopes,
|
|
375
|
+
children: [schema.description && ctx.renderMarkdown(schema.description), /* @__PURE__ */ jsxs("p", { children: ["In: ", /* @__PURE__ */ jsx("code", { children: "header" })] })]
|
|
376
|
+
});
|
|
377
|
+
if (schema.type === "apiKey") return /* @__PURE__ */ jsxs(AuthProperty, {
|
|
378
|
+
name: schema.name,
|
|
379
|
+
type: "<token>",
|
|
380
|
+
scopes,
|
|
381
|
+
children: [schema.description && ctx.renderMarkdown(schema.description), /* @__PURE__ */ jsxs("p", { children: ["In: ", /* @__PURE__ */ jsx("code", { children: schema.in })] })]
|
|
382
|
+
});
|
|
383
|
+
if (schema.type === "openIdConnect") return /* @__PURE__ */ jsx(AuthProperty, {
|
|
384
|
+
name: "OpenID Connect",
|
|
385
|
+
type: "<token>",
|
|
386
|
+
scopes,
|
|
387
|
+
children: schema.description && ctx.renderMarkdown(schema.description)
|
|
388
|
+
});
|
|
191
389
|
}
|
|
192
390
|
function AuthProperty({ name, type, scopes = [], className, ...props }) {
|
|
193
|
-
|
|
391
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
392
|
+
className: cn("text-sm border-t my-4 first:border-t-0", className),
|
|
393
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
394
|
+
className: "flex flex-wrap items-center gap-3 not-prose",
|
|
395
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
396
|
+
className: "font-medium font-mono text-fd-primary",
|
|
397
|
+
children: name
|
|
398
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
399
|
+
className: "text-sm font-mono text-fd-muted-foreground",
|
|
400
|
+
children: type
|
|
401
|
+
})]
|
|
402
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
403
|
+
className: "prose-no-margin pt-2.5 empty:hidden",
|
|
404
|
+
children: [props.children, scopes.length > 0 && /* @__PURE__ */ jsxs("p", { children: ["Scope: ", /* @__PURE__ */ jsx("code", { children: scopes.join(", ") })] })]
|
|
405
|
+
})]
|
|
406
|
+
});
|
|
194
407
|
}
|
|
408
|
+
|
|
409
|
+
//#endregion
|
|
410
|
+
export { Operation };
|
|
411
|
+
//# sourceMappingURL=index.js.map
|