@scalar/types 0.1.13 → 0.1.15
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-reference-configuration.d.ts +41 -11
- package/dist/api-reference/api-reference-configuration.d.ts.map +1 -1
- package/dist/api-reference/api-reference-configuration.js +274 -290
- 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.d.ts +16 -2
- package/dist/api-reference/api-reference-plugin.d.ts.map +1 -1
- package/dist/api-reference/api-reference-plugin.js +28 -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.d.ts +104 -0
- package/dist/entities/security-scheme.d.ts.map +1 -1
- package/dist/entities/security-scheme.js +118 -157
- package/dist/entities/security-scheme.js.map +7 -0
- package/dist/entities/security-scheme.test.js +318 -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.d.ts +1 -1
- package/dist/snippetz/snippetz.d.ts.map +1 -1
- 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 +6 -10
- 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,211 @@
|
|
|
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(),
|
|
199
|
+
/** Whether to persist auth to local storage */
|
|
200
|
+
persistAuth: z.boolean().optional().default(false).catch(false)
|
|
207
201
|
});
|
|
208
|
-
|
|
209
|
-
|
|
202
|
+
const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(
|
|
203
|
+
z.object({
|
|
210
204
|
/**
|
|
211
205
|
* The layout to use for the references
|
|
212
206
|
* @default 'modern'
|
|
213
207
|
*/
|
|
214
|
-
layout: z.enum([
|
|
208
|
+
layout: z.enum(["modern", "classic"]).optional().default("modern").catch("modern"),
|
|
215
209
|
/**
|
|
216
210
|
* URL to a request proxy for the API client
|
|
217
211
|
* @deprecated Use proxyUrl instead
|
|
@@ -222,7 +216,7 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
222
216
|
*/
|
|
223
217
|
plugins: z.array(ApiReferencePluginSchema).optional(),
|
|
224
218
|
/**
|
|
225
|
-
*
|
|
219
|
+
* Allows the user to inject an editor for the spec
|
|
226
220
|
* @default false
|
|
227
221
|
*/
|
|
228
222
|
isEditable: z.boolean().optional().default(false).catch(false),
|
|
@@ -254,7 +248,7 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
254
248
|
/** Whether dark mode is on or off initially (light mode) */
|
|
255
249
|
darkMode: z.boolean().optional(),
|
|
256
250
|
/** forceDarkModeState makes it always this state no matter what */
|
|
257
|
-
forceDarkModeState: z.enum([
|
|
251
|
+
forceDarkModeState: z.enum(["dark", "light"]).optional(),
|
|
258
252
|
/**
|
|
259
253
|
* Whether to show the dark mode toggle
|
|
260
254
|
* @default false
|
|
@@ -264,7 +258,8 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
264
258
|
* If used, passed data will be added to the HTML header
|
|
265
259
|
* @see https://unhead.unjs.io/usage/composables/use-seo-meta
|
|
266
260
|
*/
|
|
267
|
-
metaData: z.any().optional(),
|
|
261
|
+
metaData: z.any().optional(),
|
|
262
|
+
// Using any for UseSeoMetaInput since it's an external type
|
|
268
263
|
/**
|
|
269
264
|
* Path to a favicon image
|
|
270
265
|
* @default undefined
|
|
@@ -275,16 +270,12 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
275
270
|
* List of httpsnippet clients to hide from the clients menu
|
|
276
271
|
* By default hides Unirest, pass `[]` to show all clients
|
|
277
272
|
*/
|
|
278
|
-
hiddenClients: z
|
|
279
|
-
.union([z.record(z.union([z.boolean(), z.array(z.string())])), z.array(z.string()), z.literal(true)])
|
|
280
|
-
.optional(),
|
|
273
|
+
hiddenClients: z.union([z.record(z.union([z.boolean(), z.array(z.string())])), z.array(z.string()), z.literal(true)]).optional(),
|
|
281
274
|
/** Determine the HTTP client that's selected by default */
|
|
282
|
-
defaultHttpClient: z
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
})
|
|
287
|
-
.optional(),
|
|
275
|
+
defaultHttpClient: z.object({
|
|
276
|
+
targetKey: z.custom(),
|
|
277
|
+
clientKey: z.string()
|
|
278
|
+
}).optional(),
|
|
288
279
|
/** Custom CSS to be added to the page */
|
|
289
280
|
customCss: z.string().optional(),
|
|
290
281
|
/** onSpecUpdate is fired on spec/swagger content change */
|
|
@@ -318,69 +309,59 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
318
309
|
* @returns A string ID used to generate the URL hash
|
|
319
310
|
* @default (heading) => `#description/${heading.slug}`
|
|
320
311
|
*/
|
|
321
|
-
generateHeadingSlug: z
|
|
322
|
-
|
|
323
|
-
.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
.returns(z.string())
|
|
327
|
-
.optional(),
|
|
312
|
+
generateHeadingSlug: z.function().args(
|
|
313
|
+
z.object({
|
|
314
|
+
slug: z.string().default("headingSlug")
|
|
315
|
+
})
|
|
316
|
+
).returns(z.string()).optional(),
|
|
328
317
|
/**
|
|
329
318
|
* Customize the model portion of the hash
|
|
330
319
|
* @param model - The model object with a name property
|
|
331
320
|
* @returns A string ID used to generate the URL hash
|
|
332
321
|
* @default (model) => slug(model.name)
|
|
333
322
|
*/
|
|
334
|
-
generateModelSlug: z
|
|
335
|
-
|
|
336
|
-
.
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
.returns(z.string())
|
|
340
|
-
.optional(),
|
|
323
|
+
generateModelSlug: z.function().args(
|
|
324
|
+
z.object({
|
|
325
|
+
name: z.string().default("modelName")
|
|
326
|
+
})
|
|
327
|
+
).returns(z.string()).optional(),
|
|
341
328
|
/**
|
|
342
329
|
* Customize the tag portion of the hash
|
|
343
330
|
* @param tag - The tag object
|
|
344
331
|
* @returns A string ID used to generate the URL hash
|
|
345
332
|
* @default (tag) => slug(tag.name)
|
|
346
333
|
*/
|
|
347
|
-
generateTagSlug: z
|
|
348
|
-
|
|
349
|
-
.
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
.returns(z.string())
|
|
353
|
-
.optional(),
|
|
334
|
+
generateTagSlug: z.function().args(
|
|
335
|
+
z.object({
|
|
336
|
+
name: z.string().default("tagName")
|
|
337
|
+
})
|
|
338
|
+
).returns(z.string()).optional(),
|
|
354
339
|
/**
|
|
355
340
|
* Customize the operation portion of the hash
|
|
356
341
|
* @param operation - The operation object
|
|
357
342
|
* @returns A string ID used to generate the URL hash
|
|
358
343
|
* @default (operation) => `${operation.method}${operation.path}`
|
|
359
344
|
*/
|
|
360
|
-
generateOperationSlug: z
|
|
361
|
-
|
|
362
|
-
.args(z.object({
|
|
345
|
+
generateOperationSlug: z.function().args(
|
|
346
|
+
z.object({
|
|
363
347
|
path: z.string(),
|
|
364
348
|
operationId: z.string().optional(),
|
|
365
349
|
method: z.string(),
|
|
366
|
-
summary: z.string().optional()
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
.optional(),
|
|
350
|
+
summary: z.string().optional()
|
|
351
|
+
})
|
|
352
|
+
).returns(z.string()).optional(),
|
|
370
353
|
/**
|
|
371
354
|
* Customize the webhook portion of the hash
|
|
372
355
|
* @param webhook - The webhook object
|
|
373
356
|
* @returns A string ID used to generate the URL hash
|
|
374
357
|
* @default (webhook) => slug(webhook.name)
|
|
375
358
|
*/
|
|
376
|
-
generateWebhookSlug: z
|
|
377
|
-
|
|
378
|
-
.args(z.object({
|
|
359
|
+
generateWebhookSlug: z.function().args(
|
|
360
|
+
z.object({
|
|
379
361
|
name: z.string(),
|
|
380
|
-
method: z.string().optional()
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
.optional(),
|
|
362
|
+
method: z.string().optional()
|
|
363
|
+
})
|
|
364
|
+
).returns(z.string()).optional(),
|
|
384
365
|
/**
|
|
385
366
|
* To handle redirects, pass a function that will recieve:
|
|
386
367
|
* - The current path with hash if pathRouting is enabled
|
|
@@ -413,54 +394,57 @@ const _apiReferenceConfigurationSchema = apiClientConfigurationSchema.merge(z.ob
|
|
|
413
394
|
* Function to sort tags
|
|
414
395
|
* @default 'alpha' for alphabetical sorting
|
|
415
396
|
*/
|
|
416
|
-
tagsSorter: z.union([z.literal(
|
|
397
|
+
tagsSorter: z.union([z.literal("alpha"), z.function().args(z.any(), z.any()).returns(z.number())]).optional(),
|
|
417
398
|
/**
|
|
418
399
|
* Function to sort operations
|
|
419
400
|
* @default 'alpha' for alphabetical sorting
|
|
420
401
|
*/
|
|
421
|
-
operationsSorter: z
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const
|
|
426
|
-
const NEW_PROXY_URL = 'https://proxy.scalar.com';
|
|
427
|
-
/** Migrate the configuration through a transform */
|
|
402
|
+
operationsSorter: z.union([z.literal("alpha"), z.literal("method"), z.function().args(z.any(), z.any()).returns(z.number())]).optional()
|
|
403
|
+
})
|
|
404
|
+
);
|
|
405
|
+
const OLD_PROXY_URL = "https://api.scalar.com/request-proxy";
|
|
406
|
+
const NEW_PROXY_URL = "https://proxy.scalar.com";
|
|
428
407
|
const migrateConfiguration = (_configuration) => {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
408
|
+
const configuration = { ..._configuration };
|
|
409
|
+
if (configuration.spec?.url) {
|
|
410
|
+
console.warn(
|
|
411
|
+
`[DEPRECATED] You're using the deprecated 'spec.url' attribute. Remove the spec prefix and move the 'url' attribute to the top level.`
|
|
412
|
+
);
|
|
413
|
+
configuration.url = configuration.spec.url;
|
|
414
|
+
delete configuration.spec;
|
|
415
|
+
}
|
|
416
|
+
if (configuration.spec?.content) {
|
|
417
|
+
console.warn(
|
|
418
|
+
`[DEPRECATED] You're using the deprecated 'spec.content' attribute. Remove the spec prefix and move the 'content' attribute to the top level.`
|
|
419
|
+
);
|
|
420
|
+
configuration.content = configuration.spec.content;
|
|
421
|
+
delete configuration.spec;
|
|
422
|
+
}
|
|
423
|
+
if (configuration.proxy) {
|
|
424
|
+
console.warn(
|
|
425
|
+
`[DEPRECATED] You're using the deprecated 'proxy' attribute, rename it to 'proxyUrl' or update the package.`
|
|
426
|
+
);
|
|
427
|
+
if (!configuration.proxyUrl) {
|
|
428
|
+
configuration.proxyUrl = configuration.proxy;
|
|
444
429
|
}
|
|
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;
|
|
430
|
+
delete configuration.proxy;
|
|
431
|
+
}
|
|
432
|
+
if (configuration.proxyUrl === OLD_PROXY_URL) {
|
|
433
|
+
console.warn(`[DEPRECATED] Warning: configuration.proxyUrl points to our old proxy (${OLD_PROXY_URL}).`);
|
|
434
|
+
console.warn(`[DEPRECATED] We are overwriting the value and use the new proxy URL (${NEW_PROXY_URL}) instead.`);
|
|
435
|
+
console.warn(
|
|
436
|
+
`[DEPRECATED] Action Required: You should manually update your configuration to use the new URL (${NEW_PROXY_URL}). Read more: https://github.com/scalar/scalar`
|
|
437
|
+
);
|
|
438
|
+
configuration.proxyUrl = NEW_PROXY_URL;
|
|
439
|
+
}
|
|
440
|
+
return configuration;
|
|
460
441
|
};
|
|
461
|
-
/** Configuration for the Api Reference */
|
|
462
442
|
const apiReferenceConfigurationSchema = _apiReferenceConfigurationSchema.transform(migrateConfiguration);
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
443
|
+
const isConfigurationWithSources = (config) => Boolean(!Array.isArray(config) && config && "sources" in config && Array.isArray(config.sources));
|
|
444
|
+
export {
|
|
445
|
+
apiClientConfigurationSchema,
|
|
446
|
+
apiReferenceConfigurationSchema,
|
|
447
|
+
isConfigurationWithSources,
|
|
448
|
+
specConfigurationSchema
|
|
449
|
+
};
|
|
450
|
+
//# sourceMappingURL=api-reference-configuration.js.map
|