@scalar/oas-utils 0.2.75 → 0.2.76
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 +7 -0
- package/dist/entities/spec/collection.d.ts +292 -0
- package/dist/entities/spec/collection.d.ts.map +1 -1
- package/dist/entities/spec/collection.js +11 -1
- package/dist/entities/spec/index.js +2 -2
- package/dist/entities/spec/parameters.d.ts +2 -2
- package/dist/entities/spec/request-examples.d.ts +228 -70
- package/dist/entities/spec/request-examples.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.js +156 -4
- package/dist/entities/spec/requests.d.ts +205 -11
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/requests.js +16 -11
- package/dist/entities/spec/server.d.ts +2 -2
- package/dist/entities/spec/server.d.ts.map +1 -1
- package/dist/entities/spec/spec-objects.d.ts +20 -10
- package/dist/entities/spec/spec-objects.d.ts.map +1 -1
- package/dist/entities/spec/spec-objects.js +6 -1
- package/dist/entities/spec/x-scalar-environments.d.ts +74 -0
- package/dist/entities/spec/x-scalar-environments.d.ts.map +1 -0
- package/dist/entities/spec/x-scalar-environments.js +23 -0
- package/dist/entities/spec/x-scalar-secrets.d.ts +23 -0
- package/dist/entities/spec/x-scalar-secrets.d.ts.map +1 -0
- package/dist/entities/spec/x-scalar-secrets.js +9 -0
- package/dist/migrations/v-2.1.0/migration.d.ts +1 -1
- package/dist/spec-getters/getExampleFromSchema.d.ts +1 -0
- package/dist/spec-getters/getExampleFromSchema.d.ts.map +1 -1
- package/dist/spec-getters/getRequestBodyFromOperation.d.ts +1 -1
- package/dist/spec-getters/getRequestBodyFromOperation.d.ts.map +1 -1
- package/dist/spec-getters/getRequestBodyFromOperation.js +2 -5
- package/dist/spec-getters/getRequestFromOperation.d.ts +1 -1
- package/dist/spec-getters/getRequestFromOperation.d.ts.map +1 -1
- package/dist/spec-getters/getRequestFromOperation.js +2 -2
- package/dist/transforms/export-spec.d.ts +14 -71
- package/dist/transforms/export-spec.d.ts.map +1 -1
- package/dist/transforms/export-spec.js +73 -0
- package/dist/transforms/import-spec.js +1 -1
- package/dist/transforms/index.d.ts +1 -0
- package/dist/transforms/index.d.ts.map +1 -1
- package/dist/transforms/index.js +1 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,KAAK,SAAS,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvC;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,EAc9B,SAAS,CACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,MAAM,CAAC,GAAG;IAC/C,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;CAC7B,CACF,CAAA;AAED,eAAO,MAAM,eAAe;IAC1B;;;;OAIG;;IAEH;;;OAGG;;IAEH,oHAAoH;;eAhB3G,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;;eAArB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;;;;;;eAArB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,KAAK,SAAS,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvC;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,EAc9B,SAAS,CACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,MAAM,CAAC,GAAG;IAC/C,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;CAC7B,CACF,CAAA;AAED,eAAO,MAAM,eAAe;IAC1B;;;;OAIG;;IAEH;;;OAGG;;IAEH,oHAAoH;;eAhB3G,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;;eAArB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;;;;;;eAArB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;;;;;eAArB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;;;EAkBgB,CAAA;AAEhD,eAAO,MAAM,YAAY;IAfvB;;;;OAIG;;IAEH;;;OAGG;;IAEH,oHAAoH;;eAhB3G,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;;eAArB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;;;;;;;;;eAArB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;;;;;;eAArB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;;;EAsB9B,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AACjD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
|
|
@@ -170,6 +170,11 @@ export declare const xScalarNestedSchema: z.ZodArray<z.ZodObject<{
|
|
|
170
170
|
* @see https://spec.openapis.org/oas/latest.html#tag-object
|
|
171
171
|
*/
|
|
172
172
|
export declare const oasTagSchema: z.ZodObject<{
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated
|
|
175
|
+
*
|
|
176
|
+
* Needs to be remove as it is not a spec property
|
|
177
|
+
*/
|
|
173
178
|
type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"tag">>>;
|
|
174
179
|
/** REQUIRED. The name of the tag. */
|
|
175
180
|
name: z.ZodString;
|
|
@@ -188,24 +193,24 @@ export declare const oasTagSchema: z.ZodObject<{
|
|
|
188
193
|
description?: string | undefined;
|
|
189
194
|
url?: string | undefined;
|
|
190
195
|
}>>;
|
|
191
|
-
'x-scalar-children': z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
196
|
+
'x-scalar-children': z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
192
197
|
tagName: z.ZodString;
|
|
193
198
|
}, "strip", z.ZodTypeAny, {
|
|
194
199
|
tagName: string;
|
|
195
200
|
}, {
|
|
196
201
|
tagName: string;
|
|
197
|
-
}>, "many"
|
|
202
|
+
}>, "many">>>;
|
|
198
203
|
}, "strip", z.ZodTypeAny, {
|
|
199
204
|
type: "tag";
|
|
200
205
|
name: string;
|
|
201
|
-
'x-scalar-children': {
|
|
202
|
-
tagName: string;
|
|
203
|
-
}[];
|
|
204
206
|
description?: string | undefined;
|
|
205
207
|
externalDocs?: {
|
|
206
208
|
url: string;
|
|
207
209
|
description?: string | undefined;
|
|
208
210
|
} | undefined;
|
|
211
|
+
'x-scalar-children'?: {
|
|
212
|
+
tagName: string;
|
|
213
|
+
}[] | undefined;
|
|
209
214
|
}, {
|
|
210
215
|
name: string;
|
|
211
216
|
type?: "tag" | undefined;
|
|
@@ -219,6 +224,11 @@ export declare const oasTagSchema: z.ZodObject<{
|
|
|
219
224
|
}[] | undefined;
|
|
220
225
|
}>;
|
|
221
226
|
export declare const tagSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
227
|
+
/**
|
|
228
|
+
* @deprecated
|
|
229
|
+
*
|
|
230
|
+
* Needs to be remove as it is not a spec property
|
|
231
|
+
*/
|
|
222
232
|
type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"tag">>>;
|
|
223
233
|
/** REQUIRED. The name of the tag. */
|
|
224
234
|
name: z.ZodString;
|
|
@@ -237,13 +247,13 @@ export declare const tagSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
237
247
|
description?: string | undefined;
|
|
238
248
|
url?: string | undefined;
|
|
239
249
|
}>>;
|
|
240
|
-
'x-scalar-children': z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
250
|
+
'x-scalar-children': z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
241
251
|
tagName: z.ZodString;
|
|
242
252
|
}, "strip", z.ZodTypeAny, {
|
|
243
253
|
tagName: string;
|
|
244
254
|
}, {
|
|
245
255
|
tagName: string;
|
|
246
|
-
}>, "many"
|
|
256
|
+
}>, "many">>>;
|
|
247
257
|
}, {
|
|
248
258
|
uid: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
249
259
|
children: z.ZodDefault<z.ZodArray<z.ZodDefault<z.ZodOptional<z.ZodString>>, "many">>;
|
|
@@ -251,15 +261,15 @@ export declare const tagSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
251
261
|
type: "tag";
|
|
252
262
|
uid: string;
|
|
253
263
|
name: string;
|
|
254
|
-
'x-scalar-children': {
|
|
255
|
-
tagName: string;
|
|
256
|
-
}[];
|
|
257
264
|
children: string[];
|
|
258
265
|
description?: string | undefined;
|
|
259
266
|
externalDocs?: {
|
|
260
267
|
url: string;
|
|
261
268
|
description?: string | undefined;
|
|
262
269
|
} | undefined;
|
|
270
|
+
'x-scalar-children'?: {
|
|
271
|
+
tagName: string;
|
|
272
|
+
}[] | undefined;
|
|
263
273
|
}, {
|
|
264
274
|
name: string;
|
|
265
275
|
type?: "tag" | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-objects.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/spec-objects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;IAC3B,mDAAmD;;IAEnD,2GAA2G;;IAE3G;;;OAGG;;;;;;;;;;EAEH,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;IAC3B,+DAA+D;;IAE/D,sFAAsF;;IAEtF,0GAA0G;;;;;;;;;;EAE1G,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;IACxB,sCAAsC;;IAEtC,kCAAkC;;IAElC,4FAA4F;;IAE5F,oFAAoF;;IAEpF,mDAAmD;;QAxBnD,+DAA+D;;QAE/D,sFAAsF;;QAEtF,0GAA0G;;;;;;;;;;;IAsB1G,mDAAmD;;QA5CnD,mDAAmD;;QAEnD,2GAA2G;;QAE3G;;;WAGG;;;;;;;;;;;IAuCH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEH,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B;IACzC,6GAA6G;;IAE7G,yFAAyF;;;;;;;;EAEzF,CAAA;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CACzC,OAAO,8BAA8B,CACtC,CAAA;AAED,eAAO,MAAM,mBAAmB;;;;;;WAItB,CAAA;AAEV;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;;
|
|
1
|
+
{"version":3,"file":"spec-objects.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/spec-objects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;IAC3B,mDAAmD;;IAEnD,2GAA2G;;IAE3G;;;OAGG;;;;;;;;;;EAEH,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;IAC3B,+DAA+D;;IAE/D,sFAAsF;;IAEtF,0GAA0G;;;;;;;;;;EAE1G,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;IACxB,sCAAsC;;IAEtC,kCAAkC;;IAElC,4FAA4F;;IAE5F,oFAAoF;;IAEpF,mDAAmD;;QAxBnD,+DAA+D;;QAE/D,sFAAsF;;QAEtF,0GAA0G;;;;;;;;;;;IAsB1G,mDAAmD;;QA5CnD,mDAAmD;;QAEnD,2GAA2G;;QAE3G;;;WAGG;;;;;;;;;;;IAuCH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEH,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B;IACzC,6GAA6G;;IAE7G,yFAAyF;;;;;;;;EAEzF,CAAA;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CACzC,OAAO,8BAA8B,CACtC,CAAA;AAED,eAAO,MAAM,mBAAmB;;;;;;WAItB,CAAA;AAEV;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;IACvB;;;;OAIG;;IAEH,qCAAqC;;IAErC,6FAA6F;;IAE7F,sDAAsD;;QAjCtD,6GAA6G;;QAE7G,yFAAyF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCzF,CAAA;AAEF,eAAO,MAAM,SAAS;IAfpB;;;;OAIG;;IAEH,qCAAqC;;IAErC,6FAA6F;;IAE7F,sDAAsD;;QAjCtD,6GAA6G;;QAE7G,yFAAyF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCzF,CAAA;AAEF,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAC3C,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA"}
|
|
@@ -82,6 +82,11 @@ const xScalarNestedSchema = z
|
|
|
82
82
|
* @see https://spec.openapis.org/oas/latest.html#tag-object
|
|
83
83
|
*/
|
|
84
84
|
const oasTagSchema = z.object({
|
|
85
|
+
/**
|
|
86
|
+
* @deprecated
|
|
87
|
+
*
|
|
88
|
+
* Needs to be remove as it is not a spec property
|
|
89
|
+
*/
|
|
85
90
|
'type': z.literal('tag').optional().default('tag'),
|
|
86
91
|
/** REQUIRED. The name of the tag. */
|
|
87
92
|
'name': z.string(),
|
|
@@ -89,7 +94,7 @@ const oasTagSchema = z.object({
|
|
|
89
94
|
'description': z.string().optional(),
|
|
90
95
|
/** Additional external documentation for this tag. */
|
|
91
96
|
'externalDocs': oasExternalDocumentationSchema.optional(),
|
|
92
|
-
'x-scalar-children': xScalarNestedSchema.default([]),
|
|
97
|
+
'x-scalar-children': xScalarNestedSchema.default([]).optional(),
|
|
93
98
|
});
|
|
94
99
|
const tagSchema = oasTagSchema.extend({
|
|
95
100
|
uid: nanoidSchema,
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export type XScalarEnvVar = z.infer<typeof xScalarEnvVarSchema>;
|
|
3
|
+
export declare const xScalarEnvVarSchema: z.ZodUnion<[z.ZodObject<{
|
|
4
|
+
description: z.ZodOptional<z.ZodString>;
|
|
5
|
+
default: z.ZodDefault<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
default: string;
|
|
8
|
+
description?: string | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
default?: string | undefined;
|
|
11
|
+
description?: string | undefined;
|
|
12
|
+
}>, z.ZodString]>;
|
|
13
|
+
export declare const xScalarEnvironmentSchema: z.ZodObject<{
|
|
14
|
+
description: z.ZodOptional<z.ZodString>;
|
|
15
|
+
color: z.ZodOptional<z.ZodString>;
|
|
16
|
+
/** A map of variables by name */
|
|
17
|
+
variables: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
18
|
+
description: z.ZodOptional<z.ZodString>;
|
|
19
|
+
default: z.ZodDefault<z.ZodString>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
default: string;
|
|
22
|
+
description?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
default?: string | undefined;
|
|
25
|
+
description?: string | undefined;
|
|
26
|
+
}>, z.ZodString]>>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
variables: Record<string, string | {
|
|
29
|
+
default: string;
|
|
30
|
+
description?: string | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
description?: string | undefined;
|
|
33
|
+
color?: string | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
variables: Record<string, string | {
|
|
36
|
+
default?: string | undefined;
|
|
37
|
+
description?: string | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
description?: string | undefined;
|
|
40
|
+
color?: string | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
/** A map of environments by name */
|
|
43
|
+
export declare const xScalarEnvironmentsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
44
|
+
description: z.ZodOptional<z.ZodString>;
|
|
45
|
+
color: z.ZodOptional<z.ZodString>;
|
|
46
|
+
/** A map of variables by name */
|
|
47
|
+
variables: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
48
|
+
description: z.ZodOptional<z.ZodString>;
|
|
49
|
+
default: z.ZodDefault<z.ZodString>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
default: string;
|
|
52
|
+
description?: string | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
default?: string | undefined;
|
|
55
|
+
description?: string | undefined;
|
|
56
|
+
}>, z.ZodString]>>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
variables: Record<string, string | {
|
|
59
|
+
default: string;
|
|
60
|
+
description?: string | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
description?: string | undefined;
|
|
63
|
+
color?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
variables: Record<string, string | {
|
|
66
|
+
default?: string | undefined;
|
|
67
|
+
description?: string | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
description?: string | undefined;
|
|
70
|
+
color?: string | undefined;
|
|
71
|
+
}>>;
|
|
72
|
+
export type XScalarEnvironment = z.infer<typeof xScalarEnvironmentSchema>;
|
|
73
|
+
export type XScalarEnvironments = z.infer<typeof xScalarEnvironmentsSchema>;
|
|
74
|
+
//# sourceMappingURL=x-scalar-environments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x-scalar-environments.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/x-scalar-environments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D,eAAO,MAAM,mBAAmB;;;;;;;;;iBAM9B,CAAA;AAEF,eAAO,MAAM,wBAAwB;;;IAGnC,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;EAEjC,CAAA;AAEF,oCAAoC;AACpC,eAAO,MAAM,yBAAyB;;;IALpC,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;GAUlC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AACzE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const xScalarEnvVarSchema = z.union([
|
|
4
|
+
z.object({
|
|
5
|
+
description: z.string().optional(),
|
|
6
|
+
default: z.string().default(''),
|
|
7
|
+
}),
|
|
8
|
+
z.string(),
|
|
9
|
+
]);
|
|
10
|
+
const xScalarEnvironmentSchema = z.object({
|
|
11
|
+
description: z.string().optional(),
|
|
12
|
+
color: z.string().optional(),
|
|
13
|
+
/** A map of variables by name */
|
|
14
|
+
variables: z.record(z.string(), xScalarEnvVarSchema),
|
|
15
|
+
});
|
|
16
|
+
/** A map of environments by name */
|
|
17
|
+
const xScalarEnvironmentsSchema = z.record(
|
|
18
|
+
/** Name */
|
|
19
|
+
z.string(),
|
|
20
|
+
/** Environment definition */
|
|
21
|
+
xScalarEnvironmentSchema);
|
|
22
|
+
|
|
23
|
+
export { xScalarEnvVarSchema, xScalarEnvironmentSchema, xScalarEnvironmentsSchema };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const xScalarSecretVarSchema: z.ZodObject<{
|
|
3
|
+
description: z.ZodOptional<z.ZodString>;
|
|
4
|
+
example: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
description?: string | undefined;
|
|
7
|
+
example?: string | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
description?: string | undefined;
|
|
10
|
+
example?: string | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const xScalarSecretsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
13
|
+
description: z.ZodOptional<z.ZodString>;
|
|
14
|
+
example: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
example?: string | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
description?: string | undefined;
|
|
20
|
+
example?: string | undefined;
|
|
21
|
+
}>>;
|
|
22
|
+
export type XScalarSecrets = z.infer<typeof xScalarSecretsSchema>;
|
|
23
|
+
//# sourceMappingURL=x-scalar-secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x-scalar-secrets.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/x-scalar-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,sBAAsB;;;;;;;;;EAGjC,CAAA;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;GAA+C,CAAA;AAEhF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const xScalarSecretVarSchema = z.object({
|
|
4
|
+
description: z.string().optional(),
|
|
5
|
+
example: z.string().optional(),
|
|
6
|
+
});
|
|
7
|
+
const xScalarSecretsSchema = z.record(z.string(), xScalarSecretVarSchema);
|
|
8
|
+
|
|
9
|
+
export { xScalarSecretVarSchema, xScalarSecretsSchema };
|
|
@@ -200,10 +200,10 @@ export declare const migrate_v_2_1_0: (data: Omit<v_0_0_0.Data, "folders">) => {
|
|
|
200
200
|
in: "path" | "query" | "header" | "cookie";
|
|
201
201
|
deprecated: boolean;
|
|
202
202
|
description?: string | undefined;
|
|
203
|
+
example?: unknown;
|
|
203
204
|
schema?: unknown;
|
|
204
205
|
content?: unknown;
|
|
205
206
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
206
|
-
example?: unknown;
|
|
207
207
|
examples?: Record<string, {
|
|
208
208
|
value?: unknown;
|
|
209
209
|
summary?: string | undefined;
|
|
@@ -23,6 +23,7 @@ export declare const getExampleFromSchema: (schema: Record<string, any>, options
|
|
|
23
23
|
variables?: Record<string, any>;
|
|
24
24
|
/**
|
|
25
25
|
* Whether to omit empty and optional properties.
|
|
26
|
+
* @default false
|
|
26
27
|
*/
|
|
27
28
|
omitEmptyAndOptionalProperties?: boolean;
|
|
28
29
|
}, level?: number, parentSchema?: Record<string, any>, name?: string) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExampleFromSchema.d.ts","sourceRoot":"","sources":["../../src/spec-getters/getExampleFromSchema.ts"],"names":[],"mappings":"AAyDA;;GAEG;AACH,eAAO,MAAM,oBAAoB,WACvB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YACjB;IACR;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B
|
|
1
|
+
{"version":3,"file":"getExampleFromSchema.d.ts","sourceRoot":"","sources":["../../src/spec-getters/getExampleFromSchema.ts"],"names":[],"mappings":"AAyDA;;GAEG;AACH,eAAO,MAAM,oBAAoB,WACvB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YACjB;IACR;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAA;CACzC,UACM,MAAM,iBACE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,SAC3B,MAAM,KACZ,GAqTF,CAAA"}
|
|
@@ -3,7 +3,7 @@ declare const mimeTypes: readonly ["application/json", "application/octet-stream
|
|
|
3
3
|
/**
|
|
4
4
|
* Get the request body from the operation.
|
|
5
5
|
*/
|
|
6
|
-
export declare function getRequestBodyFromOperation(operation: Omit<TransformedOperation, 'httpVerb'>, selectedExampleKey?: string | number): {
|
|
6
|
+
export declare function getRequestBodyFromOperation(operation: Omit<TransformedOperation, 'httpVerb'>, selectedExampleKey?: string | number, omitEmptyAndOptionalProperties?: boolean): {
|
|
7
7
|
headers?: {
|
|
8
8
|
name: string;
|
|
9
9
|
value: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestBodyFromOperation.d.ts","sourceRoot":"","sources":["../../src/spec-getters/getRequestBodyFromOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAgC7E,QAAA,MAAM,SAAS,wJAOL,CAAA;AAEV;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,EACjD,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"getRequestBodyFromOperation.d.ts","sourceRoot":"","sources":["../../src/spec-getters/getRequestBodyFromOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAgC7E,QAAA,MAAM,SAAS,wJAOL,CAAA;AAEV;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,EACjD,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,EACpC,8BAA8B,CAAC,EAAE,OAAO,GACvC;IACD,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC3C,IAAI,CAAC,EAAE;QACL,QAAQ,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;QACpC,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE;YACP,IAAI,EAAE,MAAM,CAAA;YACZ,KAAK,CAAC,EAAE,MAAM,CAAA;SACf,EAAE,CAAA;KACJ,CAAA;CACF,GAAG,IAAI,CA6MP"}
|
|
@@ -29,7 +29,7 @@ const mimeTypes = [
|
|
|
29
29
|
/**
|
|
30
30
|
* Get the request body from the operation.
|
|
31
31
|
*/
|
|
32
|
-
function getRequestBodyFromOperation(operation, selectedExampleKey) {
|
|
32
|
+
function getRequestBodyFromOperation(operation, selectedExampleKey, omitEmptyAndOptionalProperties) {
|
|
33
33
|
// Get the content object from the operation
|
|
34
34
|
const originalContent = operation.information?.requestBody?.content;
|
|
35
35
|
const content = normalizeMimeTypeObject(originalContent);
|
|
@@ -127,7 +127,7 @@ function getRequestBodyFromOperation(operation, selectedExampleKey) {
|
|
|
127
127
|
const exampleFromSchema = requestBodyObject?.schema
|
|
128
128
|
? getExampleFromSchema(requestBodyObject?.schema, {
|
|
129
129
|
mode: 'write',
|
|
130
|
-
omitEmptyAndOptionalProperties:
|
|
130
|
+
omitEmptyAndOptionalProperties: omitEmptyAndOptionalProperties,
|
|
131
131
|
})
|
|
132
132
|
: null;
|
|
133
133
|
const body = example ?? exampleFromSchema;
|
|
@@ -145,7 +145,6 @@ function getRequestBodyFromOperation(operation, selectedExampleKey) {
|
|
|
145
145
|
? getExampleFromSchema(requestBodyObject?.schema, {
|
|
146
146
|
xml: true,
|
|
147
147
|
mode: 'write',
|
|
148
|
-
omitEmptyAndOptionalProperties: true,
|
|
149
148
|
})
|
|
150
149
|
: null;
|
|
151
150
|
return {
|
|
@@ -172,7 +171,6 @@ function getRequestBodyFromOperation(operation, selectedExampleKey) {
|
|
|
172
171
|
? getExampleFromSchema(requestBodyObject?.schema, {
|
|
173
172
|
xml: true,
|
|
174
173
|
mode: 'write',
|
|
175
|
-
omitEmptyAndOptionalProperties: true,
|
|
176
174
|
})
|
|
177
175
|
: null;
|
|
178
176
|
return {
|
|
@@ -190,7 +188,6 @@ function getRequestBodyFromOperation(operation, selectedExampleKey) {
|
|
|
190
188
|
? getExampleFromSchema(requestBodyObject?.schema, {
|
|
191
189
|
xml: true,
|
|
192
190
|
mode: 'write',
|
|
193
|
-
omitEmptyAndOptionalProperties: true,
|
|
194
191
|
})
|
|
195
192
|
: null;
|
|
196
193
|
return {
|
|
@@ -6,5 +6,5 @@ export declare const getRequestFromOperation: (operation: TransformedOperation,
|
|
|
6
6
|
*/
|
|
7
7
|
replaceVariables?: boolean;
|
|
8
8
|
requiredOnly?: boolean;
|
|
9
|
-
}, selectedExampleKey?: string | number) => Partial<HarRequestWithPath>;
|
|
9
|
+
}, selectedExampleKey?: string | number, omitEmptyAndOptionalProperties?: boolean) => Partial<HarRequestWithPath>;
|
|
10
10
|
//# sourceMappingURL=getRequestFromOperation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestFromOperation.d.ts","sourceRoot":"","sources":["../../src/spec-getters/getRequestFromOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAGlB,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAM7B,eAAO,MAAM,uBAAuB,cACvB,oBAAoB,YACrB;IACR;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,uBACoB,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"getRequestFromOperation.d.ts","sourceRoot":"","sources":["../../src/spec-getters/getRequestFromOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAGlB,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAM7B,eAAO,MAAM,uBAAuB,cACvB,oBAAoB,YACrB;IACR;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,uBACoB,MAAM,GAAG,MAAM,mCACH,OAAO,KACvC,OAAO,CAAC,kBAAkB,CAgE5B,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { getParametersFromOperation } from './getParametersFromOperation.js';
|
|
|
2
2
|
import { getRequestBodyFromOperation } from './getRequestBodyFromOperation.js';
|
|
3
3
|
import { REGEX } from '../helpers/regexHelpers.js';
|
|
4
4
|
|
|
5
|
-
const getRequestFromOperation = (operation, options, selectedExampleKey) => {
|
|
5
|
+
const getRequestFromOperation = (operation, options, selectedExampleKey, omitEmptyAndOptionalProperties) => {
|
|
6
6
|
// Replace all variables of the format {something} with the uppercase variable name without the brackets
|
|
7
7
|
let path = operation.path;
|
|
8
8
|
// {id} -> 123
|
|
@@ -31,7 +31,7 @@ const getRequestFromOperation = (operation, options, selectedExampleKey) => {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
const requestBody = getRequestBodyFromOperation(operation, selectedExampleKey);
|
|
34
|
+
const requestBody = getRequestBodyFromOperation(operation, selectedExampleKey, omitEmptyAndOptionalProperties);
|
|
35
35
|
return {
|
|
36
36
|
method: operation.httpVerb.toUpperCase(),
|
|
37
37
|
path,
|
|
@@ -1,74 +1,17 @@
|
|
|
1
|
-
import { type Collection, type Request } from '../entities/spec/index.js';
|
|
2
|
-
|
|
1
|
+
import { type Collection, type Request, type RequestExample, type SecurityScheme, type Tag } from '../entities/spec/index.js';
|
|
2
|
+
import type { OpenAPIV3_1 } from '@scalar/types';
|
|
3
|
+
type WithRequired<T, K extends keyof T> = T & {
|
|
4
|
+
[P in K]-?: T[P];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Convert a workspace collection into an OpenAPI document
|
|
8
|
+
*/
|
|
9
|
+
export declare function exportSpecFromWorkspace({ collection, requests, requestExamples, tags, securitySchemes, }: {
|
|
3
10
|
collection: Collection;
|
|
4
11
|
requests: Record<string, Request>;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
security: Record<string, string[]>[];
|
|
11
|
-
'x-scalar-icon': string;
|
|
12
|
-
securitySchemes: string[];
|
|
13
|
-
selectedSecuritySchemeUids: string[];
|
|
14
|
-
selectedServerUid: string;
|
|
15
|
-
servers: string[];
|
|
16
|
-
requests: string[];
|
|
17
|
-
tags: string[];
|
|
18
|
-
auth: Record<string, {
|
|
19
|
-
type: "apiKey";
|
|
20
|
-
value: string;
|
|
21
|
-
name: string;
|
|
22
|
-
} | {
|
|
23
|
-
type: "http";
|
|
24
|
-
username: string;
|
|
25
|
-
password: string;
|
|
26
|
-
token: string;
|
|
27
|
-
} | {
|
|
28
|
-
type: "oauth-implicit";
|
|
29
|
-
token: string;
|
|
30
|
-
} | {
|
|
31
|
-
type: "oauth-password";
|
|
32
|
-
username: string;
|
|
33
|
-
password: string;
|
|
34
|
-
token: string;
|
|
35
|
-
clientSecret: string;
|
|
36
|
-
} | {
|
|
37
|
-
type: "oauth-clientCredentials";
|
|
38
|
-
token: string;
|
|
39
|
-
clientSecret: string;
|
|
40
|
-
} | {
|
|
41
|
-
type: "oauth-authorizationCode";
|
|
42
|
-
token: string;
|
|
43
|
-
clientSecret: string;
|
|
44
|
-
}>;
|
|
45
|
-
watchMode: boolean;
|
|
46
|
-
watchModeStatus: "IDLE" | "WATCHING" | "ERROR";
|
|
47
|
-
externalDocs?: {
|
|
48
|
-
url: string;
|
|
49
|
-
description?: string | undefined;
|
|
50
|
-
} | undefined;
|
|
51
|
-
jsonSchemaDialect?: string | undefined;
|
|
52
|
-
info?: {
|
|
53
|
-
title: string;
|
|
54
|
-
version: string;
|
|
55
|
-
description?: string | undefined;
|
|
56
|
-
summary?: string | undefined;
|
|
57
|
-
termsOfService?: string | undefined;
|
|
58
|
-
contact?: {
|
|
59
|
-
name?: string | undefined;
|
|
60
|
-
url?: string | undefined;
|
|
61
|
-
email?: string | undefined;
|
|
62
|
-
} | undefined;
|
|
63
|
-
license?: {
|
|
64
|
-
name: string;
|
|
65
|
-
identifier?: string | undefined;
|
|
66
|
-
url?: string | undefined;
|
|
67
|
-
} | undefined;
|
|
68
|
-
} | undefined;
|
|
69
|
-
components?: Record<string, unknown> | undefined;
|
|
70
|
-
webhooks?: Record<string, unknown> | undefined;
|
|
71
|
-
documentUrl?: string | undefined;
|
|
72
|
-
integration?: string | null | undefined;
|
|
73
|
-
};
|
|
12
|
+
requestExamples: Record<string, RequestExample>;
|
|
13
|
+
tags: Record<string, Tag>;
|
|
14
|
+
securitySchemes: Record<string, SecurityScheme>;
|
|
15
|
+
}): WithRequired<OpenAPIV3_1.Document<{}>, "paths" | "components" | "tags">;
|
|
16
|
+
export {};
|
|
74
17
|
//# sourceMappingURL=export-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/export-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"export-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/export-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,GAAG,EAMT,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAA;AAElE;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,QAAQ,EACR,eAAe,EACf,IAAI,EACJ,eAAe,GAChB,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC/C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACzB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;CAChD,2EAyEA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { oasCollectionSchema } from '../entities/spec/collection.js';
|
|
2
|
+
import { oasTagSchema } from '../entities/spec/spec-objects.js';
|
|
3
|
+
import { oasRequestSchema } from '../entities/spec/requests.js';
|
|
4
|
+
import { convertExampleToXScalar } from '../entities/spec/request-examples.js';
|
|
5
|
+
import { oasSecuritySchemeSchema } from '../entities/spec/security.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert a workspace collection into an OpenAPI document
|
|
9
|
+
*/
|
|
10
|
+
function exportSpecFromWorkspace({ collection, requests, requestExamples, tags, securitySchemes, }) {
|
|
11
|
+
const parsedCollection = oasCollectionSchema.parse(collection);
|
|
12
|
+
const spec = {
|
|
13
|
+
...parsedCollection,
|
|
14
|
+
openapi: parsedCollection.openapi,
|
|
15
|
+
tags: [],
|
|
16
|
+
paths: {},
|
|
17
|
+
webhooks: {},
|
|
18
|
+
components: {
|
|
19
|
+
securitySchemes: {},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
/** Add all of the tags into the collection */
|
|
23
|
+
Object.values(tags).forEach((tag) => {
|
|
24
|
+
const oasTag = oasTagSchema.parse(tag);
|
|
25
|
+
if (!oasTag['x-scalar-children']?.length)
|
|
26
|
+
delete oasTag['x-scalar-children'];
|
|
27
|
+
spec.tags.push(oasTag);
|
|
28
|
+
});
|
|
29
|
+
/** Add all of the requests into the collection as operations */
|
|
30
|
+
Object.values(requests).forEach((request) => {
|
|
31
|
+
const oasRequest = oasRequestSchema.parse(request);
|
|
32
|
+
// Currently the request has tags added by name. Should this move to UID association?
|
|
33
|
+
oasRequest.tags = request.tags;
|
|
34
|
+
// If the request has examples we add them all as extensions
|
|
35
|
+
const exampleNames = new Set();
|
|
36
|
+
/** Increment non-unique names */
|
|
37
|
+
function checkName(name) {
|
|
38
|
+
if (exampleNames.has(name)) {
|
|
39
|
+
const base = name.split(' ');
|
|
40
|
+
const end = Number.parseInt(base.at(-1) ?? 'NaN', 10);
|
|
41
|
+
if (Number.isNaN(end)) {
|
|
42
|
+
base.push('1');
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
base[base.length - 1] = `${end + 1}`;
|
|
46
|
+
}
|
|
47
|
+
return checkName(base.join(' '));
|
|
48
|
+
}
|
|
49
|
+
exampleNames.add(name);
|
|
50
|
+
return name;
|
|
51
|
+
}
|
|
52
|
+
if (request.examples.length) {
|
|
53
|
+
oasRequest['x-scalar-examples'] = {};
|
|
54
|
+
request.examples.forEach((uid) => {
|
|
55
|
+
const requestExample = requestExamples[uid];
|
|
56
|
+
oasRequest['x-scalar-examples'][checkName(requestExample.name)] =
|
|
57
|
+
convertExampleToXScalar(requestExample);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** Insert the request as an operation in the spec */
|
|
61
|
+
if (!spec.paths[request.path])
|
|
62
|
+
spec.paths[request.path] = {};
|
|
63
|
+
spec.paths[request.path][request.method] = oasRequest;
|
|
64
|
+
});
|
|
65
|
+
/** Add all of the security schemes into the collection */
|
|
66
|
+
Object.values(securitySchemes).forEach((securityScheme) => {
|
|
67
|
+
const oasScheme = oasSecuritySchemeSchema.parse(securityScheme);
|
|
68
|
+
spec.components.securitySchemes[securityScheme.nameKey] = oasScheme;
|
|
69
|
+
});
|
|
70
|
+
return spec;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { exportSpecFromWorkspace };
|
|
@@ -116,7 +116,7 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
116
116
|
const start = performance.now();
|
|
117
117
|
const requests = [];
|
|
118
118
|
// Grab the base server URL for relative servers
|
|
119
|
-
const backupBaseServerUrl = typeof window
|
|
119
|
+
const backupBaseServerUrl = typeof window === 'undefined' ? 'http://localhost' : window.location.origin;
|
|
120
120
|
const _baseServerUrl = baseServerURL ?? backupBaseServerUrl;
|
|
121
121
|
// Add the base server url to any relative servers
|
|
122
122
|
const servers = serverSchema.array().parse((overloadServers ?? schema.servers)?.map((s) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA"}
|
package/dist/transforms/index.js
CHANGED
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.76",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -106,9 +106,9 @@
|
|
|
106
106
|
"nanoid": "^5.0.7",
|
|
107
107
|
"yaml": "^2.4.5",
|
|
108
108
|
"zod": "^3.23.8",
|
|
109
|
-
"@scalar/object-utils": "1.1.12",
|
|
110
109
|
"@scalar/openapi-types": "0.1.5",
|
|
111
110
|
"@scalar/themes": "0.9.48",
|
|
111
|
+
"@scalar/object-utils": "1.1.12",
|
|
112
112
|
"@scalar/types": "0.0.19"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
@@ -116,9 +116,9 @@
|
|
|
116
116
|
"vite": "^5.4.9",
|
|
117
117
|
"vitest": "^1.6.0",
|
|
118
118
|
"zod-to-ts": "^1.2.0",
|
|
119
|
+
"@scalar/build-tooling": "0.1.12",
|
|
119
120
|
"@scalar/openapi-types": "0.1.5",
|
|
120
|
-
"@scalar/openapi-parser": "0.8.9"
|
|
121
|
-
"@scalar/build-tooling": "0.1.12"
|
|
121
|
+
"@scalar/openapi-parser": "0.8.9"
|
|
122
122
|
},
|
|
123
123
|
"scripts": {
|
|
124
124
|
"build": "scalar-build-rollup",
|