@lukoweb/apitogo 0.1.1 → 0.1.2
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/cli/cli.js +17 -6
- package/dist/declarations/lib/ui/Command.d.ts +1 -1
- package/dist/declarations/lib/util/MdxComponents.d.ts +1 -1
- package/package.json +1 -1
- package/src/app/main.tsx +150 -150
- package/src/config/loader.ts +245 -245
- package/src/index.ts +33 -33
- package/src/lib/authentication/components/CallbackHandler.tsx +45 -45
- package/src/lib/authentication/components/SignIn.tsx +46 -46
- package/src/lib/authentication/components/SignUp.tsx +48 -48
- package/src/lib/authentication/providers/clerk.tsx +224 -224
- package/src/lib/authentication/ui/AuthCard.tsx +7 -7
- package/src/lib/authentication/ui/EmailLinkCallbackUi.tsx +129 -125
- package/src/lib/authentication/ui/EmailLinkSentUi.tsx +105 -101
- package/src/lib/authentication/ui/EmailLinkSignInUi.tsx +100 -96
- package/src/lib/authentication/ui/EmailVerificationUi.tsx +128 -124
- package/src/lib/authentication/ui/ZudokuAuthUi.tsx +620 -616
- package/src/lib/components/AiAssistantMenuItems.tsx +102 -102
- package/src/lib/components/Autocomplete.tsx +123 -123
- package/src/lib/components/DeveloperHint.tsx +39 -35
- package/src/lib/components/Header.tsx +260 -260
- package/src/lib/components/Layout.tsx +53 -53
- package/src/lib/components/Main.tsx +51 -51
- package/src/lib/components/Mermaid.tsx +74 -70
- package/src/lib/components/MobileTopNavigation.tsx +276 -276
- package/src/lib/components/MultiSelect.tsx +86 -82
- package/src/lib/components/TopNavigation.tsx +103 -103
- package/src/lib/components/index.ts +26 -26
- package/src/lib/components/navigation/NavigationCategory.tsx +157 -157
- package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -35
- package/src/lib/components/navigation/NavigationItem.tsx +181 -177
- package/src/lib/core/RouteGuard.tsx +193 -193
- package/src/lib/errors/ErrorMessage.tsx +50 -46
- package/src/lib/plugins/api-catalog/Catalog.tsx +80 -80
- package/src/lib/plugins/api-keys/CreateApiKey.tsx +128 -124
- package/src/lib/plugins/api-keys/CreateApiKeyDialog.tsx +49 -49
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +72 -72
- package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -342
- package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +127 -127
- package/src/lib/plugins/markdown/MdxPage.tsx +285 -285
- package/src/lib/plugins/openapi/ApiHeader.tsx +96 -96
- package/src/lib/plugins/openapi/CollapsibleCode.tsx +88 -88
- package/src/lib/plugins/openapi/DownloadSchemaButton.tsx +94 -94
- package/src/lib/plugins/openapi/GeneratedExampleSidecarBox.tsx +52 -52
- package/src/lib/plugins/openapi/OperationListItem.tsx +183 -183
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +63 -63
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +120 -117
- package/src/lib/plugins/openapi/SchemaInfo.tsx +344 -344
- package/src/lib/plugins/openapi/SchemaList.tsx +113 -113
- package/src/lib/plugins/openapi/Sidecar.tsx +312 -309
- package/src/lib/plugins/openapi/SidecarExamples.tsx +177 -174
- package/src/lib/plugins/openapi/components/EnumValues.tsx +58 -58
- package/src/lib/plugins/openapi/components/ResponseContent.tsx +117 -114
- package/src/lib/plugins/openapi/playground/BodyPanel.tsx +274 -271
- package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +51 -51
- package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +60 -60
- package/src/lib/plugins/openapi/playground/Headers.tsx +188 -181
- package/src/lib/plugins/openapi/playground/IdentityDialog.tsx +75 -75
- package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +38 -38
- package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +45 -45
- package/src/lib/plugins/openapi/playground/Playground.tsx +602 -599
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +56 -56
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +151 -148
- package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +70 -70
- package/src/lib/plugins/openapi/playground/request-panel/MultipartField.tsx +91 -91
- package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -50
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +355 -355
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +106 -102
- package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +189 -184
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +299 -299
- package/src/lib/plugins/search-pagefind/IndexingDialog.tsx +162 -162
- package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +202 -202
- package/src/lib/plugins/search-pagefind/ResultList.tsx +122 -118
- package/src/lib/ui/ActionButton.tsx +21 -21
- package/src/lib/ui/Command.tsx +191 -191
- package/src/lib/util/MdxComponents.tsx +150 -150
- package/src/vite/config.ts +234 -231
- package/src/vite/dev-server.ts +291 -291
- package/src/vite/plugin-api-keys.ts +50 -50
- package/src/vite/plugin-api.ts +320 -318
- package/src/vite/plugin-auth.ts +38 -38
- package/src/vite/plugin-component.ts +45 -39
- package/src/vite/plugin-config.ts +75 -75
- package/src/vite/plugin-custom-pages.ts +36 -36
- package/src/vite/plugin-docs.ts +202 -202
- package/src/vite/plugin-markdown-export.ts +214 -214
- package/src/vite/plugin-mdx.ts +149 -149
- package/src/vite/plugin-navigation.ts +106 -106
- package/src/vite/plugin-search.ts +47 -47
- package/src/vite/plugin.ts +42 -42
- package/src/vite/prerender/prerender.ts +233 -233
|
@@ -1,309 +1,312 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{ value: "
|
|
41
|
-
{ value: "
|
|
42
|
-
{ value: "
|
|
43
|
-
{ value: "
|
|
44
|
-
{ value: "
|
|
45
|
-
{ value: "
|
|
46
|
-
{ value: "
|
|
47
|
-
{ value: "
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
contentTypeIndex:
|
|
97
|
-
exampleIndex:
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
selectedRequestExample.
|
|
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
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
{language.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
1
|
+
import { useZudoku } from "@lukoweb/apitogo/hooks";
|
|
2
|
+
import { Badge } from "@lukoweb/apitogo/ui/Badge.js";
|
|
3
|
+
import {
|
|
4
|
+
NativeSelect,
|
|
5
|
+
NativeSelectOption,
|
|
6
|
+
} from "@lukoweb/apitogo/ui/NativeSelect.js";
|
|
7
|
+
import { SyntaxHighlight } from "@lukoweb/apitogo/ui/SyntaxHighlight.js";
|
|
8
|
+
import { useMemo, useState, useTransition } from "react";
|
|
9
|
+
import { useSearchParams } from "react-router";
|
|
10
|
+
import { useAuthState } from "../../authentication/state.js";
|
|
11
|
+
import { PathRenderer } from "../../components/PathRenderer.js";
|
|
12
|
+
import { cn } from "../../util/cn.js";
|
|
13
|
+
import { useOnScreen } from "../../util/useOnScreen.js";
|
|
14
|
+
import { ColorizedParam } from "./ColorizedParam.js";
|
|
15
|
+
import { NonHighlightedCode } from "./components/NonHighlightedCode.js";
|
|
16
|
+
import { useOasConfig } from "./context.js";
|
|
17
|
+
import { GeneratedExampleSidecarBox } from "./GeneratedExampleSidecarBox.js";
|
|
18
|
+
import type { OperationsFragmentFragment } from "./graphql/graphql.js";
|
|
19
|
+
import { graphql } from "./graphql/index.js";
|
|
20
|
+
import { PlaygroundDialogWrapper } from "./PlaygroundDialogWrapper.js";
|
|
21
|
+
import { RequestBodySidecarBox } from "./RequestBodySidecarBox.js";
|
|
22
|
+
import { ResponsesSidecarBox } from "./ResponsesSidecarBox.js";
|
|
23
|
+
import * as SidecarBox from "./SidecarBox.js";
|
|
24
|
+
import { createHttpSnippet, getConverted } from "./util/createHttpSnippet.js";
|
|
25
|
+
import { generateSchemaExample } from "./util/generateSchemaExample.js";
|
|
26
|
+
import { methodForColor } from "./util/methodToColor.js";
|
|
27
|
+
|
|
28
|
+
export const GetServerQuery = graphql(/* GraphQL */ `
|
|
29
|
+
query getServerQuery($input: JSON!, $type: SchemaType!) {
|
|
30
|
+
schema(input: $input, type: $type) {
|
|
31
|
+
url
|
|
32
|
+
servers {
|
|
33
|
+
url
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`);
|
|
38
|
+
|
|
39
|
+
const EXAMPLE_LANGUAGES = [
|
|
40
|
+
{ value: "shell", label: "cURL" },
|
|
41
|
+
{ value: "js", label: "JavaScript" },
|
|
42
|
+
{ value: "python", label: "Python" },
|
|
43
|
+
{ value: "java", label: "Java" },
|
|
44
|
+
{ value: "go", label: "Go" },
|
|
45
|
+
{ value: "csharp", label: "C#" },
|
|
46
|
+
{ value: "kotlin", label: "Kotlin" },
|
|
47
|
+
{ value: "objc", label: "Objective-C" },
|
|
48
|
+
{ value: "php", label: "PHP" },
|
|
49
|
+
{ value: "ruby", label: "Ruby" },
|
|
50
|
+
{ value: "swift", label: "Swift" },
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
export const Sidecar = ({
|
|
54
|
+
operation,
|
|
55
|
+
selectedResponse,
|
|
56
|
+
globalSelectedServer,
|
|
57
|
+
shouldLazyHighlight,
|
|
58
|
+
}: {
|
|
59
|
+
operation: OperationsFragmentFragment;
|
|
60
|
+
selectedResponse?: string;
|
|
61
|
+
globalSelectedServer?: string;
|
|
62
|
+
shouldLazyHighlight?: boolean;
|
|
63
|
+
}) => {
|
|
64
|
+
const { options } = useOasConfig();
|
|
65
|
+
const auth = useAuthState();
|
|
66
|
+
const context = useZudoku();
|
|
67
|
+
|
|
68
|
+
const methodTextColor = methodForColor(operation.method);
|
|
69
|
+
|
|
70
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
71
|
+
const [, startTransition] = useTransition();
|
|
72
|
+
|
|
73
|
+
const supportedLanguages = options?.supportedLanguages ?? EXAMPLE_LANGUAGES;
|
|
74
|
+
|
|
75
|
+
const preferredLang =
|
|
76
|
+
searchParams.get("lang") ?? options?.examplesLanguage ?? "shell";
|
|
77
|
+
|
|
78
|
+
const selectedLang =
|
|
79
|
+
supportedLanguages.find((lang) => lang.value === preferredLang)?.value ??
|
|
80
|
+
supportedLanguages.at(0)?.value ??
|
|
81
|
+
"shell";
|
|
82
|
+
|
|
83
|
+
const requestBodyContent = operation.requestBody?.content;
|
|
84
|
+
const transformedRequestBodyContent =
|
|
85
|
+
requestBodyContent && options?.transformExamples
|
|
86
|
+
? options.transformExamples({
|
|
87
|
+
auth,
|
|
88
|
+
type: "request",
|
|
89
|
+
operation,
|
|
90
|
+
content: requestBodyContent,
|
|
91
|
+
context,
|
|
92
|
+
})
|
|
93
|
+
: requestBodyContent;
|
|
94
|
+
|
|
95
|
+
const [selectedRequestExample, setSelectedRequestExample] = useState<{
|
|
96
|
+
contentTypeIndex: number;
|
|
97
|
+
exampleIndex: number;
|
|
98
|
+
}>({
|
|
99
|
+
contentTypeIndex: 0,
|
|
100
|
+
exampleIndex: 0,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const selectedContent = transformedRequestBodyContent?.at(
|
|
104
|
+
selectedRequestExample.contentTypeIndex,
|
|
105
|
+
);
|
|
106
|
+
const currentExample = selectedContent?.examples?.at(
|
|
107
|
+
selectedRequestExample.exampleIndex,
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const currentExampleCode = currentExample
|
|
111
|
+
? (currentExample?.value ?? currentExample)
|
|
112
|
+
: selectedContent?.schema
|
|
113
|
+
? generateSchemaExample(selectedContent?.schema)
|
|
114
|
+
: undefined;
|
|
115
|
+
|
|
116
|
+
const path = (
|
|
117
|
+
<PathRenderer
|
|
118
|
+
path={operation.path}
|
|
119
|
+
renderParam={({ name }) => (
|
|
120
|
+
<ColorizedParam
|
|
121
|
+
name={name}
|
|
122
|
+
backgroundOpacity="0"
|
|
123
|
+
className="py-px px-0.5"
|
|
124
|
+
// same as in `ParameterListItem`
|
|
125
|
+
slug={`${operation.slug}-${name}`}
|
|
126
|
+
>
|
|
127
|
+
{`{${name}}`}
|
|
128
|
+
</ColorizedParam>
|
|
129
|
+
)}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// Manual server selection takes precedence over the server hierarchy.
|
|
134
|
+
// If no manual selection, fall back to operation's first server (already respects operation > path > global hierarchy)
|
|
135
|
+
const selectedServer =
|
|
136
|
+
globalSelectedServer || operation.servers.at(0)?.url || "";
|
|
137
|
+
|
|
138
|
+
const httpSnippetCode = useMemo<string | undefined>(() => {
|
|
139
|
+
const converted = options?.generateCodeSnippet?.({
|
|
140
|
+
selectedLang,
|
|
141
|
+
selectedServer,
|
|
142
|
+
context,
|
|
143
|
+
operation,
|
|
144
|
+
example: currentExampleCode,
|
|
145
|
+
auth,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
if (converted) return converted;
|
|
149
|
+
|
|
150
|
+
const snippet = createHttpSnippet({
|
|
151
|
+
operation,
|
|
152
|
+
selectedServer,
|
|
153
|
+
exampleBody: currentExampleCode
|
|
154
|
+
? {
|
|
155
|
+
mimeType: selectedContent?.mediaType ?? "application/json",
|
|
156
|
+
text: JSON.stringify(currentExampleCode, null, 2),
|
|
157
|
+
}
|
|
158
|
+
: { mimeType: selectedContent?.mediaType ?? "application/json" },
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return getConverted(snippet, selectedLang);
|
|
162
|
+
}, [
|
|
163
|
+
currentExampleCode,
|
|
164
|
+
operation,
|
|
165
|
+
selectedServer,
|
|
166
|
+
selectedLang,
|
|
167
|
+
selectedContent,
|
|
168
|
+
options,
|
|
169
|
+
auth,
|
|
170
|
+
context,
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
const [ref, isOnScreen] = useOnScreen({ rootMargin: "200px 0px 200px 0px" });
|
|
174
|
+
|
|
175
|
+
const showPlayground =
|
|
176
|
+
isOnScreen &&
|
|
177
|
+
(operation.extensions["x-explorer-enabled"] === true ||
|
|
178
|
+
operation.extensions["x-zudoku-playground-enabled"] === true ||
|
|
179
|
+
(operation.extensions["x-explorer-enabled"] === undefined &&
|
|
180
|
+
operation.extensions["x-zudoku-playground-enabled"] === undefined &&
|
|
181
|
+
!options?.disablePlayground));
|
|
182
|
+
|
|
183
|
+
const hasResponseExamples = operation.responses.some((response) =>
|
|
184
|
+
response.content?.some((content) => (content.examples?.length ?? 0) > 0),
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<aside
|
|
189
|
+
ref={ref}
|
|
190
|
+
className="flex flex-col sticky top-(--scroll-padding) gap-4"
|
|
191
|
+
data-pagefind-ignore="all"
|
|
192
|
+
>
|
|
193
|
+
<SidecarBox.Root>
|
|
194
|
+
<SidecarBox.Head className="py-1.5">
|
|
195
|
+
<div className="flex items-center flex-wrap gap-2 justify-between w-full">
|
|
196
|
+
<span className="font-mono wrap-break-word leading-6 space-x-1">
|
|
197
|
+
<Badge
|
|
198
|
+
variant="outline"
|
|
199
|
+
className={cn(
|
|
200
|
+
methodTextColor,
|
|
201
|
+
"px-1.5 rounded-md border-none bg-current/7 dark:bg-current/15",
|
|
202
|
+
)}
|
|
203
|
+
>
|
|
204
|
+
{operation.method.toUpperCase()}
|
|
205
|
+
</Badge>
|
|
206
|
+
{path}
|
|
207
|
+
</span>
|
|
208
|
+
<div className="flex items-center gap-1">
|
|
209
|
+
<NativeSelect
|
|
210
|
+
className="py-0.5 h-fit max-w-32 truncate bg-background"
|
|
211
|
+
value={selectedLang}
|
|
212
|
+
onChange={(e) => {
|
|
213
|
+
startTransition(() => {
|
|
214
|
+
setSearchParams((prev) => {
|
|
215
|
+
prev.set("lang", e.target.value);
|
|
216
|
+
return prev;
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
}}
|
|
220
|
+
>
|
|
221
|
+
{supportedLanguages.map((language) => (
|
|
222
|
+
<NativeSelectOption
|
|
223
|
+
key={language.value}
|
|
224
|
+
value={language.value}
|
|
225
|
+
>
|
|
226
|
+
{language.label}
|
|
227
|
+
</NativeSelectOption>
|
|
228
|
+
))}
|
|
229
|
+
</NativeSelect>
|
|
230
|
+
{showPlayground && (
|
|
231
|
+
<PlaygroundDialogWrapper
|
|
232
|
+
servers={operation.servers.map((server) => server.url)}
|
|
233
|
+
operation={operation}
|
|
234
|
+
examples={requestBodyContent ?? undefined}
|
|
235
|
+
/>
|
|
236
|
+
)}
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
</SidecarBox.Head>
|
|
240
|
+
<SidecarBox.Body>
|
|
241
|
+
{shouldLazyHighlight && !isOnScreen ? (
|
|
242
|
+
<NonHighlightedCode code={httpSnippetCode ?? ""} />
|
|
243
|
+
) : (
|
|
244
|
+
<SyntaxHighlight
|
|
245
|
+
embedded
|
|
246
|
+
language={selectedLang}
|
|
247
|
+
className="[--scrollbar-color:gray] rounded-none text-xs max-h-[200px]"
|
|
248
|
+
// biome-ignore lint/style/noNonNullAssertion: code is guaranteed to be defined
|
|
249
|
+
code={httpSnippetCode!}
|
|
250
|
+
/>
|
|
251
|
+
)}
|
|
252
|
+
</SidecarBox.Body>
|
|
253
|
+
</SidecarBox.Root>
|
|
254
|
+
|
|
255
|
+
{transformedRequestBodyContent && currentExample ? (
|
|
256
|
+
<RequestBodySidecarBox
|
|
257
|
+
content={transformedRequestBodyContent}
|
|
258
|
+
onExampleChange={(selected) => {
|
|
259
|
+
setSelectedRequestExample(selected);
|
|
260
|
+
}}
|
|
261
|
+
selectedContentIndex={selectedRequestExample.contentTypeIndex}
|
|
262
|
+
selectedExampleIndex={selectedRequestExample.exampleIndex}
|
|
263
|
+
isOnScreen={isOnScreen}
|
|
264
|
+
shouldLazyHighlight={shouldLazyHighlight}
|
|
265
|
+
/>
|
|
266
|
+
) : transformedRequestBodyContent && currentExampleCode ? (
|
|
267
|
+
<GeneratedExampleSidecarBox
|
|
268
|
+
isOnScreen={isOnScreen}
|
|
269
|
+
shouldLazyHighlight={shouldLazyHighlight}
|
|
270
|
+
code={JSON.stringify(currentExampleCode, null, 2)}
|
|
271
|
+
/>
|
|
272
|
+
) : null}
|
|
273
|
+
|
|
274
|
+
{hasResponseExamples ? (
|
|
275
|
+
<ResponsesSidecarBox
|
|
276
|
+
isOnScreen={isOnScreen}
|
|
277
|
+
shouldLazyHighlight={shouldLazyHighlight}
|
|
278
|
+
selectedResponse={selectedResponse}
|
|
279
|
+
responses={operation.responses.map((response) => ({
|
|
280
|
+
...response,
|
|
281
|
+
content:
|
|
282
|
+
response.content && options?.transformExamples
|
|
283
|
+
? options.transformExamples({
|
|
284
|
+
auth,
|
|
285
|
+
type: "response",
|
|
286
|
+
context,
|
|
287
|
+
operation,
|
|
288
|
+
content: response.content,
|
|
289
|
+
})
|
|
290
|
+
: response.content,
|
|
291
|
+
}))}
|
|
292
|
+
/>
|
|
293
|
+
) : (
|
|
294
|
+
<ResponsesSidecarBox
|
|
295
|
+
isGenerated
|
|
296
|
+
isOnScreen={isOnScreen}
|
|
297
|
+
shouldLazyHighlight={shouldLazyHighlight}
|
|
298
|
+
selectedResponse={selectedResponse}
|
|
299
|
+
responses={operation.responses.map((response) => ({
|
|
300
|
+
...response,
|
|
301
|
+
content: response.content?.map((content) => ({
|
|
302
|
+
...content,
|
|
303
|
+
examples: content.schema
|
|
304
|
+
? [{ name: "", value: generateSchemaExample(content.schema) }]
|
|
305
|
+
: content.examples,
|
|
306
|
+
})),
|
|
307
|
+
}))}
|
|
308
|
+
/>
|
|
309
|
+
)}
|
|
310
|
+
</aside>
|
|
311
|
+
);
|
|
312
|
+
};
|