@scalar/oas-utils 0.2.126 → 0.2.127
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/operation.d.ts +59 -1
- package/dist/entities/spec/operation.d.ts.map +1 -1
- package/dist/entities/spec/requests.d.ts +59 -1
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/requests.js +2 -0
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +18 -11
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type RequestPayload, type Request as RequestType } from './requests.ts';
|
|
6
6
|
export type Operation = RequestType;
|
|
7
7
|
export type OperationPayload = RequestPayload;
|
|
8
|
-
export declare const operationSchema: import("zod").ZodObject<import("zod").objectUtil.extendShape<import("zod").objectUtil.extendShape<Omit<{
|
|
8
|
+
export declare const operationSchema: import("zod").ZodObject<import("zod").objectUtil.extendShape<import("zod").objectUtil.extendShape<import("zod").objectUtil.extendShape<Omit<{
|
|
9
9
|
tags: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
10
10
|
summary: import("zod").ZodOptional<import("zod").ZodString>;
|
|
11
11
|
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -161,6 +161,46 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
161
161
|
'x-internal': import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
162
162
|
'x-scalar-ignore': import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
163
163
|
}, "x-scalar-examples">, {
|
|
164
|
+
'x-codeSamples': import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
165
|
+
lang: import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
166
|
+
label: import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
167
|
+
source: import("zod").ZodString;
|
|
168
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
169
|
+
source: string;
|
|
170
|
+
label?: string | undefined;
|
|
171
|
+
lang?: string | undefined;
|
|
172
|
+
}, {
|
|
173
|
+
source: string;
|
|
174
|
+
label?: unknown;
|
|
175
|
+
lang?: unknown;
|
|
176
|
+
}>, "many">>>;
|
|
177
|
+
'x-code-samples': import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
178
|
+
lang: import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
179
|
+
label: import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
180
|
+
source: import("zod").ZodString;
|
|
181
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
182
|
+
source: string;
|
|
183
|
+
label?: string | undefined;
|
|
184
|
+
lang?: string | undefined;
|
|
185
|
+
}, {
|
|
186
|
+
source: string;
|
|
187
|
+
label?: unknown;
|
|
188
|
+
lang?: unknown;
|
|
189
|
+
}>, "many">>>;
|
|
190
|
+
'x-custom-examples': import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
191
|
+
lang: import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
192
|
+
label: import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
193
|
+
source: import("zod").ZodString;
|
|
194
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
195
|
+
source: string;
|
|
196
|
+
label?: string | undefined;
|
|
197
|
+
lang?: string | undefined;
|
|
198
|
+
}, {
|
|
199
|
+
source: string;
|
|
200
|
+
label?: unknown;
|
|
201
|
+
lang?: unknown;
|
|
202
|
+
}>, "many">>>;
|
|
203
|
+
}>, {
|
|
164
204
|
'x-scalar-stability': import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodEnum<[import("@scalar/types").XScalarStability.Deprecated, import("@scalar/types").XScalarStability.Experimental, import("@scalar/types").XScalarStability.Stable]>>>;
|
|
165
205
|
}>, {
|
|
166
206
|
type: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodLiteral<"request">>>;
|
|
@@ -209,6 +249,21 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
209
249
|
}[] | undefined;
|
|
210
250
|
requestBody?: any;
|
|
211
251
|
responses?: Record<string, any> | undefined;
|
|
252
|
+
'x-codeSamples'?: {
|
|
253
|
+
source: string;
|
|
254
|
+
label?: string | undefined;
|
|
255
|
+
lang?: string | undefined;
|
|
256
|
+
}[] | undefined;
|
|
257
|
+
'x-code-samples'?: {
|
|
258
|
+
source: string;
|
|
259
|
+
label?: string | undefined;
|
|
260
|
+
lang?: string | undefined;
|
|
261
|
+
}[] | undefined;
|
|
262
|
+
'x-custom-examples'?: {
|
|
263
|
+
source: string;
|
|
264
|
+
label?: string | undefined;
|
|
265
|
+
lang?: string | undefined;
|
|
266
|
+
}[] | undefined;
|
|
212
267
|
'x-scalar-stability'?: import("@scalar/types").XScalarStability | undefined;
|
|
213
268
|
}, {
|
|
214
269
|
uid?: string | undefined;
|
|
@@ -247,6 +302,9 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
247
302
|
}[] | undefined;
|
|
248
303
|
requestBody?: any;
|
|
249
304
|
responses?: Record<string, any> | undefined;
|
|
305
|
+
'x-codeSamples'?: unknown;
|
|
306
|
+
'x-code-samples'?: unknown;
|
|
307
|
+
'x-custom-examples'?: unknown;
|
|
250
308
|
'x-scalar-stability'?: unknown;
|
|
251
309
|
method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
|
|
252
310
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,IAAI,WAAW,EAAiB,MAAM,eAAe,CAAA;AAE/F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,IAAI,WAAW,EAAiB,MAAM,eAAe,CAAA;AAE/F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aACqV,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAqT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAwT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADrzC,CAAA"}
|
|
@@ -315,7 +315,7 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
315
315
|
}> | undefined;
|
|
316
316
|
}>;
|
|
317
317
|
/** Unified request schema for client usage */
|
|
318
|
-
export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<Omit<{
|
|
318
|
+
export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<Omit<{
|
|
319
319
|
/**
|
|
320
320
|
* A list of tags for API documentation control. Tags can be used for logical
|
|
321
321
|
* grouping of operations by resources or any other qualifier.
|
|
@@ -506,6 +506,46 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
506
506
|
'x-internal': z.ZodOptional<z.ZodBoolean>;
|
|
507
507
|
'x-scalar-ignore': z.ZodOptional<z.ZodBoolean>;
|
|
508
508
|
}, "x-scalar-examples">, {
|
|
509
|
+
'x-codeSamples': z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
510
|
+
lang: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
511
|
+
label: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
512
|
+
source: z.ZodString;
|
|
513
|
+
}, "strip", z.ZodTypeAny, {
|
|
514
|
+
source: string;
|
|
515
|
+
label?: string | undefined;
|
|
516
|
+
lang?: string | undefined;
|
|
517
|
+
}, {
|
|
518
|
+
source: string;
|
|
519
|
+
label?: unknown;
|
|
520
|
+
lang?: unknown;
|
|
521
|
+
}>, "many">>>;
|
|
522
|
+
'x-code-samples': z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
523
|
+
lang: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
524
|
+
label: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
525
|
+
source: z.ZodString;
|
|
526
|
+
}, "strip", z.ZodTypeAny, {
|
|
527
|
+
source: string;
|
|
528
|
+
label?: string | undefined;
|
|
529
|
+
lang?: string | undefined;
|
|
530
|
+
}, {
|
|
531
|
+
source: string;
|
|
532
|
+
label?: unknown;
|
|
533
|
+
lang?: unknown;
|
|
534
|
+
}>, "many">>>;
|
|
535
|
+
'x-custom-examples': z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
536
|
+
lang: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
537
|
+
label: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
538
|
+
source: z.ZodString;
|
|
539
|
+
}, "strip", z.ZodTypeAny, {
|
|
540
|
+
source: string;
|
|
541
|
+
label?: string | undefined;
|
|
542
|
+
lang?: string | undefined;
|
|
543
|
+
}, {
|
|
544
|
+
source: string;
|
|
545
|
+
label?: unknown;
|
|
546
|
+
lang?: unknown;
|
|
547
|
+
}>, "many">>>;
|
|
548
|
+
}>, {
|
|
509
549
|
'x-scalar-stability': z.ZodCatch<z.ZodOptional<z.ZodEnum<[XScalarStability.Deprecated, XScalarStability.Experimental, XScalarStability.Stable]>>>;
|
|
510
550
|
}>, {
|
|
511
551
|
type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"request">>>;
|
|
@@ -560,6 +600,21 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
560
600
|
}[] | undefined;
|
|
561
601
|
requestBody?: any;
|
|
562
602
|
responses?: Record<string, any> | undefined;
|
|
603
|
+
'x-codeSamples'?: {
|
|
604
|
+
source: string;
|
|
605
|
+
label?: string | undefined;
|
|
606
|
+
lang?: string | undefined;
|
|
607
|
+
}[] | undefined;
|
|
608
|
+
'x-code-samples'?: {
|
|
609
|
+
source: string;
|
|
610
|
+
label?: string | undefined;
|
|
611
|
+
lang?: string | undefined;
|
|
612
|
+
}[] | undefined;
|
|
613
|
+
'x-custom-examples'?: {
|
|
614
|
+
source: string;
|
|
615
|
+
label?: string | undefined;
|
|
616
|
+
lang?: string | undefined;
|
|
617
|
+
}[] | undefined;
|
|
563
618
|
'x-scalar-stability'?: XScalarStability | undefined;
|
|
564
619
|
}, {
|
|
565
620
|
uid?: string | undefined;
|
|
@@ -598,6 +653,9 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
598
653
|
}[] | undefined;
|
|
599
654
|
requestBody?: any;
|
|
600
655
|
responses?: Record<string, any> | undefined;
|
|
656
|
+
'x-codeSamples'?: unknown;
|
|
657
|
+
'x-code-samples'?: unknown;
|
|
658
|
+
'x-custom-examples'?: unknown;
|
|
601
659
|
'x-scalar-stability'?: unknown;
|
|
602
660
|
method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
|
|
603
661
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/requests.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,CAAC,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/requests.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAGhD,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,uBAAuB,CAAA;AAGjF,eAAO,MAAM,cAAc,2FAA4F,CAAA;AAEvH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3D,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG;IACzD,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,wCAAwC;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,0BAA0B;IAC1B,MAAM,EAAE,aAAa,CAAA;IACrB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,iEAAiE;AACjE,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EAAE,SAAS;gBAAmB,EAAG,SAAS;gBAAiB,EAAI,UAAS;;aAEhF,CAAC;YAAkC,CAAC;;;aAEO,CAAC;YACpC,CAAC;;sBACV,EAAG,QAAQ,CAAC,EAAE,WAAW,CAAE,EAAC,QAAQ,CAAC,EAAE,SAAS;cACpD,EAAG,QAAQ,CAAC,EAAE,WAAW,CAAC,EAAE,SACzB;eAAkB,EAAG,QAAQ,CAAC,EAAE,WAChC,CAAC,EAAE,SAAS;gBACV,EAAI,SAAQ;gBACjB,EAAA,UAAU;;aAEJ,CAAA;YACY,CAAC;;;aAGX,CAAA;YACM,CAAC;;yBAEC,EAAG,QAClB,CAAC,EAAE,WAEN,CAEA,EADE,QAAQ,CAAC,EAAE,SAAS;cAAgB,EAAI,QAAO,CAAC,EAAE,WAAW,CAAC,EAChE,SAAS;eAAkB,EACzB,QAAO,CAAE,EAAC,WAAW,CAAC,EACtB,SAAO;gBACP,EAAA,SAAS;gBAGN,EAAI,UAAS;;aAEhB,CAAC;YAAkC,CAAC;;;aAEA,CAAC;YACrB,CAAC;;;;;;;IA4EjB,eAAe;;IAEf,qBAAqB;;IAErB,kDAAkD;;IAElD,oCAAoC;;IAEpC,uDAAuD;;IAEvD,+DAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASlC,CAAA;AAE/B,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { selectedSecuritySchemeUidSchema } from '../shared/utility.js';
|
|
2
2
|
import { nanoidSchema } from '@scalar/types/utils';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { XCodeSamplesSchema } from '@scalar/openapi-types/schemas/extensions';
|
|
4
5
|
import { XScalarStability } from '@scalar/types';
|
|
5
6
|
import { oasSecurityRequirementSchema } from '@scalar/types/entities';
|
|
6
7
|
import { oasParameterSchema } from './parameters.js';
|
|
@@ -100,6 +101,7 @@ const extendedRequestSchema = z.object({
|
|
|
100
101
|
/** Unified request schema for client usage */
|
|
101
102
|
const requestSchema = oasRequestSchema
|
|
102
103
|
.omit({ 'x-scalar-examples': true })
|
|
104
|
+
.merge(XCodeSamplesSchema)
|
|
103
105
|
.merge(ScalarStabilitySchema)
|
|
104
106
|
.merge(extendedRequestSchema);
|
|
105
107
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAC9E,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAoB,MAAM,+BAA+B,CAAA;AAEzG,OAAO,EAAE,KAAK,cAAc,EAA4B,MAAM,qCAAqC,CAAA;AACnG,OAAO,EAAE,KAAK,OAAO,EAAsC,MAAM,6BAA6B,CAAA;AAC9F,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,KAAK,GAAG,EAAa,MAAM,iCAAiC,CAAA;AAKrE,OAAO,EAEL,KAAK,cAAc,EAGpB,MAAM,wBAAwB,CAAA;AAE/B,mFAAmF;AACnF,eAAO,MAAM,WAAW,SAAgB,MAAM,GAAG,aAAa;;;IAoC1D;;;OAGG;YAC8C,WAAW,CAAC,QAAQ;;EAGxE,CAAA;AAED,sDAAsD;A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AE,gBAAgB,GAAG,eAAe,GAAG,SAAS,GAAG,MAAM,CAAC,GAAG;IACzF,mFAAmF;IACnF,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,GAAG,aAAa,EAC5B,EACE,cAAc,EACd,aAAa,EACb,WAAW,EACX,OAAO,EAAE,iBAAiB,EAC1B,qBAA6B,EAC7B,IAAI,EACJ,UAAU,EACV,SAAiB,GAClB,GAAE,yBAA8B,GAChC,OAAO,CACN;IACE,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,eAAe,EAAE,cAAc,EAAE,CAAA;CAClC,GACD;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,SAAS,CAAA;CAAE,CACnE,CAiXA;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,WAAW,CAAC,YAAY,EAAE,GAAG,SAAS,EAC/C,EAAE,aAAa,EAAE,GAAE,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAM,GACvE,MAAM,EAAE,CA0CV"}
|
|
@@ -86,15 +86,17 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
86
86
|
// Some entities will be broken out as individual lists for modification in the workspace
|
|
87
87
|
const start = performance.now();
|
|
88
88
|
const requests = [];
|
|
89
|
-
// Add the base server url to
|
|
90
|
-
const
|
|
89
|
+
// Add the base server url to collection servers
|
|
90
|
+
const collectionServers = getServersFromOpenApiDocument(configuredServers || schema.servers, {
|
|
91
91
|
baseServerURL,
|
|
92
92
|
});
|
|
93
|
+
// Store operation servers
|
|
94
|
+
const operationServers = [];
|
|
93
95
|
// Fallback to the current window.location.origin if no servers are provided
|
|
94
|
-
if (!
|
|
96
|
+
if (!collectionServers.length) {
|
|
95
97
|
const fallbackUrl = getFallbackUrl();
|
|
96
98
|
if (fallbackUrl) {
|
|
97
|
-
|
|
99
|
+
collectionServers.push(serverSchema.parse({ url: fallbackUrl }));
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
/**
|
|
@@ -198,13 +200,17 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
198
200
|
}
|
|
199
201
|
// Path level servers must be saved
|
|
200
202
|
const pathServers = serverSchema.array().parse(path.servers ?? []);
|
|
201
|
-
|
|
203
|
+
for (const server of pathServers) {
|
|
204
|
+
collectionServers.push(server);
|
|
205
|
+
}
|
|
202
206
|
// Creates a sorted array of methods based on the path object.
|
|
203
207
|
const methods = Object.keys(path).filter(isHttpMethod);
|
|
204
208
|
methods.forEach((method) => {
|
|
205
209
|
const operation = path[method];
|
|
206
|
-
const
|
|
207
|
-
|
|
210
|
+
const operationLevelServers = serverSchema.array().parse(operation.servers ?? []);
|
|
211
|
+
for (const server of operationLevelServers) {
|
|
212
|
+
operationServers.push(server);
|
|
213
|
+
}
|
|
208
214
|
// We will save a list of all tags to ensure they exists at the top level
|
|
209
215
|
// TODO: make sure we add any loose requests with no tags to the collection children
|
|
210
216
|
operation.tags?.forEach((t) => tagNames.add(t));
|
|
@@ -234,10 +240,11 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
234
240
|
method,
|
|
235
241
|
path: pathString,
|
|
236
242
|
security: operationSecurity,
|
|
243
|
+
selectedServerUid: operationLevelServers?.[0]?.uid,
|
|
237
244
|
selectedSecuritySchemeUids,
|
|
238
245
|
// Merge path and operation level parameters
|
|
239
246
|
parameters: [...(path?.parameters ?? []), ...(operation.parameters ?? [])],
|
|
240
|
-
servers: [...pathServers, ...
|
|
247
|
+
servers: [...pathServers, ...operationLevelServers].map((s) => s.uid),
|
|
241
248
|
};
|
|
242
249
|
// Remove any examples from the request payload as they conflict with our examples property and are not valid
|
|
243
250
|
if (requestPayload.examples) {
|
|
@@ -344,11 +351,11 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
344
351
|
documentUrl,
|
|
345
352
|
useCollectionSecurity,
|
|
346
353
|
requests: requests.map((r) => r.uid),
|
|
347
|
-
servers:
|
|
354
|
+
servers: collectionServers.map((s) => s.uid),
|
|
348
355
|
tags: tags.map((t) => t.uid),
|
|
349
356
|
children: [...collectionChildren],
|
|
350
357
|
security: schema.security ?? [{}],
|
|
351
|
-
selectedServerUid:
|
|
358
|
+
selectedServerUid: collectionServers?.[0]?.uid,
|
|
352
359
|
selectedSecuritySchemeUids,
|
|
353
360
|
components: {
|
|
354
361
|
...schema.components,
|
|
@@ -363,7 +370,7 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
|
|
|
363
370
|
*/
|
|
364
371
|
return {
|
|
365
372
|
error: false,
|
|
366
|
-
servers,
|
|
373
|
+
servers: [...collectionServers, ...operationServers],
|
|
367
374
|
schema,
|
|
368
375
|
requests,
|
|
369
376
|
examples,
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.127",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"yaml": "^2.4.5",
|
|
89
89
|
"zod": "^3.23.8",
|
|
90
90
|
"@scalar/object-utils": "1.1.13",
|
|
91
|
-
"@scalar/themes": "0.9.84",
|
|
92
91
|
"@scalar/openapi-types": "0.2.0",
|
|
92
|
+
"@scalar/themes": "0.9.84",
|
|
93
93
|
"@scalar/types": "0.1.6"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|