@scalar/types 0.1.13 → 0.1.14
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 +9 -9
- package/dist/api-reference/api-reference-configuration.d.ts.map +1 -1
- package/dist/api-reference/api-reference-configuration.js +271 -289
- package/dist/api-reference/api-reference-configuration.js.map +7 -0
- package/dist/api-reference/api-reference-configuration.test.js +224 -0
- package/dist/api-reference/api-reference-configuration.test.js.map +7 -0
- package/dist/api-reference/api-reference-plugin.js +24 -22
- package/dist/api-reference/api-reference-plugin.js.map +7 -0
- package/dist/api-reference/authentication-configuration.d.ts +2 -2
- package/dist/api-reference/authentication-configuration.d.ts.map +1 -1
- package/dist/api-reference/authentication-configuration.js +1 -0
- package/dist/api-reference/authentication-configuration.js.map +7 -0
- package/dist/api-reference/authentication-configuration.test-d.js +45 -0
- package/dist/api-reference/authentication-configuration.test-d.js.map +7 -0
- package/dist/api-reference/html-api.d.ts +1 -1
- package/dist/api-reference/html-api.d.ts.map +1 -1
- package/dist/api-reference/html-api.js +1 -0
- package/dist/api-reference/html-api.js.map +7 -0
- package/dist/api-reference/html-rendering-configuration.d.ts +1 -1
- package/dist/api-reference/html-rendering-configuration.d.ts.map +1 -1
- package/dist/api-reference/html-rendering-configuration.js +19 -21
- package/dist/api-reference/html-rendering-configuration.js.map +7 -0
- package/dist/api-reference/index.d.ts +4 -5
- package/dist/api-reference/index.d.ts.map +1 -1
- package/dist/api-reference/index.js +17 -3
- package/dist/api-reference/index.js.map +7 -0
- package/dist/entities/index.d.ts +1 -1
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +21 -1
- package/dist/entities/index.js.map +7 -0
- package/dist/entities/security-scheme.js +116 -157
- package/dist/entities/security-scheme.js.map +7 -0
- package/dist/entities/security-scheme.test.js +311 -0
- package/dist/entities/security-scheme.test.js.map +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +7 -0
- package/dist/legacy/index.d.ts +1 -1
- package/dist/legacy/index.d.ts.map +1 -1
- package/dist/legacy/index.js +2 -1
- package/dist/legacy/index.js.map +7 -0
- package/dist/legacy/reference-config.d.ts +2 -2
- package/dist/legacy/reference-config.d.ts.map +1 -1
- package/dist/legacy/reference-config.js +10 -8
- package/dist/legacy/reference-config.js.map +7 -0
- package/dist/snippetz/index.d.ts +1 -1
- package/dist/snippetz/index.d.ts.map +1 -1
- package/dist/snippetz/index.js +2 -1
- package/dist/snippetz/index.js.map +7 -0
- package/dist/snippetz/snippetz.js +39 -40
- package/dist/snippetz/snippetz.js.map +7 -0
- package/dist/snippetz/snippetz.test-d.js +28 -0
- package/dist/snippetz/snippetz.test-d.js.map +7 -0
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +5 -1
- package/dist/utils/index.js.map +7 -0
- package/dist/utils/nanoid.js +7 -11
- package/dist/utils/nanoid.js.map +7 -0
- package/dist/utils/nanoid.test.js +29 -0
- package/dist/utils/nanoid.test.js.map +7 -0
- package/dist/utils/utility-types.js +1 -0
- package/dist/utils/utility-types.js.map +7 -0
- package/package.json +5 -9
- package/dist/api-reference/helpers/migrate-theme-variables.d.ts +0 -10
- package/dist/api-reference/helpers/migrate-theme-variables.d.ts.map +0 -1
- package/dist/api-reference/helpers/migrate-theme-variables.js +0 -22
|
@@ -1,217 +1,209 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { ApiReferencePluginSchema } from
|
|
3
|
-
import { migrateThemeVariables } from './helpers/migrate-theme-variables.js';
|
|
4
|
-
|
|
5
|
-
/** Available theme presets for the API reference */
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ApiReferencePluginSchema } from "./api-reference-plugin.js";
|
|
6
3
|
const themeIdEnum = z.enum([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
"alternate",
|
|
5
|
+
"default",
|
|
6
|
+
"moon",
|
|
7
|
+
"purple",
|
|
8
|
+
"solarized",
|
|
9
|
+
"bluePlanet",
|
|
10
|
+
"deepSpace",
|
|
11
|
+
"saturn",
|
|
12
|
+
"kepler",
|
|
13
|
+
"elysiajs",
|
|
14
|
+
"fastify",
|
|
15
|
+
"mars",
|
|
16
|
+
"laserwave",
|
|
17
|
+
"none"
|
|
21
18
|
]);
|
|
22
|
-
/** Valid keys that can be used with CTRL/CMD to open the search modal */
|
|
23
19
|
const searchHotKeyEnum = z.enum([
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
20
|
+
"a",
|
|
21
|
+
"b",
|
|
22
|
+
"c",
|
|
23
|
+
"d",
|
|
24
|
+
"e",
|
|
25
|
+
"f",
|
|
26
|
+
"g",
|
|
27
|
+
"h",
|
|
28
|
+
"i",
|
|
29
|
+
"j",
|
|
30
|
+
"k",
|
|
31
|
+
"l",
|
|
32
|
+
"m",
|
|
33
|
+
"n",
|
|
34
|
+
"o",
|
|
35
|
+
"p",
|
|
36
|
+
"q",
|
|
37
|
+
"r",
|
|
38
|
+
"s",
|
|
39
|
+
"t",
|
|
40
|
+
"u",
|
|
41
|
+
"v",
|
|
42
|
+
"w",
|
|
43
|
+
"x",
|
|
44
|
+
"y",
|
|
45
|
+
"z"
|
|
50
46
|
]);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'vue',
|
|
75
|
-
])
|
|
76
|
-
.nullable();
|
|
77
|
-
/** Configuration for the OpenAPI/Swagger specification */
|
|
47
|
+
const integrationEnum = z.enum([
|
|
48
|
+
"adonisjs",
|
|
49
|
+
"docusaurus",
|
|
50
|
+
"dotnet",
|
|
51
|
+
"elysiajs",
|
|
52
|
+
"express",
|
|
53
|
+
"fastapi",
|
|
54
|
+
"fastify",
|
|
55
|
+
"go",
|
|
56
|
+
"hono",
|
|
57
|
+
"html",
|
|
58
|
+
"laravel",
|
|
59
|
+
"litestar",
|
|
60
|
+
"nestjs",
|
|
61
|
+
"nextjs",
|
|
62
|
+
"nitro",
|
|
63
|
+
"nuxt",
|
|
64
|
+
"platformatic",
|
|
65
|
+
"react",
|
|
66
|
+
"rust",
|
|
67
|
+
"svelte",
|
|
68
|
+
"vue"
|
|
69
|
+
]).nullable();
|
|
78
70
|
const specConfigurationSchema = z.object({
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
71
|
+
/**
|
|
72
|
+
* URL to an OpenAPI/Swagger document
|
|
73
|
+
*
|
|
74
|
+
* @deprecated Please move `url` to the top level and remove the `spec` prefix.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const oldConfiguration = {
|
|
79
|
+
* spec: {
|
|
80
|
+
* url: 'https://example.com/openapi.json',
|
|
81
|
+
* },
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* const newConfiguration = {
|
|
85
|
+
* url: 'https://example.com/openapi.json',
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
**/
|
|
89
|
+
url: z.string().optional(),
|
|
90
|
+
/**
|
|
91
|
+
* Directly embed the OpenAPI document.
|
|
92
|
+
* Can be a string, object, function returning an object, or null.
|
|
93
|
+
*
|
|
94
|
+
* @remarks It's recommended to pass a URL instead of content.
|
|
95
|
+
*
|
|
96
|
+
* @deprecated Please move `content` to the top level and remove the `spec` prefix.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const oldConfiguration = {
|
|
101
|
+
* spec: {
|
|
102
|
+
* content: '…',
|
|
103
|
+
* },
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* const newConfiguration = {
|
|
107
|
+
* content: '…',
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
**/
|
|
111
|
+
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
112
|
+
/**
|
|
113
|
+
* The title of the OpenAPI document.
|
|
114
|
+
*
|
|
115
|
+
* @example 'Scalar Galaxy'
|
|
116
|
+
*
|
|
117
|
+
* @deprecated Please move `title` to the top level and remove the `spec` prefix.
|
|
118
|
+
*/
|
|
119
|
+
title: z.string().optional(),
|
|
120
|
+
/**
|
|
121
|
+
* The slug of the OpenAPI document used in the URL.
|
|
122
|
+
*
|
|
123
|
+
* If none is passed, the title will be used.
|
|
124
|
+
*
|
|
125
|
+
* If no title is used, it'll just use the index.
|
|
126
|
+
*
|
|
127
|
+
* @example 'scalar-galaxy'
|
|
128
|
+
*
|
|
129
|
+
* @deprecated Please move `slug` to the top level and remove the `spec` prefix.
|
|
130
|
+
*/
|
|
131
|
+
slug: z.string().optional()
|
|
140
132
|
});
|
|
141
|
-
/** Configuration for path-based routing */
|
|
142
133
|
const pathRoutingSchema = z.object({
|
|
143
|
-
|
|
144
|
-
|
|
134
|
+
/** Base path for the API reference */
|
|
135
|
+
basePath: z.string()
|
|
145
136
|
});
|
|
146
|
-
/** Configuration for the Api Client */
|
|
147
137
|
const apiClientConfigurationSchema = z.object({
|
|
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
|
-
|
|
138
|
+
/**
|
|
139
|
+
* URL to an OpenAPI/Swagger document
|
|
140
|
+
**/
|
|
141
|
+
url: z.string().optional(),
|
|
142
|
+
/**
|
|
143
|
+
* Directly embed the OpenAPI document.
|
|
144
|
+
* Can be a string, object, function returning an object, or null.
|
|
145
|
+
*
|
|
146
|
+
* @remarks It's recommended to pass a URL instead of content.
|
|
147
|
+
**/
|
|
148
|
+
content: z.union([z.string(), z.record(z.any()), z.function().returns(z.record(z.any())), z.null()]).optional(),
|
|
149
|
+
/**
|
|
150
|
+
* The title of the OpenAPI document.
|
|
151
|
+
*
|
|
152
|
+
* @example 'Scalar Galaxy'
|
|
153
|
+
*/
|
|
154
|
+
title: z.string().optional(),
|
|
155
|
+
/**
|
|
156
|
+
* The slug of the OpenAPI document used in the URL.
|
|
157
|
+
*
|
|
158
|
+
* If none is passed, the title will be used.
|
|
159
|
+
*
|
|
160
|
+
* If no title is used, it'll just use the index.
|
|
161
|
+
*
|
|
162
|
+
* @example 'scalar-galaxy'
|
|
163
|
+
*/
|
|
164
|
+
slug: z.string().optional(),
|
|
165
|
+
/**
|
|
166
|
+
* The OpenAPI/Swagger document to render
|
|
167
|
+
*
|
|
168
|
+
* @deprecated Use `url` and `content` on the top level instead.
|
|
169
|
+
**/
|
|
170
|
+
spec: specConfigurationSchema.optional(),
|
|
171
|
+
/** Prefill authentication */
|
|
172
|
+
authentication: z.any().optional(),
|
|
173
|
+
// Temp until we bring in the new auth
|
|
174
|
+
/** Base URL for the API server */
|
|
175
|
+
baseServerURL: z.string().optional(),
|
|
176
|
+
/**
|
|
177
|
+
* Whether to hide the client button
|
|
178
|
+
* @default false
|
|
179
|
+
*/
|
|
180
|
+
hideClientButton: z.boolean().optional().default(false).catch(false),
|
|
181
|
+
/** URL to a request proxy for the API client */
|
|
182
|
+
proxyUrl: z.string().optional(),
|
|
183
|
+
/** Key used with CTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k) */
|
|
184
|
+
searchHotKey: searchHotKeyEnum.optional(),
|
|
185
|
+
/** List of OpenAPI server objects */
|
|
186
|
+
servers: z.array(z.any()).optional(),
|
|
187
|
+
// Using any for OpenAPIV3_1.ServerObject
|
|
188
|
+
/**
|
|
189
|
+
* Whether to show the sidebar
|
|
190
|
+
* @default true
|
|
191
|
+
*/
|
|
192
|
+
showSidebar: z.boolean().optional().default(true).catch(true),
|
|
193
|
+
/** A string to use one of the color presets */
|
|
194
|
+
theme: themeIdEnum.optional().default("default").catch("default"),
|
|
195
|
+
/** Integration type identifier */
|
|
196
|
+
_integration: integrationEnum.optional(),
|
|
197
|
+
/** onRequestSent is fired when a request is sent */
|
|
198
|
+
onRequestSent: z.function().args(z.string()).returns(z.void()).optional()
|
|
207
199
|
});
|
|
208
|
-
|
|
209
|
-
|
|
200
|
+
const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(
|
|
201
|
+
z.object({
|
|
210
202
|
/**
|
|
211
203
|
* The layout to use for the references
|
|
212
204
|
* @default 'modern'
|
|
213
205
|
*/
|
|
214
|
-
layout: z.enum([
|
|
206
|
+
layout: z.enum(["modern", "classic"]).optional().default("modern").catch("modern"),
|
|
215
207
|
/**
|
|
216
208
|
* URL to a request proxy for the API client
|
|
217
209
|
* @deprecated Use proxyUrl instead
|
|
@@ -254,7 +246,7 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
254
246
|
/** Whether dark mode is on or off initially (light mode) */
|
|
255
247
|
darkMode: z.boolean().optional(),
|
|
256
248
|
/** forceDarkModeState makes it always this state no matter what */
|
|
257
|
-
forceDarkModeState: z.enum([
|
|
249
|
+
forceDarkModeState: z.enum(["dark", "light"]).optional(),
|
|
258
250
|
/**
|
|
259
251
|
* Whether to show the dark mode toggle
|
|
260
252
|
* @default false
|
|
@@ -264,7 +256,8 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
264
256
|
* If used, passed data will be added to the HTML header
|
|
265
257
|
* @see https://unhead.unjs.io/usage/composables/use-seo-meta
|
|
266
258
|
*/
|
|
267
|
-
metaData: z.any().optional(),
|
|
259
|
+
metaData: z.any().optional(),
|
|
260
|
+
// Using any for UseSeoMetaInput since it's an external type
|
|
268
261
|
/**
|
|
269
262
|
* Path to a favicon image
|
|
270
263
|
* @default undefined
|
|
@@ -275,16 +268,12 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
275
268
|
* List of httpsnippet clients to hide from the clients menu
|
|
276
269
|
* By default hides Unirest, pass `[]` to show all clients
|
|
277
270
|
*/
|
|
278
|
-
hiddenClients: z
|
|
279
|
-
.union([z.record(z.union([z.boolean(), z.array(z.string())])), z.array(z.string()), z.literal(true)])
|
|
280
|
-
.optional(),
|
|
271
|
+
hiddenClients: z.union([z.record(z.union([z.boolean(), z.array(z.string())])), z.array(z.string()), z.literal(true)]).optional(),
|
|
281
272
|
/** Determine the HTTP client that's selected by default */
|
|
282
|
-
defaultHttpClient: z
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
})
|
|
287
|
-
.optional(),
|
|
273
|
+
defaultHttpClient: z.object({
|
|
274
|
+
targetKey: z.custom(),
|
|
275
|
+
clientKey: z.string()
|
|
276
|
+
}).optional(),
|
|
288
277
|
/** Custom CSS to be added to the page */
|
|
289
278
|
customCss: z.string().optional(),
|
|
290
279
|
/** onSpecUpdate is fired on spec/swagger content change */
|
|
@@ -318,69 +307,59 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
318
307
|
* @returns A string ID used to generate the URL hash
|
|
319
308
|
* @default (heading) => `#description/${heading.slug}`
|
|
320
309
|
*/
|
|
321
|
-
generateHeadingSlug: z
|
|
322
|
-
|
|
323
|
-
.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
.returns(z.string())
|
|
327
|
-
.optional(),
|
|
310
|
+
generateHeadingSlug: z.function().args(
|
|
311
|
+
z.object({
|
|
312
|
+
slug: z.string().default("headingSlug")
|
|
313
|
+
})
|
|
314
|
+
).returns(z.string()).optional(),
|
|
328
315
|
/**
|
|
329
316
|
* Customize the model portion of the hash
|
|
330
317
|
* @param model - The model object with a name property
|
|
331
318
|
* @returns A string ID used to generate the URL hash
|
|
332
319
|
* @default (model) => slug(model.name)
|
|
333
320
|
*/
|
|
334
|
-
generateModelSlug: z
|
|
335
|
-
|
|
336
|
-
.
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
.returns(z.string())
|
|
340
|
-
.optional(),
|
|
321
|
+
generateModelSlug: z.function().args(
|
|
322
|
+
z.object({
|
|
323
|
+
name: z.string().default("modelName")
|
|
324
|
+
})
|
|
325
|
+
).returns(z.string()).optional(),
|
|
341
326
|
/**
|
|
342
327
|
* Customize the tag portion of the hash
|
|
343
328
|
* @param tag - The tag object
|
|
344
329
|
* @returns A string ID used to generate the URL hash
|
|
345
330
|
* @default (tag) => slug(tag.name)
|
|
346
331
|
*/
|
|
347
|
-
generateTagSlug: z
|
|
348
|
-
|
|
349
|
-
.
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
.returns(z.string())
|
|
353
|
-
.optional(),
|
|
332
|
+
generateTagSlug: z.function().args(
|
|
333
|
+
z.object({
|
|
334
|
+
name: z.string().default("tagName")
|
|
335
|
+
})
|
|
336
|
+
).returns(z.string()).optional(),
|
|
354
337
|
/**
|
|
355
338
|
* Customize the operation portion of the hash
|
|
356
339
|
* @param operation - The operation object
|
|
357
340
|
* @returns A string ID used to generate the URL hash
|
|
358
341
|
* @default (operation) => `${operation.method}${operation.path}`
|
|
359
342
|
*/
|
|
360
|
-
generateOperationSlug: z
|
|
361
|
-
|
|
362
|
-
.args(z.object({
|
|
343
|
+
generateOperationSlug: z.function().args(
|
|
344
|
+
z.object({
|
|
363
345
|
path: z.string(),
|
|
364
346
|
operationId: z.string().optional(),
|
|
365
347
|
method: z.string(),
|
|
366
|
-
summary: z.string().optional()
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
.optional(),
|
|
348
|
+
summary: z.string().optional()
|
|
349
|
+
})
|
|
350
|
+
).returns(z.string()).optional(),
|
|
370
351
|
/**
|
|
371
352
|
* Customize the webhook portion of the hash
|
|
372
353
|
* @param webhook - The webhook object
|
|
373
354
|
* @returns A string ID used to generate the URL hash
|
|
374
355
|
* @default (webhook) => slug(webhook.name)
|
|
375
356
|
*/
|
|
376
|
-
generateWebhookSlug: z
|
|
377
|
-
|
|
378
|
-
.args(z.object({
|
|
357
|
+
generateWebhookSlug: z.function().args(
|
|
358
|
+
z.object({
|
|
379
359
|
name: z.string(),
|
|
380
|
-
method: z.string().optional()
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
.optional(),
|
|
360
|
+
method: z.string().optional()
|
|
361
|
+
})
|
|
362
|
+
).returns(z.string()).optional(),
|
|
384
363
|
/**
|
|
385
364
|
* To handle redirects, pass a function that will recieve:
|
|
386
365
|
* - The current path with hash if pathRouting is enabled
|
|
@@ -413,54 +392,57 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
413
392
|
* Function to sort tags
|
|
414
393
|
* @default 'alpha' for alphabetical sorting
|
|
415
394
|
*/
|
|
416
|
-
tagsSorter: z.union([z.literal(
|
|
395
|
+
tagsSorter: z.union([z.literal("alpha"), z.function().args(z.any(), z.any()).returns(z.number())]).optional(),
|
|
417
396
|
/**
|
|
418
397
|
* Function to sort operations
|
|
419
398
|
* @default 'alpha' for alphabetical sorting
|
|
420
399
|
*/
|
|
421
|
-
operationsSorter: z
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const
|
|
426
|
-
const NEW_PROXY_URL = 'https://proxy.scalar.com';
|
|
427
|
-
/** Migrate the configuration through a transform */
|
|
400
|
+
operationsSorter: z.union([z.literal("alpha"), z.literal("method"), z.function().args(z.any(), z.any()).returns(z.number())]).optional()
|
|
401
|
+
})
|
|
402
|
+
);
|
|
403
|
+
const OLD_PROXY_URL = "https://api.scalar.com/request-proxy";
|
|
404
|
+
const NEW_PROXY_URL = "https://proxy.scalar.com";
|
|
428
405
|
const migrateConfiguration = (_configuration) => {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
406
|
+
const configuration = { ..._configuration };
|
|
407
|
+
if (configuration.spec?.url) {
|
|
408
|
+
console.warn(
|
|
409
|
+
`[DEPRECATED] You're using the deprecated 'spec.url' attribute. Remove the spec prefix and move the 'url' attribute to the top level.`
|
|
410
|
+
);
|
|
411
|
+
configuration.url = configuration.spec.url;
|
|
412
|
+
delete configuration.spec;
|
|
413
|
+
}
|
|
414
|
+
if (configuration.spec?.content) {
|
|
415
|
+
console.warn(
|
|
416
|
+
`[DEPRECATED] You're using the deprecated 'spec.content' attribute. Remove the spec prefix and move the 'content' attribute to the top level.`
|
|
417
|
+
);
|
|
418
|
+
configuration.content = configuration.spec.content;
|
|
419
|
+
delete configuration.spec;
|
|
420
|
+
}
|
|
421
|
+
if (configuration.proxy) {
|
|
422
|
+
console.warn(
|
|
423
|
+
`[DEPRECATED] You're using the deprecated 'proxy' attribute, rename it to 'proxyUrl' or update the package.`
|
|
424
|
+
);
|
|
425
|
+
if (!configuration.proxyUrl) {
|
|
426
|
+
configuration.proxyUrl = configuration.proxy;
|
|
444
427
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
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`);
|
|
457
|
-
configuration.proxyUrl = NEW_PROXY_URL;
|
|
458
|
-
}
|
|
459
|
-
return configuration;
|
|
428
|
+
delete configuration.proxy;
|
|
429
|
+
}
|
|
430
|
+
if (configuration.proxyUrl === OLD_PROXY_URL) {
|
|
431
|
+
console.warn(`[DEPRECATED] Warning: configuration.proxyUrl points to our old proxy (${OLD_PROXY_URL}).`);
|
|
432
|
+
console.warn(`[DEPRECATED] We are overwriting the value and use the new proxy URL (${NEW_PROXY_URL}) instead.`);
|
|
433
|
+
console.warn(
|
|
434
|
+
`[DEPRECATED] Action Required: You should manually update your configuration to use the new URL (${NEW_PROXY_URL}). Read more: https://github.com/scalar/scalar`
|
|
435
|
+
);
|
|
436
|
+
configuration.proxyUrl = NEW_PROXY_URL;
|
|
437
|
+
}
|
|
438
|
+
return configuration;
|
|
460
439
|
};
|
|
461
|
-
/** Configuration for the Api Reference */
|
|
462
440
|
const apiReferenceConfigurationSchema = _apiReferenceConfigurationSchema.transform(migrateConfiguration);
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
441
|
+
const isConfigurationWithSources = (config) => Boolean(!Array.isArray(config) && config && "sources" in config && Array.isArray(config.sources));
|
|
442
|
+
export {
|
|
443
|
+
apiClientConfigurationSchema,
|
|
444
|
+
apiReferenceConfigurationSchema,
|
|
445
|
+
isConfigurationWithSources,
|
|
446
|
+
specConfigurationSchema
|
|
447
|
+
};
|
|
448
|
+
//# sourceMappingURL=api-reference-configuration.js.map
|