@scalar/types 0.0.36 → 0.0.37
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-reference-configuration.d.ts +578 -0
- package/dist/api-reference/api-reference-configuration.d.ts.map +1 -0
- package/dist/api-reference/api-reference-configuration.js +333 -0
- package/dist/api-reference/api-reference-configuration.test-d.d.ts +2 -0
- package/dist/api-reference/api-reference-configuration.test-d.d.ts.map +1 -0
- package/dist/api-reference/helpers/migrate-theme-variables.d.ts +10 -0
- package/dist/api-reference/helpers/migrate-theme-variables.d.ts.map +1 -0
- package/dist/api-reference/helpers/migrate-theme-variables.js +21 -0
- package/dist/api-reference/index.d.ts +3 -0
- package/dist/api-reference/index.d.ts.map +1 -0
- package/dist/api-reference/index.js +2 -0
- package/dist/legacy/reference-config.d.ts +50 -43
- package/dist/legacy/reference-config.d.ts.map +1 -1
- package/package.json +12 -3
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { migrateThemeVariables } from './helpers/migrate-theme-variables.js';
|
|
3
|
+
|
|
4
|
+
/** Available theme presets for the API reference */
|
|
5
|
+
const themeIdEnum = z.enum([
|
|
6
|
+
'alternate',
|
|
7
|
+
'default',
|
|
8
|
+
'moon',
|
|
9
|
+
'purple',
|
|
10
|
+
'solarized',
|
|
11
|
+
'bluePlanet',
|
|
12
|
+
'deepSpace',
|
|
13
|
+
'saturn',
|
|
14
|
+
'kepler',
|
|
15
|
+
'elysiajs',
|
|
16
|
+
'fastify',
|
|
17
|
+
'mars',
|
|
18
|
+
'none',
|
|
19
|
+
]);
|
|
20
|
+
/** Valid keys that can be used with CTRL/CMD to open the search modal */
|
|
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
|
+
/** Supported integration types */
|
|
50
|
+
const integrationEnum = z
|
|
51
|
+
.enum([
|
|
52
|
+
'adonisjs',
|
|
53
|
+
'docusaurus',
|
|
54
|
+
'dotnet',
|
|
55
|
+
'elysiajs',
|
|
56
|
+
'express',
|
|
57
|
+
'fastapi',
|
|
58
|
+
'fastify',
|
|
59
|
+
'go',
|
|
60
|
+
'hono',
|
|
61
|
+
'html',
|
|
62
|
+
'laravel',
|
|
63
|
+
'litestar',
|
|
64
|
+
'nestjs',
|
|
65
|
+
'nextjs',
|
|
66
|
+
'nitro',
|
|
67
|
+
'nuxt',
|
|
68
|
+
'platformatic',
|
|
69
|
+
'react',
|
|
70
|
+
'rust',
|
|
71
|
+
'vue',
|
|
72
|
+
])
|
|
73
|
+
.nullable();
|
|
74
|
+
/** Configuration for the OpenAPI/Swagger specification */
|
|
75
|
+
const specConfigurationSchema = z.object({
|
|
76
|
+
/** URL to an OpenAPI/Swagger document */
|
|
77
|
+
url: z.string().optional(),
|
|
78
|
+
/**
|
|
79
|
+
* Directly embed the OpenAPI document.
|
|
80
|
+
* Can be a string, object, function returning an object, or null.
|
|
81
|
+
* @remarks It's recommended to pass a URL instead of content.
|
|
82
|
+
*/
|
|
83
|
+
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
84
|
+
});
|
|
85
|
+
/** Configuration for path-based routing */
|
|
86
|
+
const pathRoutingSchema = z.object({
|
|
87
|
+
/** Base path for the API reference */
|
|
88
|
+
basePath: z.string(),
|
|
89
|
+
});
|
|
90
|
+
/** Configuration for the Api Client */
|
|
91
|
+
const apiClientConfigurationSchema = z.object({
|
|
92
|
+
/** Prefill authentication */
|
|
93
|
+
authentication: z.any().optional(), // Temp until we bring in the new auth
|
|
94
|
+
/** Base URL for the API server */
|
|
95
|
+
baseServerURL: z.string().optional(),
|
|
96
|
+
/**
|
|
97
|
+
* Whether to hide the client button
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
hideClientButton: z.boolean().optional().default(false).catch(false),
|
|
101
|
+
/** URL to a request proxy for the API client */
|
|
102
|
+
proxyUrl: z.string().optional(),
|
|
103
|
+
/** Key used with CTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k) */
|
|
104
|
+
searchHotKey: searchHotKeyEnum.optional(),
|
|
105
|
+
/** List of OpenAPI server objects */
|
|
106
|
+
servers: z.array(z.any()).optional(), // Using any for OpenAPIV3_1.ServerObject
|
|
107
|
+
/**
|
|
108
|
+
* Whether to show the sidebar
|
|
109
|
+
* @default true
|
|
110
|
+
*/
|
|
111
|
+
showSidebar: z.boolean().optional().default(true).catch(true),
|
|
112
|
+
/** The Swagger/OpenAPI spec to render */
|
|
113
|
+
spec: specConfigurationSchema.optional(),
|
|
114
|
+
/** A string to use one of the color presets */
|
|
115
|
+
theme: themeIdEnum.optional().default('default').catch('default'),
|
|
116
|
+
/** Integration type identifier */
|
|
117
|
+
_integration: integrationEnum.optional(),
|
|
118
|
+
});
|
|
119
|
+
const OLD_PROXY_URL = 'https://api.scalar.com/request-proxy';
|
|
120
|
+
const NEW_PROXY_URL = 'https://proxy.scalar.com';
|
|
121
|
+
/** Configuration for the Api Reference */
|
|
122
|
+
const apiReferenceConfigurationSchema = apiClientConfigurationSchema
|
|
123
|
+
.merge(z.object({
|
|
124
|
+
/**
|
|
125
|
+
* The layout to use for the references
|
|
126
|
+
* @default 'modern'
|
|
127
|
+
*/
|
|
128
|
+
layout: z.enum(['modern', 'classic']).optional().default('modern').catch('modern'),
|
|
129
|
+
/**
|
|
130
|
+
* URL to a request proxy for the API client
|
|
131
|
+
* @deprecated Use proxyUrl instead
|
|
132
|
+
*/
|
|
133
|
+
proxy: z.string().optional(),
|
|
134
|
+
/**
|
|
135
|
+
* Whether the spec input should show
|
|
136
|
+
* @default false
|
|
137
|
+
*/
|
|
138
|
+
isEditable: z.boolean().optional().default(false).catch(false),
|
|
139
|
+
/**
|
|
140
|
+
* Whether to show models in the sidebar, search, and content.
|
|
141
|
+
* @default false
|
|
142
|
+
*/
|
|
143
|
+
hideModels: z.boolean().optional().default(false).catch(false),
|
|
144
|
+
/**
|
|
145
|
+
* Whether to show the "Download OpenAPI Document" button
|
|
146
|
+
* @default false
|
|
147
|
+
*/
|
|
148
|
+
hideDownloadButton: z.boolean().optional().default(false).catch(false),
|
|
149
|
+
/**
|
|
150
|
+
* Whether to show the "Test Request" button
|
|
151
|
+
* @default false
|
|
152
|
+
*/
|
|
153
|
+
hideTestRequestButton: z.boolean().optional().default(false).catch(false),
|
|
154
|
+
/**
|
|
155
|
+
* Whether to show the sidebar search bar
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
158
|
+
hideSearch: z.boolean().optional().default(false).catch(false),
|
|
159
|
+
/** Whether dark mode is on or off initially (light mode) */
|
|
160
|
+
darkMode: z.boolean().optional(),
|
|
161
|
+
/** forceDarkModeState makes it always this state no matter what */
|
|
162
|
+
forceDarkModeState: z.enum(['dark', 'light']).optional(),
|
|
163
|
+
/**
|
|
164
|
+
* Whether to show the dark mode toggle
|
|
165
|
+
* @default false
|
|
166
|
+
*/
|
|
167
|
+
hideDarkModeToggle: z.boolean().optional().default(false).catch(false),
|
|
168
|
+
/**
|
|
169
|
+
* If used, passed data will be added to the HTML header
|
|
170
|
+
* @see https://unhead.unjs.io/usage/composables/use-seo-meta
|
|
171
|
+
*/
|
|
172
|
+
metaData: z.any().optional(), // Using any for UseSeoMetaInput since it's an external type
|
|
173
|
+
/**
|
|
174
|
+
* Path to a favicon image
|
|
175
|
+
* @default undefined
|
|
176
|
+
* @example '/favicon.svg'
|
|
177
|
+
*/
|
|
178
|
+
favicon: z.string().optional(),
|
|
179
|
+
/**
|
|
180
|
+
* List of httpsnippet clients to hide from the clients menu
|
|
181
|
+
* By default hides Unirest, pass `[]` to show all clients
|
|
182
|
+
*/
|
|
183
|
+
hiddenClients: z.union([z.record(z.union([z.boolean(), z.array(z.string())])), z.array(z.string())]).optional(),
|
|
184
|
+
/** Determine the HTTP client that's selected by default */
|
|
185
|
+
defaultHttpClient: z
|
|
186
|
+
.object({
|
|
187
|
+
targetKey: z.custom(),
|
|
188
|
+
clientKey: z.string(),
|
|
189
|
+
})
|
|
190
|
+
.optional(),
|
|
191
|
+
/** Custom CSS to be added to the page */
|
|
192
|
+
customCss: z.string().optional(),
|
|
193
|
+
/** onSpecUpdate is fired on spec/swagger content change */
|
|
194
|
+
onSpecUpdate: z.function().args(z.string()).returns(z.void()).optional(),
|
|
195
|
+
/** onServerChange is fired on selected server change */
|
|
196
|
+
onServerChange: z.function().args(z.string()).returns(z.void()).optional(),
|
|
197
|
+
/**
|
|
198
|
+
* Route using paths instead of hashes, your server MUST support this
|
|
199
|
+
* @example '/standalone-api-reference/:custom(.*)?'
|
|
200
|
+
* @experimental
|
|
201
|
+
* @default undefined
|
|
202
|
+
*/
|
|
203
|
+
pathRouting: pathRoutingSchema.optional(),
|
|
204
|
+
/**
|
|
205
|
+
* Customize the heading portion of the hash
|
|
206
|
+
* @param heading - The heading object
|
|
207
|
+
* @returns A string ID used to generate the URL hash
|
|
208
|
+
* @default (heading) => `#description/${heading.slug}`
|
|
209
|
+
*/
|
|
210
|
+
generateHeadingSlug: z
|
|
211
|
+
.function()
|
|
212
|
+
.args(z.object({ slug: z.string().default('headingSlug') }))
|
|
213
|
+
.returns(z.string())
|
|
214
|
+
.optional(),
|
|
215
|
+
/**
|
|
216
|
+
* Customize the model portion of the hash
|
|
217
|
+
* @param model - The model object with a name property
|
|
218
|
+
* @returns A string ID used to generate the URL hash
|
|
219
|
+
* @default (model) => slug(model.name)
|
|
220
|
+
*/
|
|
221
|
+
generateModelSlug: z
|
|
222
|
+
.function()
|
|
223
|
+
.args(z.object({ name: z.string().default('modelName') }))
|
|
224
|
+
.returns(z.string())
|
|
225
|
+
.optional(),
|
|
226
|
+
/**
|
|
227
|
+
* Customize the tag portion of the hash
|
|
228
|
+
* @param tag - The tag object
|
|
229
|
+
* @returns A string ID used to generate the URL hash
|
|
230
|
+
* @default (tag) => slug(tag.name)
|
|
231
|
+
*/
|
|
232
|
+
generateTagSlug: z
|
|
233
|
+
.function()
|
|
234
|
+
.args(z.object({ name: z.string().default('tagName') }))
|
|
235
|
+
.returns(z.string())
|
|
236
|
+
.optional(),
|
|
237
|
+
/**
|
|
238
|
+
* Customize the operation portion of the hash
|
|
239
|
+
* @param operation - The operation object
|
|
240
|
+
* @returns A string ID used to generate the URL hash
|
|
241
|
+
* @default (operation) => `${operation.method}${operation.path}`
|
|
242
|
+
*/
|
|
243
|
+
generateOperationSlug: z
|
|
244
|
+
.function()
|
|
245
|
+
.args(z.object({
|
|
246
|
+
path: z.string(),
|
|
247
|
+
operationId: z.string().optional(),
|
|
248
|
+
method: z.string(),
|
|
249
|
+
summary: z.string().optional(),
|
|
250
|
+
}))
|
|
251
|
+
.returns(z.string())
|
|
252
|
+
.optional(),
|
|
253
|
+
/**
|
|
254
|
+
* Customize the webhook portion of the hash
|
|
255
|
+
* @param webhook - The webhook object
|
|
256
|
+
* @returns A string ID used to generate the URL hash
|
|
257
|
+
* @default (webhook) => slug(webhook.name)
|
|
258
|
+
*/
|
|
259
|
+
generateWebhookSlug: z
|
|
260
|
+
.function()
|
|
261
|
+
.args(z.object({
|
|
262
|
+
name: z.string(),
|
|
263
|
+
method: z.string().optional(),
|
|
264
|
+
}))
|
|
265
|
+
.returns(z.string())
|
|
266
|
+
.optional(),
|
|
267
|
+
/** Callback fired when the reference is fully loaded */
|
|
268
|
+
onLoaded: z.union([z.function().returns(z.void()), z.undefined()]).optional(),
|
|
269
|
+
/**
|
|
270
|
+
* To handle redirects, pass a function that will recieve:
|
|
271
|
+
* - The current path with hash if pathRouting is enabled
|
|
272
|
+
* - The current hash if hashRouting (default)
|
|
273
|
+
* And then passes that to history.replaceState
|
|
274
|
+
*
|
|
275
|
+
* @example hashRouting (default)
|
|
276
|
+
* ```ts
|
|
277
|
+
* redirect: (hash: string) => hash.replace('#v1/old-path', '#v2/new-path')
|
|
278
|
+
* ```
|
|
279
|
+
* @example pathRouting
|
|
280
|
+
* ```ts
|
|
281
|
+
* redirect: (pathWithHash: string) => {
|
|
282
|
+
* if (pathWithHash.includes('#')) {
|
|
283
|
+
* return pathWithHash.replace('/v1/tags/user#operation/get-user', '/v1/tags/user/operation/get-user')
|
|
284
|
+
* }
|
|
285
|
+
* return null
|
|
286
|
+
* }
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
redirect: z.function().args(z.string()).returns(z.string().nullable().optional()).optional(),
|
|
290
|
+
/**
|
|
291
|
+
* Whether to include default fonts
|
|
292
|
+
* @default true
|
|
293
|
+
*/
|
|
294
|
+
withDefaultFonts: z.boolean().optional().default(true).catch(true),
|
|
295
|
+
/** Whether to expand all tags by default */
|
|
296
|
+
defaultOpenAllTags: z.boolean().optional(),
|
|
297
|
+
/**
|
|
298
|
+
* Function to sort tags
|
|
299
|
+
* @default 'alpha' for alphabetical sorting
|
|
300
|
+
*/
|
|
301
|
+
tagsSorter: z.union([z.literal('alpha'), z.function().args(z.any(), z.any()).returns(z.number())]).optional(),
|
|
302
|
+
/**
|
|
303
|
+
* Function to sort operations
|
|
304
|
+
* @default 'alpha' for alphabetical sorting
|
|
305
|
+
*/
|
|
306
|
+
operationsSorter: z
|
|
307
|
+
.union([z.literal('alpha'), z.literal('method'), z.function().args(z.any(), z.any()).returns(z.number())])
|
|
308
|
+
.optional(),
|
|
309
|
+
}))
|
|
310
|
+
.transform((_configuration) => {
|
|
311
|
+
const configuration = { ..._configuration };
|
|
312
|
+
// Migrate legacy theme variables
|
|
313
|
+
if (configuration.customCss) {
|
|
314
|
+
configuration.customCss = migrateThemeVariables(configuration.customCss);
|
|
315
|
+
}
|
|
316
|
+
// Migrate proxy URL
|
|
317
|
+
if (configuration.proxy) {
|
|
318
|
+
console.warn(`[DEPRECATED] You’re using the deprecated 'proxy' attribute, rename it to 'proxyUrl' or update the package.`);
|
|
319
|
+
if (!configuration.proxyUrl) {
|
|
320
|
+
configuration.proxyUrl = configuration.proxy;
|
|
321
|
+
}
|
|
322
|
+
delete configuration.proxy;
|
|
323
|
+
}
|
|
324
|
+
if (configuration.proxyUrl === OLD_PROXY_URL) {
|
|
325
|
+
console.warn(`[DEPRECATED] Warning: configuration.proxyUrl points to our old proxy (${OLD_PROXY_URL}).`);
|
|
326
|
+
console.warn(`[DEPRECATED] We are overwriting the value and use the new proxy URL (${NEW_PROXY_URL}) instead.`);
|
|
327
|
+
console.warn(`[DEPRECATED] Action Required: You should manually update your configuration to use the new URL (${NEW_PROXY_URL}). Read more: https://github.com/scalar/scalar`);
|
|
328
|
+
configuration.proxyUrl = NEW_PROXY_URL;
|
|
329
|
+
}
|
|
330
|
+
return configuration;
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
export { apiClientConfigurationSchema, apiReferenceConfigurationSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-reference-configuration.test-d.d.ts","sourceRoot":"","sources":["../../src/api-reference/api-reference-configuration.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The legacy -> updated CSS variable prefix pairs */
|
|
2
|
+
export declare const PREFIX_MIGRATIONS: readonly [readonly ["--theme-", "--scalar-"], readonly ["--sidebar-", "--scalar-sidebar-"]];
|
|
3
|
+
export declare const LEGACY_PREFIXES: ("--theme-" | "--sidebar-")[];
|
|
4
|
+
/**
|
|
5
|
+
* Checks a style string for legacy theme variables and updated them to the new theme variables
|
|
6
|
+
*
|
|
7
|
+
* @param styles the style string to be checked for legacy theme variables and updated
|
|
8
|
+
*/
|
|
9
|
+
export declare function migrateThemeVariables(styles: string): string;
|
|
10
|
+
//# sourceMappingURL=migrate-theme-variables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-theme-variables.d.ts","sourceRoot":"","sources":["../../../src/api-reference/helpers/migrate-theme-variables.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,6FAGpB,CAAA;AAEV,eAAO,MAAM,eAAe,+BAA8C,CAAA;AAE1E;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAU5D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The legacy -> updated CSS variable prefix pairs */
|
|
2
|
+
const PREFIX_MIGRATIONS = [
|
|
3
|
+
['--theme-', '--scalar-'],
|
|
4
|
+
['--sidebar-', '--scalar-sidebar-'],
|
|
5
|
+
];
|
|
6
|
+
const LEGACY_PREFIXES = PREFIX_MIGRATIONS.map(([legacy]) => legacy);
|
|
7
|
+
/**
|
|
8
|
+
* Checks a style string for legacy theme variables and updated them to the new theme variables
|
|
9
|
+
*
|
|
10
|
+
* @param styles the style string to be checked for legacy theme variables and updated
|
|
11
|
+
*/
|
|
12
|
+
function migrateThemeVariables(styles) {
|
|
13
|
+
const hasLegacyPrefixes = LEGACY_PREFIXES.some((p) => styles.includes(p));
|
|
14
|
+
if (!hasLegacyPrefixes)
|
|
15
|
+
return styles;
|
|
16
|
+
console.warn(`DEPRECATION WARNING: It looks like you're using legacy CSS variables in your custom CSS string. Please migrate them to use the updated prefixes. See https://github.com/scalar/scalar/blob/main/documentation/themes.md#theme-prefix-changes`);
|
|
17
|
+
// Replaces each old variable in the prefix migrations
|
|
18
|
+
return PREFIX_MIGRATIONS.reduce((s, [o, n]) => s.replaceAll(o, n), styles);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { LEGACY_PREFIXES, PREFIX_MIGRATIONS, migrateThemeVariables };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api-reference/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA"}
|
|
@@ -33,82 +33,89 @@ export type PathRouting = {
|
|
|
33
33
|
basePath: string;
|
|
34
34
|
};
|
|
35
35
|
export type ThemeId = 'alternate' | 'default' | 'moon' | 'purple' | 'solarized' | 'bluePlanet' | 'deepSpace' | 'saturn' | 'kepler' | 'elysiajs' | 'fastify' | 'mars' | 'none';
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use ApiReferenceConfiguration instead
|
|
38
|
+
*
|
|
39
|
+
* @example import type { ApiReferenceConfiguration } from '@scalar/types/api-reference'
|
|
40
|
+
*/
|
|
36
41
|
export type ReferenceConfiguration = {
|
|
37
42
|
/** A string to use one of the color presets */
|
|
38
|
-
theme?: ThemeId;
|
|
43
|
+
theme?: ThemeId | undefined | unknown;
|
|
39
44
|
/** The layout to use for the references */
|
|
40
|
-
layout?: 'modern' | 'classic';
|
|
45
|
+
layout?: 'modern' | 'classic' | unknown;
|
|
41
46
|
/** The Swagger/OpenAPI spec to render */
|
|
42
|
-
spec?: SpecConfiguration;
|
|
47
|
+
spec?: SpecConfiguration | undefined;
|
|
43
48
|
/**
|
|
44
49
|
* URL to a request proxy for the API client
|
|
45
50
|
*
|
|
46
51
|
* @deprecated Use proxyUrl instead
|
|
47
52
|
*/
|
|
48
|
-
proxy?: string;
|
|
53
|
+
proxy?: string | undefined;
|
|
49
54
|
/** URL to a request proxy for the API client */
|
|
50
55
|
proxyUrl?: string | undefined;
|
|
51
56
|
/** Whether the spec input should show */
|
|
52
|
-
isEditable?: boolean;
|
|
57
|
+
isEditable?: boolean | unknown;
|
|
53
58
|
/** Whether to show the sidebar */
|
|
54
|
-
showSidebar?: boolean;
|
|
59
|
+
showSidebar?: boolean | undefined | unknown;
|
|
55
60
|
/**
|
|
56
61
|
* Whether to show models in the sidebar, search, and content.
|
|
57
62
|
*
|
|
58
63
|
* @default false
|
|
59
64
|
*/
|
|
60
|
-
hideModels?: boolean;
|
|
65
|
+
hideModels?: boolean | undefined | unknown;
|
|
61
66
|
/**
|
|
62
67
|
* Whether to show the “Download OpenAPI Document” button
|
|
63
68
|
*
|
|
64
69
|
* @default false
|
|
65
70
|
*/
|
|
66
|
-
hideDownloadButton?: boolean;
|
|
71
|
+
hideDownloadButton?: boolean | undefined | unknown;
|
|
67
72
|
/**
|
|
68
73
|
* Whether to show the “Test Request” button
|
|
69
74
|
*
|
|
70
75
|
* @default: false
|
|
71
76
|
*/
|
|
72
|
-
hideTestRequestButton?: boolean;
|
|
77
|
+
hideTestRequestButton?: boolean | undefined | unknown;
|
|
73
78
|
/**
|
|
74
79
|
* Whether to show the sidebar search bar
|
|
75
80
|
*
|
|
76
81
|
* @default: false
|
|
77
82
|
*/
|
|
78
|
-
hideSearch?: boolean;
|
|
83
|
+
hideSearch?: boolean | undefined | unknown;
|
|
79
84
|
/** Whether dark mode is on or off initially (light mode) */
|
|
80
|
-
darkMode?: boolean;
|
|
85
|
+
darkMode?: boolean | undefined | unknown;
|
|
81
86
|
/** forceDarkModeState makes it always this state no matter what*/
|
|
82
|
-
forceDarkModeState?: 'dark' | 'light';
|
|
87
|
+
forceDarkModeState?: 'dark' | 'light' | undefined;
|
|
83
88
|
/** Whether to show the dark mode toggle */
|
|
84
|
-
hideDarkModeToggle?: boolean;
|
|
89
|
+
hideDarkModeToggle?: boolean | undefined | unknown;
|
|
85
90
|
/** Key used with CTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k) */
|
|
86
|
-
searchHotKey?: 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
|
|
91
|
+
searchHotKey?: 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | undefined;
|
|
87
92
|
/**
|
|
88
93
|
* If used, passed data will be added to the HTML header
|
|
89
94
|
* @see https://unhead.unjs.io/usage/composables/use-seo-meta
|
|
90
95
|
*/
|
|
91
|
-
metaData?: UseSeoMetaInput;
|
|
96
|
+
metaData?: UseSeoMetaInput | undefined;
|
|
92
97
|
/**
|
|
93
98
|
* Path to a favicon image
|
|
94
99
|
*
|
|
95
100
|
* @default undefined
|
|
96
101
|
* @example '/favicon.svg'
|
|
97
102
|
*/
|
|
98
|
-
favicon?: string;
|
|
103
|
+
favicon?: string | undefined;
|
|
99
104
|
/**
|
|
100
105
|
* List of httpsnippet clients to hide from the clients menu
|
|
101
106
|
* By default hides Unirest, pass `[]` to show all clients
|
|
102
107
|
*/
|
|
103
|
-
hiddenClients?: HiddenClients;
|
|
108
|
+
hiddenClients?: HiddenClients | undefined;
|
|
104
109
|
/** Determine the HTTP client that’s selected by default */
|
|
105
|
-
defaultHttpClient?: HttpClientState;
|
|
110
|
+
defaultHttpClient?: HttpClientState | undefined;
|
|
106
111
|
/** Custom CSS to be added to the page */
|
|
107
|
-
customCss?: string;
|
|
112
|
+
customCss?: string | undefined;
|
|
108
113
|
/** onSpecUpdate is fired on spec/swagger content change */
|
|
109
|
-
onSpecUpdate?: (spec: string) => void;
|
|
114
|
+
onSpecUpdate?: ((spec: string) => void) | undefined;
|
|
115
|
+
/** onServerChange is fired on selected server change */
|
|
116
|
+
onServerChange?: ((server: string) => void) | undefined;
|
|
110
117
|
/** Prefill authentication */
|
|
111
|
-
authentication?: Partial<AuthenticationState
|
|
118
|
+
authentication?: Partial<AuthenticationState> | undefined;
|
|
112
119
|
/**
|
|
113
120
|
* Route using paths instead of hashes, your server MUST support this
|
|
114
121
|
* for example vue router needs a catch all so any subpaths are included
|
|
@@ -119,7 +126,7 @@ export type ReferenceConfiguration = {
|
|
|
119
126
|
* @experimental
|
|
120
127
|
* @default undefined
|
|
121
128
|
*/
|
|
122
|
-
pathRouting?: PathRouting;
|
|
129
|
+
pathRouting?: PathRouting | undefined;
|
|
123
130
|
/**
|
|
124
131
|
* To handle redirects, pass a function that will recieve:
|
|
125
132
|
* - The current path with hash if pathRouting is enabled
|
|
@@ -140,7 +147,7 @@ export type ReferenceConfiguration = {
|
|
|
140
147
|
* }
|
|
141
148
|
* ```
|
|
142
149
|
*/
|
|
143
|
-
redirect?: (pathWithHash: string) => string | null | undefined;
|
|
150
|
+
redirect?: ((pathWithHash: string) => string | null | undefined) | undefined;
|
|
144
151
|
/**
|
|
145
152
|
* If you want to customize the heading portion of the hash you can pass in a function that receives the heading
|
|
146
153
|
* and returns a string ID. This will then be used to generate the url hash. You control the whole hash with this
|
|
@@ -151,7 +158,7 @@ export type ReferenceConfiguration = {
|
|
|
151
158
|
* @default
|
|
152
159
|
* (heading: Heading) => `#description/${heading.slug}`
|
|
153
160
|
*/
|
|
154
|
-
generateHeadingSlug?: (heading: Heading) => string;
|
|
161
|
+
generateHeadingSlug?: ((heading: Heading) => string) | undefined;
|
|
155
162
|
/**
|
|
156
163
|
* If you want to customize the model portion of the hash you can pass in a function that receives the model name
|
|
157
164
|
* and returns a string ID. This will then be used to generate the url hash. model/ will get prepended to the result
|
|
@@ -164,9 +171,9 @@ export type ReferenceConfiguration = {
|
|
|
164
171
|
*
|
|
165
172
|
* which would give the full hash of `#model/${slug(model.name)}`
|
|
166
173
|
*/
|
|
167
|
-
generateModelSlug?: (model: {
|
|
174
|
+
generateModelSlug?: ((model: {
|
|
168
175
|
name: string;
|
|
169
|
-
}) => string;
|
|
176
|
+
}) => string) | undefined;
|
|
170
177
|
/**
|
|
171
178
|
* If you want to customize the tag portion of the hash you can pass in a function that receives the tag
|
|
172
179
|
* and returns a string ID. This will then be used to generate the url hash. tag/ will get prepended to the result
|
|
@@ -179,7 +186,7 @@ export type ReferenceConfiguration = {
|
|
|
179
186
|
*
|
|
180
187
|
* which would give the full hash of `#tag/tag-name`
|
|
181
188
|
*/
|
|
182
|
-
generateTagSlug?: (tag: Tag) => string;
|
|
189
|
+
generateTagSlug?: ((tag: Tag) => string) | undefined;
|
|
183
190
|
/**
|
|
184
191
|
* If you want to customize the operation portion of the hash you can pass in a function that receives the operation
|
|
185
192
|
* and returns a string ID. This will then be used to generate the url hash. tag/slug(tag.name) will get prepended to
|
|
@@ -192,12 +199,12 @@ export type ReferenceConfiguration = {
|
|
|
192
199
|
*
|
|
193
200
|
* which would give the full hash of `#tag/tag-name/post-path`
|
|
194
201
|
*/
|
|
195
|
-
generateOperationSlug?: (operation: {
|
|
202
|
+
generateOperationSlug?: ((operation: {
|
|
196
203
|
path: string;
|
|
197
204
|
operationId: string | undefined;
|
|
198
205
|
method: string;
|
|
199
206
|
summary: string | undefined;
|
|
200
|
-
}) => string;
|
|
207
|
+
}) => string) | undefined;
|
|
201
208
|
/**
|
|
202
209
|
* If you want to customize the webhook portion of the hash you can pass in a function that receives the webhook name
|
|
203
210
|
* and possibly a HTTP verb and returns a string ID. This will then be used to generate the url hash. webhook/ will get
|
|
@@ -210,10 +217,10 @@ export type ReferenceConfiguration = {
|
|
|
210
217
|
*
|
|
211
218
|
* which would give the full hash of `#webhook/webhook-name`
|
|
212
219
|
*/
|
|
213
|
-
generateWebhookSlug?: (webhook: {
|
|
220
|
+
generateWebhookSlug?: ((webhook: {
|
|
214
221
|
name: string;
|
|
215
222
|
method?: string;
|
|
216
|
-
}) => string;
|
|
223
|
+
}) => string) | undefined;
|
|
217
224
|
/**
|
|
218
225
|
* The baseServerURL is used when the spec servers are relative paths and we are using SSR.
|
|
219
226
|
* On the client we can grab the window.location.origin but on the server we need
|
|
@@ -234,35 +241,35 @@ export type ReferenceConfiguration = {
|
|
|
234
241
|
* }
|
|
235
242
|
* ```
|
|
236
243
|
*/
|
|
237
|
-
onLoaded?: () => void;
|
|
238
|
-
baseServerURL?: string;
|
|
244
|
+
onLoaded?: ((...args: unknown[]) => void) | undefined;
|
|
245
|
+
baseServerURL?: string | undefined;
|
|
239
246
|
/**
|
|
240
247
|
* List of servers to override the servers in the given OpenAPI document
|
|
241
248
|
*
|
|
242
249
|
* @default undefined
|
|
243
250
|
* @example [{ url: 'https://api.scalar.com', description: 'Production server' }]
|
|
244
251
|
*/
|
|
245
|
-
servers?: OpenAPIV3_1.ServerObject[];
|
|
252
|
+
servers?: OpenAPIV3_1.ServerObject[] | undefined;
|
|
246
253
|
/**
|
|
247
254
|
* We’re using Inter and JetBrains Mono as the default fonts. If you want to use your own fonts, set this to false.
|
|
248
255
|
*
|
|
249
256
|
* @default true
|
|
250
257
|
*/
|
|
251
|
-
withDefaultFonts?: boolean;
|
|
258
|
+
withDefaultFonts?: boolean | undefined | unknown;
|
|
252
259
|
/**
|
|
253
260
|
* By default we only open the relevant tag based on the url, however if you want all the tags open by default then set this configuration option :)
|
|
254
261
|
*
|
|
255
262
|
* @default false
|
|
256
263
|
*/
|
|
257
|
-
defaultOpenAllTags?: boolean;
|
|
264
|
+
defaultOpenAllTags?: boolean | undefined | unknown;
|
|
258
265
|
/**
|
|
259
266
|
* Sort tags alphabetically or with a custom sort function
|
|
260
267
|
*/
|
|
261
|
-
tagsSorter?: 'alpha' | ((a: Tag, b: Tag) => number);
|
|
268
|
+
tagsSorter?: 'alpha' | ((a: Tag, b: Tag) => number) | undefined;
|
|
262
269
|
/**
|
|
263
270
|
* Sort operations alphabetically, by method or with a custom sort function
|
|
264
271
|
*/
|
|
265
|
-
operationsSorter?: 'alpha' | 'method' | ((a: TransformedOperation, b: TransformedOperation) => number);
|
|
272
|
+
operationsSorter?: 'alpha' | 'method' | ((a: TransformedOperation, b: TransformedOperation) => number) | undefined;
|
|
266
273
|
/**
|
|
267
274
|
* Specifies the integration being used. This is primarily for internal purposes and should not be manually set.
|
|
268
275
|
*
|
|
@@ -276,13 +283,13 @@ export type ReferenceConfiguration = {
|
|
|
276
283
|
*
|
|
277
284
|
* @private
|
|
278
285
|
*/
|
|
279
|
-
_integration?: null | 'adonisjs' | 'docusaurus' | 'dotnet' | 'elysiajs' | 'express' | 'fastapi' | 'fastify' | 'go' | 'hono' | 'html' | 'laravel' | 'litestar' | 'nestjs' | 'nextjs' | 'nitro' | 'nuxt' | 'platformatic' | 'react' | 'rust' | 'vue';
|
|
286
|
+
_integration?: null | 'adonisjs' | 'docusaurus' | 'dotnet' | 'elysiajs' | 'express' | 'fastapi' | 'fastify' | 'go' | 'hono' | 'html' | 'laravel' | 'litestar' | 'nestjs' | 'nextjs' | 'nitro' | 'nuxt' | 'platformatic' | 'react' | 'rust' | 'vue' | undefined;
|
|
280
287
|
/**
|
|
281
288
|
* Whether to show the client button from the reference sidebar and modal
|
|
282
289
|
*
|
|
283
290
|
* @default false
|
|
284
291
|
*/
|
|
285
|
-
hideClientButton?: boolean;
|
|
292
|
+
hideClientButton?: boolean | undefined | unknown;
|
|
286
293
|
};
|
|
287
294
|
export type BaseParameter = {
|
|
288
295
|
name: string;
|
|
@@ -292,7 +299,7 @@ export type BaseParameter = {
|
|
|
292
299
|
enabled: boolean;
|
|
293
300
|
};
|
|
294
301
|
type OptionalCharset = string | null;
|
|
295
|
-
export type ContentType = `application/json${OptionalCharset}` | `application/xml${OptionalCharset}` | `text/plain${OptionalCharset}` | `text/html${OptionalCharset}` | `application/octet-stream${OptionalCharset}` | `application/x-www-form-urlencoded${OptionalCharset}` | `multipart/form-data${OptionalCharset}` | `*/*${OptionalCharset}`;
|
|
302
|
+
export type ContentType = `application/json${OptionalCharset}` | `application/xml${OptionalCharset}` | `text/plain${OptionalCharset}` | `text/html${OptionalCharset}` | `application/octet-stream${OptionalCharset}` | `application/x-www-form-urlencoded${OptionalCharset}` | `multipart/form-data${OptionalCharset}` | `*/*${OptionalCharset}` | `application/vnd.${string}+json${OptionalCharset}`;
|
|
296
303
|
export type Cookie = {
|
|
297
304
|
name: string;
|
|
298
305
|
value: string;
|
|
@@ -391,13 +398,13 @@ export type SpecConfiguration = {
|
|
|
391
398
|
/**
|
|
392
399
|
* URL to an OpenAPI/Swagger document
|
|
393
400
|
*/
|
|
394
|
-
url?: string;
|
|
401
|
+
url?: string | undefined;
|
|
395
402
|
/**
|
|
396
403
|
* Directly embed the OpenAPI document in the HTML.
|
|
397
404
|
*
|
|
398
405
|
* @remark It’s recommended to pass an `url` instead of `content`.
|
|
399
406
|
*/
|
|
400
|
-
content?: string | Record<string, any> | (() => Record<string, any>) | null;
|
|
407
|
+
content?: string | Record<string, any> | (() => Record<string, any>) | null | undefined;
|
|
401
408
|
};
|
|
402
409
|
export type Schema = {
|
|
403
410
|
type: string;
|