@scalar/types 0.3.0 → 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 +8 -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-client → api-reference}/api-client-plugin.d.ts +6 -3
- package/dist/api-reference/api-client-plugin.d.ts.map +1 -0
- package/dist/{api-client → api-reference}/api-client-plugin.js +10 -10
- package/dist/{api-client → api-reference}/api-client-plugin.js.map +3 -3
- package/dist/api-reference/api-reference-configuration.d.ts +58 -525
- package/dist/api-reference/api-reference-configuration.d.ts.map +1 -1
- package/dist/api-reference/api-reference-configuration.js +264 -501
- package/dist/api-reference/api-reference-configuration.js.map +2 -2
- package/dist/api-reference/api-reference-plugin.d.ts +4 -4
- package/dist/api-reference/api-reference-plugin.d.ts.map +1 -1
- package/dist/api-reference/api-reference-plugin.js +5 -5
- 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 +2 -2
- 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/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 +1 -1
- 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 +2 -2
- package/dist/api-client/api-client-plugin.d.ts.map +0 -1
- 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,527 +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([
|
|
114
|
-
z.string(),
|
|
115
|
-
z.null(),
|
|
116
|
-
z.record(z.string(), z.any()),
|
|
117
|
-
z.function({
|
|
118
|
-
input: [],
|
|
119
|
-
output: z.record(z.string(), z.any())
|
|
120
|
-
})
|
|
121
|
-
]).optional(),
|
|
8
|
+
* The layout to use for the references
|
|
9
|
+
* @default 'modern'
|
|
10
|
+
*/
|
|
11
|
+
layout: z.enum(["modern", "classic"]).optional().default("modern").catch("modern"),
|
|
122
12
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @example 'Scalar Galaxy'
|
|
126
|
-
*
|
|
127
|
-
* @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
|
|
128
15
|
*/
|
|
129
|
-
|
|
16
|
+
proxy: z.string().optional(),
|
|
130
17
|
/**
|
|
131
|
-
*
|
|
18
|
+
* Custom fetch function for custom logic
|
|
132
19
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* If no title is used, it'll just use the index.
|
|
136
|
-
*
|
|
137
|
-
* @example 'scalar-galaxy'
|
|
138
|
-
*
|
|
139
|
-
* @deprecated Please move `slug` to the top level and remove the `spec` prefix.
|
|
20
|
+
* Can be used to add custom headers, handle auth, etc.
|
|
140
21
|
*/
|
|
141
|
-
|
|
142
|
-
});
|
|
143
|
-
const pathRoutingSchema = z.object({
|
|
144
|
-
/** Base path for the API reference */
|
|
145
|
-
basePath: z.string()
|
|
146
|
-
});
|
|
147
|
-
const apiClientConfigurationSchema = z.object({
|
|
22
|
+
fetch: fetchLikeSchema.optional(),
|
|
148
23
|
/**
|
|
149
|
-
*
|
|
150
|
-
|
|
151
|
-
|
|
24
|
+
* Plugins for the API reference
|
|
25
|
+
*/
|
|
26
|
+
plugins: z.array(apiReferencePluginSchema).optional(),
|
|
152
27
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
**/
|
|
158
|
-
content: z.union([
|
|
159
|
-
z.string(),
|
|
160
|
-
z.null(),
|
|
161
|
-
z.record(z.string(), z.any()),
|
|
162
|
-
z.function({
|
|
163
|
-
input: [],
|
|
164
|
-
output: z.record(z.string(), z.any())
|
|
165
|
-
})
|
|
166
|
-
]).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),
|
|
167
32
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* @example 'Scalar Galaxy'
|
|
33
|
+
* Controls whether the references show a loading state in the intro
|
|
34
|
+
* @default false
|
|
171
35
|
*/
|
|
172
|
-
|
|
36
|
+
isLoading: z.boolean().optional().default(false).catch(false),
|
|
173
37
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
*
|
|
180
|
-
* @
|
|
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'
|
|
45
|
+
*/
|
|
46
|
+
documentDownloadType: z.enum(["yaml", "json", "both", "direct", "none"]).optional().default("both").catch("both"),
|
|
47
|
+
/**
|
|
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
|
|
181
61
|
*/
|
|
182
|
-
|
|
62
|
+
hideSearch: z.boolean().optional().default(false).catch(false),
|
|
183
63
|
/**
|
|
184
|
-
*
|
|
64
|
+
* Whether to show the operationId
|
|
185
65
|
*
|
|
186
|
-
* @deprecated Use `url` and `content` on the top level instead.
|
|
187
|
-
**/
|
|
188
|
-
spec: specConfigurationSchema.optional(),
|
|
189
|
-
/** Prefill authentication */
|
|
190
|
-
authentication: z.any().optional(),
|
|
191
|
-
// Temp until we bring in the new auth
|
|
192
|
-
/** Base URL for the API server */
|
|
193
|
-
baseServerURL: z.string().optional(),
|
|
194
|
-
/**
|
|
195
|
-
* Whether to hide the client button
|
|
196
66
|
* @default false
|
|
197
67
|
*/
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
|
|
203
|
-
/** List of OpenAPI server objects */
|
|
204
|
-
servers: z.array(z.any()).optional(),
|
|
205
|
-
// 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(),
|
|
206
73
|
/**
|
|
207
|
-
* Whether to show the
|
|
208
|
-
* @default
|
|
74
|
+
* Whether to show the dark mode toggle
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
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
|
|
209
81
|
*/
|
|
210
|
-
|
|
82
|
+
metaData: z.any().optional(),
|
|
83
|
+
// Using any for UseSeoMetaInput since it's an external type
|
|
211
84
|
/**
|
|
212
|
-
*
|
|
213
|
-
* @default
|
|
85
|
+
* Path to a favicon image
|
|
86
|
+
* @default undefined
|
|
87
|
+
* @example '/favicon.svg'
|
|
214
88
|
*/
|
|
215
|
-
|
|
89
|
+
favicon: z.string().optional(),
|
|
216
90
|
/**
|
|
217
|
-
*
|
|
218
|
-
*
|
|
91
|
+
* List of httpsnippet clients to hide from the clients menu
|
|
92
|
+
* By default hides Unirest, pass `[]` to show all clients
|
|
219
93
|
*/
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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({
|
|
227
104
|
input: [z.string()],
|
|
228
105
|
output: z.void()
|
|
229
106
|
}).optional(),
|
|
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
|
-
*/
|
|
310
|
-
hideDarkModeToggle: z.boolean().optional().default(false).catch(false),
|
|
311
|
-
/**
|
|
312
|
-
* If used, passed data will be added to the HTML header
|
|
313
|
-
* @see https://unhead.unjs.io/usage/composables/use-seo-meta
|
|
314
|
-
*/
|
|
315
|
-
metaData: z.any().optional(),
|
|
316
|
-
// Using any for UseSeoMetaInput since it's an external type
|
|
317
|
-
/**
|
|
318
|
-
* Path to a favicon image
|
|
319
|
-
* @default undefined
|
|
320
|
-
* @example '/favicon.svg'
|
|
321
|
-
*/
|
|
322
|
-
favicon: z.string().optional(),
|
|
323
|
-
/**
|
|
324
|
-
* List of httpsnippet clients to hide from the clients menu
|
|
325
|
-
* By default hides Unirest, pass `[]` to show all clients
|
|
326
|
-
*/
|
|
327
|
-
hiddenClients: z.union([z.record(z.string(), z.union([z.boolean(), z.array(z.string())])), z.array(z.string()), z.literal(true)]).optional(),
|
|
328
|
-
/** Determine the HTTP client that's selected by default */
|
|
329
|
-
defaultHttpClient: z.object({
|
|
330
|
-
targetKey: z.custom(),
|
|
331
|
-
clientKey: z.string()
|
|
332
|
-
}).optional(),
|
|
333
|
-
/** Custom CSS to be added to the page */
|
|
334
|
-
customCss: z.string().optional(),
|
|
335
|
-
/** onSpecUpdate is fired on spec/swagger content change */
|
|
336
|
-
onSpecUpdate: z.function({
|
|
337
|
-
input: [z.string()],
|
|
338
|
-
output: z.void()
|
|
339
|
-
}).optional(),
|
|
340
|
-
/** onServerChange is fired on selected server change */
|
|
341
|
-
onServerChange: z.function({
|
|
342
|
-
input: [z.string()],
|
|
343
|
-
output: z.void()
|
|
344
|
-
}).optional(),
|
|
345
|
-
/** onDocumentSelect is fired when the config is selected */
|
|
346
|
-
onDocumentSelect: z.function().optional(),
|
|
347
|
-
/** Callback fired when the reference is fully loaded */
|
|
348
|
-
onLoaded: z.function().optional(),
|
|
349
|
-
/** onBeforeRequest is fired before the request is sent. You can modify the request here. */
|
|
350
|
-
onBeforeRequest: z.function({ input: [z.object({ request: z.instanceof(Request) })], output: z.void() }).optional(),
|
|
351
|
-
/**
|
|
352
|
-
* onShowMore is fired when the user clicks the "Show more" button on the references
|
|
353
|
-
* @param tagId - The ID of the tag that was clicked
|
|
354
|
-
*/
|
|
355
|
-
onShowMore: z.function({
|
|
356
|
-
input: [z.string()],
|
|
357
|
-
output: z.void()
|
|
358
|
-
}).optional(),
|
|
359
|
-
/**
|
|
360
|
-
* onSidebarClick is fired when the user clicks on a sidebar item
|
|
361
|
-
* @param href - The href of the sidebar item that was clicked
|
|
362
|
-
*/
|
|
363
|
-
onSidebarClick: z.function({
|
|
364
|
-
input: [z.string()],
|
|
365
|
-
output: z.void()
|
|
366
|
-
}).optional(),
|
|
367
|
-
/**
|
|
368
|
-
* Route using paths instead of hashes, your server MUST support this
|
|
369
|
-
* @example '/standalone-api-reference/:custom(.*)?'
|
|
370
|
-
* @experimental
|
|
371
|
-
* @default undefined
|
|
372
|
-
*/
|
|
373
|
-
pathRouting: pathRoutingSchema.optional(),
|
|
374
|
-
/**
|
|
375
|
-
* Customize the heading portion of the hash
|
|
376
|
-
* @param heading - The heading object
|
|
377
|
-
* @returns A string ID used to generate the URL hash
|
|
378
|
-
* @default (heading) => `#description/${heading.slug}`
|
|
379
|
-
*/
|
|
380
|
-
generateHeadingSlug: z.function({
|
|
381
|
-
input: [z.object({ slug: z.string().default("headingSlug") })],
|
|
382
|
-
output: z.string()
|
|
383
|
-
}).optional(),
|
|
384
|
-
/**
|
|
385
|
-
* Customize the model portion of the hash
|
|
386
|
-
* @param model - The model object with a name property
|
|
387
|
-
* @returns A string ID used to generate the URL hash
|
|
388
|
-
* @default (model) => slug(model.name)
|
|
389
|
-
*/
|
|
390
|
-
generateModelSlug: z.function({
|
|
391
|
-
input: [z.object({ name: z.string().default("modelName") })],
|
|
392
|
-
output: z.string()
|
|
393
|
-
}).optional(),
|
|
394
|
-
/**
|
|
395
|
-
* Customize the tag portion of the hash
|
|
396
|
-
* @param tag - The tag object
|
|
397
|
-
* @returns A string ID used to generate the URL hash
|
|
398
|
-
* @default (tag) => slug(tag.name)
|
|
399
|
-
*/
|
|
400
|
-
generateTagSlug: z.function({
|
|
401
|
-
input: [z.object({ name: z.string().default("tagName") })],
|
|
402
|
-
output: z.string()
|
|
403
|
-
}).optional(),
|
|
404
|
-
/**
|
|
405
|
-
* Customize the operation portion of the hash
|
|
406
|
-
* @param operation - The operation object
|
|
407
|
-
* @returns A string ID used to generate the URL hash
|
|
408
|
-
* @default (operation) => `${operation.method}${operation.path}`
|
|
409
|
-
*/
|
|
410
|
-
generateOperationSlug: z.function({
|
|
411
|
-
input: [
|
|
412
|
-
z.object({
|
|
413
|
-
path: z.string(),
|
|
414
|
-
operationId: z.string().optional(),
|
|
415
|
-
method: z.string(),
|
|
416
|
-
summary: z.string().optional()
|
|
417
|
-
})
|
|
418
|
-
],
|
|
419
|
-
output: z.string()
|
|
420
|
-
}).optional(),
|
|
421
|
-
/**
|
|
422
|
-
* Customize the webhook portion of the hash
|
|
423
|
-
* @param webhook - The webhook object
|
|
424
|
-
* @returns A string ID used to generate the URL hash
|
|
425
|
-
* @default (webhook) => slug(webhook.name)
|
|
426
|
-
*/
|
|
427
|
-
generateWebhookSlug: z.function({
|
|
428
|
-
input: [
|
|
429
|
-
z.object({
|
|
430
|
-
name: z.string(),
|
|
431
|
-
method: z.string().optional()
|
|
432
|
-
})
|
|
433
|
-
],
|
|
434
|
-
output: z.string()
|
|
435
|
-
}).optional(),
|
|
436
|
-
/**
|
|
437
|
-
* To handle redirects, pass a function that will recieve:
|
|
438
|
-
* - The current path with hash if pathRouting is enabled
|
|
439
|
-
* - The current hash if hashRouting (default)
|
|
440
|
-
* And then passes that to history.replaceState
|
|
441
|
-
*
|
|
442
|
-
* @example hashRouting (default)
|
|
443
|
-
* ```ts
|
|
444
|
-
* redirect: (hash: string) => hash.replace('#v1/old-path', '#v2/new-path')
|
|
445
|
-
* ```
|
|
446
|
-
* @example pathRouting
|
|
447
|
-
* ```ts
|
|
448
|
-
* redirect: (pathWithHash: string) => {
|
|
449
|
-
* if (pathWithHash.includes('#')) {
|
|
450
|
-
* return pathWithHash.replace('/v1/tags/user#operation/get-user', '/v1/tags/user/operation/get-user')
|
|
451
|
-
* }
|
|
452
|
-
* return null
|
|
453
|
-
* }
|
|
454
|
-
* ```
|
|
455
|
-
*/
|
|
456
|
-
redirect: z.function({
|
|
457
|
-
input: [z.string()],
|
|
458
|
-
output: z.string().nullable().optional()
|
|
459
|
-
}).optional(),
|
|
460
|
-
/**
|
|
461
|
-
* Whether to include default fonts
|
|
462
|
-
* @default true
|
|
463
|
-
*/
|
|
464
|
-
withDefaultFonts: z.boolean().optional().default(true).catch(true),
|
|
465
|
-
/**
|
|
466
|
-
* Whether to expand all tags by default
|
|
467
|
-
*
|
|
468
|
-
* Warning this can cause performance issues on big documents
|
|
469
|
-
* @default false
|
|
470
|
-
*/
|
|
471
|
-
defaultOpenAllTags: z.boolean().optional().default(false).catch(false),
|
|
472
|
-
/**
|
|
473
|
-
* Whether to expand all models by default
|
|
474
|
-
*
|
|
475
|
-
* Warning this can cause performance issues on big documents
|
|
476
|
-
* @default false
|
|
477
|
-
*/
|
|
478
|
-
expandAllModelSections: z.boolean().optional().default(false).catch(false),
|
|
479
|
-
/**
|
|
480
|
-
* Whether to expand all responses by default
|
|
481
|
-
*
|
|
482
|
-
* Warning this can cause performance issues on big documents
|
|
483
|
-
* @default false
|
|
484
|
-
*/
|
|
485
|
-
expandAllResponses: z.boolean().optional().default(false).catch(false),
|
|
486
|
-
/**
|
|
487
|
-
* Function to sort tags
|
|
488
|
-
* @default 'alpha' for alphabetical sorting
|
|
489
|
-
*/
|
|
490
|
-
tagsSorter: z.union([
|
|
491
|
-
z.literal("alpha"),
|
|
492
|
-
z.function({
|
|
493
|
-
input: [z.any(), z.any()],
|
|
494
|
-
output: z.number()
|
|
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: [
|
|
181
|
+
z.object({
|
|
182
|
+
path: z.string(),
|
|
183
|
+
operationId: z.string().optional(),
|
|
184
|
+
method: z.string(),
|
|
185
|
+
summary: z.string().optional()
|
|
495
186
|
})
|
|
496
|
-
]
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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: [
|
|
198
|
+
z.object({
|
|
199
|
+
name: z.string(),
|
|
200
|
+
method: z.string().optional()
|
|
507
201
|
})
|
|
508
|
-
]
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
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) => {
|
|
525
290
|
if (configuration.hideDownloadButton) {
|
|
526
291
|
console.warn(
|
|
527
292
|
`[DEPRECATED] You're using the deprecated 'hideDownloadButton' attribute. Use 'documentDownloadType: 'none'' instead.`
|
|
@@ -560,13 +325,11 @@ const migrateConfiguration = (_configuration) => {
|
|
|
560
325
|
configuration.proxyUrl = NEW_PROXY_URL;
|
|
561
326
|
}
|
|
562
327
|
return configuration;
|
|
563
|
-
};
|
|
564
|
-
const apiReferenceConfigurationSchema = _apiReferenceConfigurationSchema.transform(migrateConfiguration);
|
|
328
|
+
});
|
|
565
329
|
const isConfigurationWithSources = (config) => Boolean(!Array.isArray(config) && config && "sources" in config && Array.isArray(config.sources));
|
|
566
330
|
export {
|
|
567
|
-
apiClientConfigurationSchema,
|
|
568
331
|
apiReferenceConfigurationSchema,
|
|
569
|
-
|
|
570
|
-
|
|
332
|
+
apiReferenceConfigurationWithSourceSchema,
|
|
333
|
+
isConfigurationWithSources
|
|
571
334
|
};
|
|
572
335
|
//# sourceMappingURL=api-reference-configuration.js.map
|