@scalar/types 0.2.16 → 0.3.1
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/CHANGELOG.md +19 -0
- package/dist/api-reference/api-client-configuration.d.ts +122 -0
- package/dist/api-reference/api-client-configuration.d.ts.map +1 -0
- package/dist/api-reference/api-client-configuration.js +7 -0
- package/dist/api-reference/api-client-configuration.js.map +7 -0
- package/dist/api-reference/api-client-plugin.d.ts +39 -0
- package/dist/api-reference/api-client-plugin.d.ts.map +1 -0
- package/dist/api-reference/api-client-plugin.js +34 -0
- package/dist/api-reference/api-client-plugin.js.map +7 -0
- package/dist/api-reference/api-reference-configuration.d.ts +177 -2144
- package/dist/api-reference/api-reference-configuration.d.ts.map +1 -1
- package/dist/api-reference/api-reference-configuration.js +263 -440
- package/dist/api-reference/api-reference-configuration.js.map +2 -2
- package/dist/api-reference/api-reference-plugin.d.ts +7 -65
- package/dist/api-reference/api-reference-plugin.d.ts.map +1 -1
- package/dist/api-reference/api-reference-plugin.js +8 -7
- package/dist/api-reference/api-reference-plugin.js.map +2 -2
- package/dist/api-reference/base-configuration.d.ts +118 -0
- package/dist/api-reference/base-configuration.d.ts.map +1 -0
- package/dist/api-reference/base-configuration.js +139 -0
- package/dist/api-reference/base-configuration.js.map +7 -0
- package/dist/api-reference/html-rendering-configuration.d.ts +3 -21
- package/dist/api-reference/html-rendering-configuration.d.ts.map +1 -1
- package/dist/api-reference/html-rendering-configuration.js.map +2 -2
- package/dist/api-reference/index.d.ts +6 -3
- package/dist/api-reference/index.d.ts.map +1 -1
- package/dist/api-reference/index.js +12 -3
- package/dist/api-reference/index.js.map +2 -2
- package/dist/api-reference/source-configuration.d.ts +18 -0
- package/dist/api-reference/source-configuration.d.ts.map +1 -0
- package/dist/api-reference/source-configuration.js +87 -0
- package/dist/api-reference/source-configuration.js.map +7 -0
- package/dist/entities/security-scheme.d.ts +220 -1641
- package/dist/entities/security-scheme.d.ts.map +1 -1
- package/dist/entities/security-scheme.js +11 -2
- package/dist/entities/security-scheme.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/snippetz/snippetz.d.ts +9 -3
- package/dist/snippetz/snippetz.d.ts.map +1 -1
- package/dist/snippetz/snippetz.js +1 -0
- package/dist/snippetz/snippetz.js.map +2 -2
- package/package.json +4 -4
- package/dist/api-client/api-client-plugin.d.ts +0 -172
- package/dist/api-client/api-client-plugin.d.ts.map +0 -1
- package/dist/api-client/api-client-plugin.js +0 -33
- package/dist/api-client/api-client-plugin.js.map +0 -7
- package/dist/api-client/index.d.ts +0 -2
- package/dist/api-client/index.d.ts.map +0 -1
- package/dist/api-client/index.js +0 -6
- package/dist/api-client/index.js.map +0 -7
|
@@ -1,466 +1,292 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"moon",
|
|
8
|
-
"purple",
|
|
9
|
-
"solarized",
|
|
10
|
-
"bluePlanet",
|
|
11
|
-
"deepSpace",
|
|
12
|
-
"saturn",
|
|
13
|
-
"kepler",
|
|
14
|
-
"elysiajs",
|
|
15
|
-
"fastify",
|
|
16
|
-
"mars",
|
|
17
|
-
"laserwave",
|
|
18
|
-
"none"
|
|
19
|
-
]);
|
|
20
|
-
const operationTitleEnum = z.enum(["summary", "path"]);
|
|
21
|
-
const searchHotKeyEnum = z.enum([
|
|
22
|
-
"a",
|
|
23
|
-
"b",
|
|
24
|
-
"c",
|
|
25
|
-
"d",
|
|
26
|
-
"e",
|
|
27
|
-
"f",
|
|
28
|
-
"g",
|
|
29
|
-
"h",
|
|
30
|
-
"i",
|
|
31
|
-
"j",
|
|
32
|
-
"k",
|
|
33
|
-
"l",
|
|
34
|
-
"m",
|
|
35
|
-
"n",
|
|
36
|
-
"o",
|
|
37
|
-
"p",
|
|
38
|
-
"q",
|
|
39
|
-
"r",
|
|
40
|
-
"s",
|
|
41
|
-
"t",
|
|
42
|
-
"u",
|
|
43
|
-
"v",
|
|
44
|
-
"w",
|
|
45
|
-
"x",
|
|
46
|
-
"y",
|
|
47
|
-
"z"
|
|
48
|
-
]);
|
|
49
|
-
const integrationEnum = z.enum([
|
|
50
|
-
"adonisjs",
|
|
51
|
-
"docusaurus",
|
|
52
|
-
"dotnet",
|
|
53
|
-
"elysiajs",
|
|
54
|
-
"express",
|
|
55
|
-
"fastapi",
|
|
56
|
-
"fastify",
|
|
57
|
-
"go",
|
|
58
|
-
"hono",
|
|
59
|
-
"html",
|
|
60
|
-
"laravel",
|
|
61
|
-
"litestar",
|
|
62
|
-
"nestjs",
|
|
63
|
-
"nextjs",
|
|
64
|
-
"nitro",
|
|
65
|
-
"nuxt",
|
|
66
|
-
"platformatic",
|
|
67
|
-
"react",
|
|
68
|
-
"rust",
|
|
69
|
-
"svelte",
|
|
70
|
-
"vue"
|
|
71
|
-
]).nullable();
|
|
72
|
-
const specConfigurationSchema = z.object({
|
|
73
|
-
/**
|
|
74
|
-
* URL to an OpenAPI/Swagger document
|
|
75
|
-
*
|
|
76
|
-
* @deprecated Please move `url` to the top level and remove the `spec` prefix.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```ts
|
|
80
|
-
* const oldConfiguration = {
|
|
81
|
-
* spec: {
|
|
82
|
-
* url: 'https://example.com/openapi.json',
|
|
83
|
-
* },
|
|
84
|
-
* }
|
|
85
|
-
*
|
|
86
|
-
* const newConfiguration = {
|
|
87
|
-
* url: 'https://example.com/openapi.json',
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
**/
|
|
91
|
-
url: z.string().optional(),
|
|
2
|
+
import { apiReferencePluginSchema } from "./api-reference-plugin.js";
|
|
3
|
+
import { NEW_PROXY_URL, OLD_PROXY_URL, baseConfigurationSchema } from "./base-configuration.js";
|
|
4
|
+
import { sourceConfigurationSchema } from "./source-configuration.js";
|
|
5
|
+
const fetchLikeSchema = z.custom();
|
|
6
|
+
const apiReferenceConfigurationSchema = baseConfigurationSchema.extend({
|
|
92
7
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
98
|
-
* @deprecated Please move `content` to the top level and remove the `spec` prefix.
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```ts
|
|
102
|
-
* const oldConfiguration = {
|
|
103
|
-
* spec: {
|
|
104
|
-
* content: '…',
|
|
105
|
-
* },
|
|
106
|
-
* }
|
|
107
|
-
*
|
|
108
|
-
* const newConfiguration = {
|
|
109
|
-
* content: '…',
|
|
110
|
-
* }
|
|
111
|
-
* ```
|
|
112
|
-
**/
|
|
113
|
-
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
8
|
+
* The layout to use for the references
|
|
9
|
+
* @default 'modern'
|
|
10
|
+
*/
|
|
11
|
+
layout: z.enum(["modern", "classic"]).optional().default("modern").catch("modern"),
|
|
114
12
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* @example 'Scalar Galaxy'
|
|
118
|
-
*
|
|
119
|
-
* @deprecated Please move `title` to the top level and remove the `spec` prefix.
|
|
13
|
+
* URL to a request proxy for the API client
|
|
14
|
+
* @deprecated Use proxyUrl instead
|
|
120
15
|
*/
|
|
121
|
-
|
|
16
|
+
proxy: z.string().optional(),
|
|
122
17
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* If none is passed, the title will be used.
|
|
126
|
-
*
|
|
127
|
-
* If no title is used, it'll just use the index.
|
|
128
|
-
*
|
|
129
|
-
* @example 'scalar-galaxy'
|
|
18
|
+
* Custom fetch function for custom logic
|
|
130
19
|
*
|
|
131
|
-
*
|
|
20
|
+
* Can be used to add custom headers, handle auth, etc.
|
|
132
21
|
*/
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
const pathRoutingSchema = z.object({
|
|
136
|
-
/** Base path for the API reference */
|
|
137
|
-
basePath: z.string()
|
|
138
|
-
});
|
|
139
|
-
const apiClientConfigurationSchema = z.object({
|
|
22
|
+
fetch: fetchLikeSchema.optional(),
|
|
140
23
|
/**
|
|
141
|
-
*
|
|
142
|
-
|
|
143
|
-
|
|
24
|
+
* Plugins for the API reference
|
|
25
|
+
*/
|
|
26
|
+
plugins: z.array(apiReferencePluginSchema).optional(),
|
|
144
27
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
**/
|
|
150
|
-
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
28
|
+
* Allows the user to inject an editor for the spec
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
isEditable: z.boolean().optional().default(false).catch(false),
|
|
151
32
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* @example 'Scalar Galaxy'
|
|
33
|
+
* Controls whether the references show a loading state in the intro
|
|
34
|
+
* @default false
|
|
155
35
|
*/
|
|
156
|
-
|
|
36
|
+
isLoading: z.boolean().optional().default(false).catch(false),
|
|
157
37
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
*
|
|
164
|
-
* @
|
|
38
|
+
* Whether to show models in the sidebar, search, and content.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
hideModels: z.boolean().optional().default(false).catch(false),
|
|
42
|
+
/**
|
|
43
|
+
* Sets the file type of the document to download, set to `none` to hide the download button
|
|
44
|
+
* @default 'both'
|
|
165
45
|
*/
|
|
166
|
-
|
|
46
|
+
documentDownloadType: z.enum(["yaml", "json", "both", "direct", "none"]).optional().default("both").catch("both"),
|
|
167
47
|
/**
|
|
168
|
-
*
|
|
48
|
+
* Whether to show the "Download OpenAPI Document" button
|
|
49
|
+
* @default false
|
|
50
|
+
* @deprecated Use `documentDownloadType: 'none'` instead
|
|
51
|
+
*/
|
|
52
|
+
hideDownloadButton: z.boolean().optional(),
|
|
53
|
+
/**
|
|
54
|
+
* Whether to show the "Test Request" button
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
hideTestRequestButton: z.boolean().optional().default(false).catch(false),
|
|
58
|
+
/**
|
|
59
|
+
* Whether to show the sidebar search bar
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
hideSearch: z.boolean().optional().default(false).catch(false),
|
|
63
|
+
/**
|
|
64
|
+
* Whether to show the operationId
|
|
169
65
|
*
|
|
170
|
-
* @deprecated Use `url` and `content` on the top level instead.
|
|
171
|
-
**/
|
|
172
|
-
spec: specConfigurationSchema.optional(),
|
|
173
|
-
/** Prefill authentication */
|
|
174
|
-
authentication: z.any().optional(),
|
|
175
|
-
// Temp until we bring in the new auth
|
|
176
|
-
/** Base URL for the API server */
|
|
177
|
-
baseServerURL: z.string().optional(),
|
|
178
|
-
/**
|
|
179
|
-
* Whether to hide the client button
|
|
180
66
|
* @default false
|
|
181
67
|
*/
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
/** List of OpenAPI server objects */
|
|
188
|
-
servers: z.array(z.any()).optional(),
|
|
189
|
-
// Using any for OpenAPIV3_1.ServerObject
|
|
68
|
+
showOperationId: z.boolean().optional().default(false).catch(false),
|
|
69
|
+
/** Whether dark mode is on or off initially (light mode) */
|
|
70
|
+
darkMode: z.boolean().optional(),
|
|
71
|
+
/** forceDarkModeState makes it always this state no matter what */
|
|
72
|
+
forceDarkModeState: z.enum(["dark", "light"]).optional(),
|
|
190
73
|
/**
|
|
191
|
-
* Whether to show the
|
|
192
|
-
* @default
|
|
74
|
+
* Whether to show the dark mode toggle
|
|
75
|
+
* @default false
|
|
193
76
|
*/
|
|
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
|
-
|
|
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
|
-
/** Determine the HTTP client that's selected by default */
|
|
299
|
-
defaultHttpClient: z.object({
|
|
300
|
-
targetKey: z.custom(),
|
|
301
|
-
clientKey: z.string()
|
|
302
|
-
}).optional(),
|
|
303
|
-
/** Custom CSS to be added to the page */
|
|
304
|
-
customCss: z.string().optional(),
|
|
305
|
-
/** onSpecUpdate is fired on spec/swagger content change */
|
|
306
|
-
onSpecUpdate: z.function().args(z.string()).returns(z.void()).optional(),
|
|
307
|
-
/** onServerChange is fired on selected server change */
|
|
308
|
-
onServerChange: z.function().args(z.string()).returns(z.void()).optional(),
|
|
309
|
-
/** onDocumentSelect is fired when the config is selected */
|
|
310
|
-
onDocumentSelect: z.function().returns(z.void().or(z.void().promise())).optional(),
|
|
311
|
-
/** Callback fired when the reference is fully loaded */
|
|
312
|
-
onLoaded: z.function().returns(z.void().or(z.void().promise())).optional(),
|
|
313
|
-
/** onBeforeRequest is fired before the request is sent. You can modify the request here. */
|
|
314
|
-
onBeforeRequest: z.function().args(z.object({ request: z.instanceof(Request) })).returns(z.void().or(z.void().promise())).optional(),
|
|
315
|
-
/**
|
|
316
|
-
* onShowMore is fired when the user clicks the "Show more" button on the references
|
|
317
|
-
* @param tagId - The ID of the tag that was clicked
|
|
318
|
-
*/
|
|
319
|
-
onShowMore: z.function().args(z.string()).returns(z.void().or(z.void().promise())).optional(),
|
|
320
|
-
/**
|
|
321
|
-
* onSidebarClick is fired when the user clicks on a sidebar item
|
|
322
|
-
* @param href - The href of the sidebar item that was clicked
|
|
323
|
-
*/
|
|
324
|
-
onSidebarClick: z.function().args(z.string()).returns(z.void().or(z.void().promise())).optional(),
|
|
325
|
-
/**
|
|
326
|
-
* Route using paths instead of hashes, your server MUST support this
|
|
327
|
-
* @example '/standalone-api-reference/:custom(.*)?'
|
|
328
|
-
* @experimental
|
|
329
|
-
* @default undefined
|
|
330
|
-
*/
|
|
331
|
-
pathRouting: pathRoutingSchema.optional(),
|
|
332
|
-
/**
|
|
333
|
-
* Customize the heading portion of the hash
|
|
334
|
-
* @param heading - The heading object
|
|
335
|
-
* @returns A string ID used to generate the URL hash
|
|
336
|
-
* @default (heading) => `#description/${heading.slug}`
|
|
337
|
-
*/
|
|
338
|
-
generateHeadingSlug: z.function().args(
|
|
339
|
-
z.object({
|
|
340
|
-
slug: z.string().default("headingSlug")
|
|
341
|
-
})
|
|
342
|
-
).returns(z.string()).optional(),
|
|
343
|
-
/**
|
|
344
|
-
* Customize the model portion of the hash
|
|
345
|
-
* @param model - The model object with a name property
|
|
346
|
-
* @returns A string ID used to generate the URL hash
|
|
347
|
-
* @default (model) => slug(model.name)
|
|
348
|
-
*/
|
|
349
|
-
generateModelSlug: z.function().args(
|
|
350
|
-
z.object({
|
|
351
|
-
name: z.string().default("modelName")
|
|
352
|
-
})
|
|
353
|
-
).returns(z.string()).optional(),
|
|
354
|
-
/**
|
|
355
|
-
* Customize the tag portion of the hash
|
|
356
|
-
* @param tag - The tag object
|
|
357
|
-
* @returns A string ID used to generate the URL hash
|
|
358
|
-
* @default (tag) => slug(tag.name)
|
|
359
|
-
*/
|
|
360
|
-
generateTagSlug: z.function().args(
|
|
361
|
-
z.object({
|
|
362
|
-
name: z.string().default("tagName")
|
|
363
|
-
})
|
|
364
|
-
).returns(z.string()).optional(),
|
|
365
|
-
/**
|
|
366
|
-
* Customize the operation portion of the hash
|
|
367
|
-
* @param operation - The operation object
|
|
368
|
-
* @returns A string ID used to generate the URL hash
|
|
369
|
-
* @default (operation) => `${operation.method}${operation.path}`
|
|
370
|
-
*/
|
|
371
|
-
generateOperationSlug: z.function().args(
|
|
77
|
+
hideDarkModeToggle: z.boolean().optional().default(false).catch(false),
|
|
78
|
+
/**
|
|
79
|
+
* If used, passed data will be added to the HTML header
|
|
80
|
+
* @see https://unhead.unjs.io/usage/composables/use-seo-meta
|
|
81
|
+
*/
|
|
82
|
+
metaData: z.any().optional(),
|
|
83
|
+
// Using any for UseSeoMetaInput since it's an external type
|
|
84
|
+
/**
|
|
85
|
+
* Path to a favicon image
|
|
86
|
+
* @default undefined
|
|
87
|
+
* @example '/favicon.svg'
|
|
88
|
+
*/
|
|
89
|
+
favicon: z.string().optional(),
|
|
90
|
+
/**
|
|
91
|
+
* List of httpsnippet clients to hide from the clients menu
|
|
92
|
+
* By default hides Unirest, pass `[]` to show all clients
|
|
93
|
+
*/
|
|
94
|
+
hiddenClients: z.union([z.record(z.string(), z.union([z.boolean(), z.array(z.string())])), z.array(z.string()), z.literal(true)]).optional(),
|
|
95
|
+
/** Determine the HTTP client that's selected by default */
|
|
96
|
+
defaultHttpClient: z.object({
|
|
97
|
+
targetKey: z.custom(),
|
|
98
|
+
clientKey: z.string()
|
|
99
|
+
}).optional(),
|
|
100
|
+
/** Custom CSS to be added to the page */
|
|
101
|
+
customCss: z.string().optional(),
|
|
102
|
+
/** onSpecUpdate is fired on spec/swagger content change */
|
|
103
|
+
onSpecUpdate: z.function({
|
|
104
|
+
input: [z.string()],
|
|
105
|
+
output: z.void()
|
|
106
|
+
}).optional(),
|
|
107
|
+
/** onServerChange is fired on selected server change */
|
|
108
|
+
onServerChange: z.function({
|
|
109
|
+
input: [z.string()],
|
|
110
|
+
output: z.void()
|
|
111
|
+
}).optional(),
|
|
112
|
+
/** onDocumentSelect is fired when the config is selected */
|
|
113
|
+
onDocumentSelect: z.function().optional(),
|
|
114
|
+
/** Callback fired when the reference is fully loaded */
|
|
115
|
+
onLoaded: z.function().optional(),
|
|
116
|
+
/** onBeforeRequest is fired before the request is sent. You can modify the request here. */
|
|
117
|
+
onBeforeRequest: z.function({ input: [z.object({ request: z.instanceof(Request) })], output: z.void() }).optional(),
|
|
118
|
+
/**
|
|
119
|
+
* onShowMore is fired when the user clicks the "Show more" button on the references
|
|
120
|
+
* @param tagId - The ID of the tag that was clicked
|
|
121
|
+
*/
|
|
122
|
+
onShowMore: z.function({
|
|
123
|
+
input: [z.string()],
|
|
124
|
+
output: z.void()
|
|
125
|
+
}).optional(),
|
|
126
|
+
/**
|
|
127
|
+
* onSidebarClick is fired when the user clicks on a sidebar item
|
|
128
|
+
* @param href - The href of the sidebar item that was clicked
|
|
129
|
+
*/
|
|
130
|
+
onSidebarClick: z.function({
|
|
131
|
+
input: [z.string()],
|
|
132
|
+
output: z.void()
|
|
133
|
+
}).optional(),
|
|
134
|
+
/**
|
|
135
|
+
* Route using paths instead of hashes, your server MUST support this
|
|
136
|
+
* @example '/standalone-api-reference/:custom(.*)?'
|
|
137
|
+
* @experimental
|
|
138
|
+
* @default undefined
|
|
139
|
+
*/
|
|
140
|
+
pathRouting: z.object({
|
|
141
|
+
basePath: z.string()
|
|
142
|
+
}).optional(),
|
|
143
|
+
/**
|
|
144
|
+
* Customize the heading portion of the hash
|
|
145
|
+
* @param heading - The heading object
|
|
146
|
+
* @returns A string ID used to generate the URL hash
|
|
147
|
+
* @default (heading) => `#description/${heading.slug}`
|
|
148
|
+
*/
|
|
149
|
+
generateHeadingSlug: z.function({
|
|
150
|
+
input: [z.object({ slug: z.string().default("headingSlug") })],
|
|
151
|
+
output: z.string()
|
|
152
|
+
}).optional(),
|
|
153
|
+
/**
|
|
154
|
+
* Customize the model portion of the hash
|
|
155
|
+
* @param model - The model object with a name property
|
|
156
|
+
* @returns A string ID used to generate the URL hash
|
|
157
|
+
* @default (model) => slug(model.name)
|
|
158
|
+
*/
|
|
159
|
+
generateModelSlug: z.function({
|
|
160
|
+
input: [z.object({ name: z.string().default("modelName") })],
|
|
161
|
+
output: z.string()
|
|
162
|
+
}).optional(),
|
|
163
|
+
/**
|
|
164
|
+
* Customize the tag portion of the hash
|
|
165
|
+
* @param tag - The tag object
|
|
166
|
+
* @returns A string ID used to generate the URL hash
|
|
167
|
+
* @default (tag) => slug(tag.name)
|
|
168
|
+
*/
|
|
169
|
+
generateTagSlug: z.function({
|
|
170
|
+
input: [z.object({ name: z.string().default("tagName") })],
|
|
171
|
+
output: z.string()
|
|
172
|
+
}).optional(),
|
|
173
|
+
/**
|
|
174
|
+
* Customize the operation portion of the hash
|
|
175
|
+
* @param operation - The operation object
|
|
176
|
+
* @returns A string ID used to generate the URL hash
|
|
177
|
+
* @default (operation) => `${operation.method}${operation.path}`
|
|
178
|
+
*/
|
|
179
|
+
generateOperationSlug: z.function({
|
|
180
|
+
input: [
|
|
372
181
|
z.object({
|
|
373
182
|
path: z.string(),
|
|
374
183
|
operationId: z.string().optional(),
|
|
375
184
|
method: z.string(),
|
|
376
185
|
summary: z.string().optional()
|
|
377
186
|
})
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
187
|
+
],
|
|
188
|
+
output: z.string()
|
|
189
|
+
}).optional(),
|
|
190
|
+
/**
|
|
191
|
+
* Customize the webhook portion of the hash
|
|
192
|
+
* @param webhook - The webhook object
|
|
193
|
+
* @returns A string ID used to generate the URL hash
|
|
194
|
+
* @default (webhook) => slug(webhook.name)
|
|
195
|
+
*/
|
|
196
|
+
generateWebhookSlug: z.function({
|
|
197
|
+
input: [
|
|
386
198
|
z.object({
|
|
387
199
|
name: z.string(),
|
|
388
200
|
method: z.string().optional()
|
|
389
201
|
})
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
)
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
202
|
+
],
|
|
203
|
+
output: z.string()
|
|
204
|
+
}).optional(),
|
|
205
|
+
/**
|
|
206
|
+
* To handle redirects, pass a function that will recieve:
|
|
207
|
+
* - The current path with hash if pathRouting is enabled
|
|
208
|
+
* - The current hash if hashRouting (default)
|
|
209
|
+
* And then passes that to history.replaceState
|
|
210
|
+
*
|
|
211
|
+
* @example hashRouting (default)
|
|
212
|
+
* ```ts
|
|
213
|
+
* redirect: (hash: string) => hash.replace('#v1/old-path', '#v2/new-path')
|
|
214
|
+
* ```
|
|
215
|
+
* @example pathRouting
|
|
216
|
+
* ```ts
|
|
217
|
+
* redirect: (pathWithHash: string) => {
|
|
218
|
+
* if (pathWithHash.includes('#')) {
|
|
219
|
+
* return pathWithHash.replace('/v1/tags/user#operation/get-user', '/v1/tags/user/operation/get-user')
|
|
220
|
+
* }
|
|
221
|
+
* return null
|
|
222
|
+
* }
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
redirect: z.function({
|
|
226
|
+
input: [z.string()],
|
|
227
|
+
output: z.string().nullable().optional()
|
|
228
|
+
}).optional(),
|
|
229
|
+
/**
|
|
230
|
+
* Whether to include default fonts
|
|
231
|
+
* @default true
|
|
232
|
+
*/
|
|
233
|
+
withDefaultFonts: z.boolean().optional().default(true).catch(true),
|
|
234
|
+
/**
|
|
235
|
+
* Whether to expand all tags by default
|
|
236
|
+
*
|
|
237
|
+
* Warning this can cause performance issues on big documents
|
|
238
|
+
* @default false
|
|
239
|
+
*/
|
|
240
|
+
defaultOpenAllTags: z.boolean().optional().default(false).catch(false),
|
|
241
|
+
/**
|
|
242
|
+
* Whether to expand all models by default
|
|
243
|
+
*
|
|
244
|
+
* Warning this can cause performance issues on big documents
|
|
245
|
+
* @default false
|
|
246
|
+
*/
|
|
247
|
+
expandAllModelSections: z.boolean().optional().default(false).catch(false),
|
|
248
|
+
/**
|
|
249
|
+
* Whether to expand all responses by default
|
|
250
|
+
*
|
|
251
|
+
* Warning this can cause performance issues on big documents
|
|
252
|
+
* @default false
|
|
253
|
+
*/
|
|
254
|
+
expandAllResponses: z.boolean().optional().default(false).catch(false),
|
|
255
|
+
/**
|
|
256
|
+
* Function to sort tags
|
|
257
|
+
* @default 'alpha' for alphabetical sorting
|
|
258
|
+
*/
|
|
259
|
+
tagsSorter: z.union([
|
|
260
|
+
z.literal("alpha"),
|
|
261
|
+
z.function({
|
|
262
|
+
input: [z.any(), z.any()],
|
|
263
|
+
output: z.number()
|
|
264
|
+
})
|
|
265
|
+
]).optional(),
|
|
266
|
+
/**
|
|
267
|
+
* Function to sort operations
|
|
268
|
+
* @default 'alpha' for alphabetical sorting
|
|
269
|
+
*/
|
|
270
|
+
operationsSorter: z.union([
|
|
271
|
+
z.literal("alpha"),
|
|
272
|
+
z.literal("method"),
|
|
273
|
+
z.function({
|
|
274
|
+
input: [z.any(), z.any()],
|
|
275
|
+
output: z.number()
|
|
276
|
+
})
|
|
277
|
+
]).optional(),
|
|
278
|
+
/**
|
|
279
|
+
* Order the schema properties by
|
|
280
|
+
* @default 'alpha' for alphabetical sorting
|
|
281
|
+
*/
|
|
282
|
+
orderSchemaPropertiesBy: z.union([z.literal("alpha"), z.literal("preserve")]).optional().default("alpha").catch("alpha"),
|
|
283
|
+
/**
|
|
284
|
+
* Sort the schema properties by required ones first
|
|
285
|
+
* @default true
|
|
286
|
+
*/
|
|
287
|
+
orderRequiredPropertiesFirst: z.boolean().optional().default(true).catch(true)
|
|
288
|
+
});
|
|
289
|
+
const apiReferenceConfigurationWithSourceSchema = apiReferenceConfigurationSchema.extend(sourceConfigurationSchema.shape).transform((configuration) => {
|
|
464
290
|
if (configuration.hideDownloadButton) {
|
|
465
291
|
console.warn(
|
|
466
292
|
`[DEPRECATED] You're using the deprecated 'hideDownloadButton' attribute. Use 'documentDownloadType: 'none'' instead.`
|
|
@@ -499,14 +325,11 @@ const migrateConfiguration = (_configuration) => {
|
|
|
499
325
|
configuration.proxyUrl = NEW_PROXY_URL;
|
|
500
326
|
}
|
|
501
327
|
return configuration;
|
|
502
|
-
};
|
|
503
|
-
const apiReferenceConfigurationSchema = _apiReferenceConfigurationSchema.transform(migrateConfiguration);
|
|
328
|
+
});
|
|
504
329
|
const isConfigurationWithSources = (config) => Boolean(!Array.isArray(config) && config && "sources" in config && Array.isArray(config.sources));
|
|
505
330
|
export {
|
|
506
|
-
FetchLike,
|
|
507
|
-
apiClientConfigurationSchema,
|
|
508
331
|
apiReferenceConfigurationSchema,
|
|
509
|
-
|
|
510
|
-
|
|
332
|
+
apiReferenceConfigurationWithSourceSchema,
|
|
333
|
+
isConfigurationWithSources
|
|
511
334
|
};
|
|
512
335
|
//# sourceMappingURL=api-reference-configuration.js.map
|