@scalar/oas-utils 0.2.144 → 0.3.2
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 +34 -0
- package/dist/entities/spec/index.d.ts +1 -0
- package/dist/entities/spec/index.d.ts.map +1 -1
- package/dist/entities/spec/index.js.map +1 -1
- package/dist/entities/spec/operation.d.ts +13 -1
- package/dist/entities/spec/operation.d.ts.map +1 -1
- package/dist/entities/spec/parameters.d.ts +3 -0
- package/dist/entities/spec/parameters.d.ts.map +1 -1
- package/dist/entities/spec/parameters.js +1 -0
- package/dist/entities/spec/parameters.js.map +2 -2
- package/dist/entities/spec/parameters.test.js +9 -0
- package/dist/entities/spec/parameters.test.js.map +2 -2
- package/dist/entities/spec/request-example.test.js +1 -4
- package/dist/entities/spec/request-example.test.js.map +2 -2
- package/dist/entities/spec/request-examples.js +1 -1
- package/dist/entities/spec/request-examples.js.map +2 -2
- package/dist/entities/spec/requests.d.ts +35 -8
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/requests.js +8 -2
- package/dist/entities/spec/requests.js.map +2 -2
- package/dist/helpers/security/get-schemes.d.ts +2 -2
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @scalar/oas-utils
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 151ef09: fix(oas-utils): do not add content-type for multipart requests
|
|
8
|
+
- 442c0a3: feat: added support for callbacks
|
|
9
|
+
|
|
10
|
+
## 0.3.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 4440949: chore: bumping packages
|
|
15
|
+
- Updated dependencies [4440949]
|
|
16
|
+
- @scalar/object-utils@1.2.1
|
|
17
|
+
- @scalar/openapi-types@0.3.1
|
|
18
|
+
- @scalar/types@0.2.1
|
|
19
|
+
- @scalar/themes@0.12.1
|
|
20
|
+
|
|
21
|
+
## 0.3.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- 483ca93: chore: require Node 20 (or above)
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 30bab1d: support unexploded serialization of array query params
|
|
30
|
+
- Updated dependencies [5613e40]
|
|
31
|
+
- Updated dependencies [483ca93]
|
|
32
|
+
- @scalar/themes@0.12.0
|
|
33
|
+
- @scalar/openapi-types@0.3.0
|
|
34
|
+
- @scalar/object-utils@1.2.0
|
|
35
|
+
- @scalar/types@0.2.0
|
|
36
|
+
|
|
3
37
|
## 0.2.144
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
|
@@ -8,4 +8,5 @@ export { type Operation, type OperationPayload, operationSchema, } from './opera
|
|
|
8
8
|
export { xScalarEnvironmentsSchema, type XScalarEnvironment, type XScalarEnvironments, } from './x-scalar-environments.js';
|
|
9
9
|
/** Re-exported here for ease of use but we should use the other ones directly */
|
|
10
10
|
export { type Oauth2Flow, type Oauth2FlowPayload, type SecuritySchemaHttp, type SecuritySchemaOpenId, type SecurityScheme, type SecuritySchemeApiKey, type SecuritySchemeOauth2, type SecuritySchemeOauth2Payload, type SecuritySchemePayload, oasSecurityRequirementSchema, oasSecuritySchemeSchema, pkceOptions, securityApiKeySchema, securityHttpSchema, securityOauthSchema, securityOpenIdSchema, securitySchemeSchema, } from '@scalar/types/entities';
|
|
11
|
+
export type { PostResponseScript, PostResponseScripts, } from './requests.ts';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACxF,OAAO,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtG,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAA;AACxE,OAAO,EACL,aAAa,EACb,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,EAC9B,KAAK,cAAc,EACnB,KAAK,uBAAuB,GAC7B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,SAAS,EACT,8BAA8B,EAC9B,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,GAAG,EACR,KAAK,UAAU,GAChB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,eAAe,GAChB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,yBAAyB,CAAA;AAEhC,iFAAiF;AACjF,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,4BAA4B,EAC5B,uBAAuB,EACvB,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM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|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/entities/spec/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { collectionSchema, type Collection, type CollectionPayload } from './collection'\nexport { oasParameterSchema, type RequestParameter, type RequestParameterPayload } from './parameters'\nexport { serverSchema, type Server, type ServerPayload } from './server'\nexport {\n requestSchema,\n type Request,\n type RequestPayload,\n type RequestMethod,\n type ResponseInstance,\n type RequestEvent,\n} from './requests'\n\nexport {\n requestExampleSchema,\n createExampleFromRequest,\n requestExampleParametersSchema,\n type RequestExample,\n type RequestExampleParameter,\n} from './request-examples'\n\nexport {\n tagSchema,\n oasExternalDocumentationSchema,\n oasInfoSchema,\n oasContactSchema,\n oasLicenseSchema,\n type Tag,\n type TagPayload,\n} from './spec-objects'\n\nexport {\n type Operation,\n type OperationPayload,\n operationSchema,\n} from './operation'\n\nexport {\n xScalarEnvironmentsSchema,\n type XScalarEnvironment,\n type XScalarEnvironments,\n} from './x-scalar-environments'\n\n/** Re-exported here for ease of use but we should use the other ones directly */\nexport {\n type Oauth2Flow,\n type Oauth2FlowPayload,\n type SecuritySchemaHttp,\n type SecuritySchemaOpenId,\n type SecurityScheme,\n type SecuritySchemeApiKey,\n type SecuritySchemeOauth2,\n type SecuritySchemeOauth2Payload,\n type SecuritySchemePayload,\n oasSecurityRequirementSchema,\n oasSecuritySchemeSchema,\n pkceOptions,\n securityApiKeySchema,\n securityHttpSchema,\n securityOauthSchema,\n securityOpenIdSchema,\n securitySchemeSchema,\n} from '@scalar/types/entities'\n"],
|
|
4
|
+
"sourcesContent": ["export { collectionSchema, type Collection, type CollectionPayload } from './collection'\nexport { oasParameterSchema, type RequestParameter, type RequestParameterPayload } from './parameters'\nexport { serverSchema, type Server, type ServerPayload } from './server'\nexport {\n requestSchema,\n type Request,\n type RequestPayload,\n type RequestMethod,\n type ResponseInstance,\n type RequestEvent,\n} from './requests'\n\nexport {\n requestExampleSchema,\n createExampleFromRequest,\n requestExampleParametersSchema,\n type RequestExample,\n type RequestExampleParameter,\n} from './request-examples'\n\nexport {\n tagSchema,\n oasExternalDocumentationSchema,\n oasInfoSchema,\n oasContactSchema,\n oasLicenseSchema,\n type Tag,\n type TagPayload,\n} from './spec-objects'\n\nexport {\n type Operation,\n type OperationPayload,\n operationSchema,\n} from './operation'\n\nexport {\n xScalarEnvironmentsSchema,\n type XScalarEnvironment,\n type XScalarEnvironments,\n} from './x-scalar-environments'\n\n/** Re-exported here for ease of use but we should use the other ones directly */\nexport {\n type Oauth2Flow,\n type Oauth2FlowPayload,\n type SecuritySchemaHttp,\n type SecuritySchemaOpenId,\n type SecurityScheme,\n type SecuritySchemeApiKey,\n type SecuritySchemeOauth2,\n type SecuritySchemeOauth2Payload,\n type SecuritySchemePayload,\n oasSecurityRequirementSchema,\n oasSecuritySchemeSchema,\n pkceOptions,\n securityApiKeySchema,\n securityHttpSchema,\n securityOauthSchema,\n securityOpenIdSchema,\n securitySchemeSchema,\n} from '@scalar/types/entities'\n\nexport type {\n PostResponseScript,\n PostResponseScripts,\n} from './requests.ts'\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,wBAAiE;AAC1E,SAAS,0BAA+E;AACxF,SAAS,oBAAqD;AAC9D;AAAA,EACE;AAAA,OAMK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP;AAAA,EAGE;AAAA,OACK;AAEP;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EAUE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type RequestPayload, type Request as RequestType } from './requests.js';
|
|
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<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<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>;
|
|
@@ -21,6 +21,7 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
21
21
|
schema: import("zod").ZodOptional<import("zod").ZodUnknown>;
|
|
22
22
|
content: import("zod").ZodOptional<import("zod").ZodUnknown>;
|
|
23
23
|
style: import("zod").ZodOptional<import("zod").ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
|
|
24
|
+
explode: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
24
25
|
example: import("zod").ZodOptional<import("zod").ZodUnknown>;
|
|
25
26
|
examples: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
26
27
|
value: import("zod").ZodOptional<import("zod").ZodUnknown>;
|
|
@@ -50,6 +51,7 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
50
51
|
schema?: unknown;
|
|
51
52
|
content?: unknown;
|
|
52
53
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
54
|
+
explode?: boolean | undefined;
|
|
53
55
|
}, {
|
|
54
56
|
name: string;
|
|
55
57
|
in: "cookie" | "path" | "query" | "header";
|
|
@@ -65,6 +67,7 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
65
67
|
schema?: unknown;
|
|
66
68
|
content?: unknown;
|
|
67
69
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
70
|
+
explode?: boolean | undefined;
|
|
68
71
|
}>, "many">>;
|
|
69
72
|
externalDocs: import("zod").ZodOptional<import("zod").ZodEffects<import("zod").ZodObject<{
|
|
70
73
|
description: import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
@@ -84,6 +87,7 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
84
87
|
}>>;
|
|
85
88
|
deprecated: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
86
89
|
responses: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
90
|
+
callbacks: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>>>;
|
|
87
91
|
'x-scalar-examples': import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
88
92
|
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
89
93
|
body: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
@@ -216,6 +220,8 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
216
220
|
selectedServerUid: import("zod").ZodDefault<import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodBranded<import("zod").ZodString, "server">>>>;
|
|
217
221
|
examples: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodBranded<import("zod").ZodString, "example">, "many">>;
|
|
218
222
|
selectedSecuritySchemeUids: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodBranded<import("zod").ZodString, "securityScheme">, import("zod").ZodArray<import("zod").ZodBranded<import("zod").ZodString, "securityScheme">, "many">]>, "many">>;
|
|
223
|
+
}>, {
|
|
224
|
+
'x-post-response': import("zod").ZodOptional<import("zod").ZodString>;
|
|
219
225
|
}>, "strip", import("zod").ZodTypeAny, {
|
|
220
226
|
uid: string & import("zod").BRAND<"operation">;
|
|
221
227
|
path: string;
|
|
@@ -252,10 +258,13 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
252
258
|
schema?: unknown;
|
|
253
259
|
content?: unknown;
|
|
254
260
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
261
|
+
explode?: boolean | undefined;
|
|
255
262
|
}[] | undefined;
|
|
256
263
|
requestBody?: any;
|
|
257
264
|
responses?: Record<string, any> | undefined;
|
|
265
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
258
266
|
'x-scalar-stability'?: import("@scalar/types").XScalarStability | undefined;
|
|
267
|
+
'x-post-response'?: string | undefined;
|
|
259
268
|
'x-codeSamples'?: {
|
|
260
269
|
source: string;
|
|
261
270
|
label?: string | undefined;
|
|
@@ -306,11 +315,14 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
|
|
|
306
315
|
schema?: unknown;
|
|
307
316
|
content?: unknown;
|
|
308
317
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
318
|
+
explode?: boolean | undefined;
|
|
309
319
|
}[] | undefined;
|
|
310
320
|
requestBody?: any;
|
|
311
321
|
responses?: Record<string, any> | undefined;
|
|
322
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
312
323
|
'x-scalar-stability'?: unknown;
|
|
313
324
|
method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
|
|
325
|
+
'x-post-response'?: string | undefined;
|
|
314
326
|
'x-codeSamples'?: unknown;
|
|
315
327
|
'x-code-samples'?: unknown;
|
|
316
328
|
'x-custom-examples'?: unknown;
|
|
@@ -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,YAAY,CAAA;AAE5F,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,YAAY,CAAA;AAE5F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aACwV,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAqT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAwT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADxzC,CAAA"}
|
|
@@ -26,6 +26,7 @@ export declare const oasParameterSchema: z.ZodObject<{
|
|
|
26
26
|
content: z.ZodOptional<z.ZodUnknown>;
|
|
27
27
|
/** Defaulted according to @url https://spec.openapis.org/oas/v3.1.0#parameter-object */
|
|
28
28
|
style: z.ZodOptional<z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
|
|
29
|
+
explode: z.ZodOptional<z.ZodBoolean>;
|
|
29
30
|
example: z.ZodOptional<z.ZodUnknown>;
|
|
30
31
|
examples: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
31
32
|
value: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -55,6 +56,7 @@ export declare const oasParameterSchema: z.ZodObject<{
|
|
|
55
56
|
schema?: unknown;
|
|
56
57
|
content?: unknown;
|
|
57
58
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
59
|
+
explode?: boolean | undefined;
|
|
58
60
|
}, {
|
|
59
61
|
name: string;
|
|
60
62
|
in: "cookie" | "path" | "query" | "header";
|
|
@@ -70,6 +72,7 @@ export declare const oasParameterSchema: z.ZodObject<{
|
|
|
70
72
|
schema?: unknown;
|
|
71
73
|
content?: unknown;
|
|
72
74
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
75
|
+
explode?: boolean | undefined;
|
|
73
76
|
}>;
|
|
74
77
|
export type RequestParameter = z.infer<typeof oasParameterSchema>;
|
|
75
78
|
export type RequestParameterPayload = z.input<typeof oasParameterSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/parameters.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,CAAC,EAAE,MAAM,KAAK,CAAA;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAEjE,eAAO,MAAM,mBAAmB,kDAAgD,CAAA;AAChF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO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AACD,eAAO,MAAM,sBAAsB,cAAc,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;IAI7B,yBAAyB;;IAEzB,yBAAyB;;;;IAIzB,wFAAwF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBjD,CAAA;AAEzC,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AACjE,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
|
|
@@ -22,6 +22,7 @@ const oasParameterSchema = z.object({
|
|
|
22
22
|
content: z.unknown().optional(),
|
|
23
23
|
/** Defaulted according to @url https://spec.openapis.org/oas/v3.1.0#parameter-object */
|
|
24
24
|
style: parameterStyleSchema.optional(),
|
|
25
|
+
explode: z.boolean().optional(),
|
|
25
26
|
example: z.unknown().optional(),
|
|
26
27
|
examples: z.union([
|
|
27
28
|
z.record(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/entities/spec/parameters.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OpenAPI } from '@scalar/openapi-types'\nimport { type ZodSchema, z } from 'zod'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { RequestExampleParameter } from './request-examples'\n\nexport const parameterTypeSchema = z.enum(['path', 'query', 'header', 'cookie'])\nexport type ParamType = z.infer<typeof parameterTypeSchema>\n\nexport const parameterStyleSchema = z.enum([\n 'matrix',\n 'simple',\n 'form',\n 'label',\n 'spaceDelimited',\n 'pipeDelimited',\n 'deepObject',\n])\nexport type ParameterStyle = z.infer<typeof parameterStyleSchema>\nexport type ParameterContent = Record<\n string,\n {\n schema?: OpenAPIV3_1.Document\n examples?: Record<string, RequestExampleParameter>\n example?: RequestExampleParameter\n }\n>\nexport const parameterExampleSchema = z.unknown()\n\n/**\n * OpenAPI compliant parameters object\n */\nexport const oasParameterSchema = z.object({\n in: parameterTypeSchema,\n name: z.string(),\n description: z.string().optional(),\n /** Defaulted to false */\n required: z.boolean().optional().default(false),\n /** Defaulted to false */\n deprecated: z.boolean().optional().default(false),\n schema: z.unknown().optional(),\n content: z.unknown().optional(),\n /** Defaulted according to @url https://spec.openapis.org/oas/v3.1.0#parameter-object */\n style: parameterStyleSchema.optional(),\n example: z.unknown().optional(),\n examples: z\n .union([\n z.record(\n z.string(),\n z.object({\n value: z.unknown().optional(),\n summary: z.string().optional(),\n externalValue: z.string().optional(),\n }),\n ),\n z.array(z.unknown()),\n ])\n .optional(),\n}) satisfies ZodSchema<OpenAPI.Parameter>\n\nexport type RequestParameter = z.infer<typeof oasParameterSchema>\nexport type RequestParameterPayload = z.input<typeof oasParameterSchema>\n"],
|
|
5
|
-
"mappings": "AACA,SAAyB,SAAS;AAI3B,MAAM,sBAAsB,EAAE,KAAK,CAAC,QAAQ,SAAS,UAAU,QAAQ,CAAC;AAGxE,MAAM,uBAAuB,EAAE,KAAK;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAUM,MAAM,yBAAyB,EAAE,QAAQ;AAKzC,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI;AAAA,EACJ,MAAM,EAAE,OAAO;AAAA,EACf,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAEjC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA;AAAA,EAE9C,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,EAChD,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC7B,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EAE9B,OAAO,qBAAqB,SAAS;AAAA,EACrC,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,UAAU,EACP,MAAM;AAAA,IACL,EAAE;AAAA,MACA,EAAE,OAAO;AAAA,MACT,EAAE,OAAO;AAAA,QACP,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,QAC5B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,QAC7B,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,IACA,EAAE,MAAM,EAAE,QAAQ,CAAC;AAAA,EACrB,CAAC,EACA,SAAS;AACd,CAAC;",
|
|
4
|
+
"sourcesContent": ["import type { OpenAPI } from '@scalar/openapi-types'\nimport { type ZodSchema, z } from 'zod'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { RequestExampleParameter } from './request-examples'\n\nexport const parameterTypeSchema = z.enum(['path', 'query', 'header', 'cookie'])\nexport type ParamType = z.infer<typeof parameterTypeSchema>\n\nexport const parameterStyleSchema = z.enum([\n 'matrix',\n 'simple',\n 'form',\n 'label',\n 'spaceDelimited',\n 'pipeDelimited',\n 'deepObject',\n])\nexport type ParameterStyle = z.infer<typeof parameterStyleSchema>\nexport type ParameterContent = Record<\n string,\n {\n schema?: OpenAPIV3_1.Document\n examples?: Record<string, RequestExampleParameter>\n example?: RequestExampleParameter\n }\n>\nexport const parameterExampleSchema = z.unknown()\n\n/**\n * OpenAPI compliant parameters object\n */\nexport const oasParameterSchema = z.object({\n in: parameterTypeSchema,\n name: z.string(),\n description: z.string().optional(),\n /** Defaulted to false */\n required: z.boolean().optional().default(false),\n /** Defaulted to false */\n deprecated: z.boolean().optional().default(false),\n schema: z.unknown().optional(),\n content: z.unknown().optional(),\n /** Defaulted according to @url https://spec.openapis.org/oas/v3.1.0#parameter-object */\n style: parameterStyleSchema.optional(),\n explode: z.boolean().optional(),\n example: z.unknown().optional(),\n examples: z\n .union([\n z.record(\n z.string(),\n z.object({\n value: z.unknown().optional(),\n summary: z.string().optional(),\n externalValue: z.string().optional(),\n }),\n ),\n z.array(z.unknown()),\n ])\n .optional(),\n}) satisfies ZodSchema<OpenAPI.Parameter>\n\nexport type RequestParameter = z.infer<typeof oasParameterSchema>\nexport type RequestParameterPayload = z.input<typeof oasParameterSchema>\n"],
|
|
5
|
+
"mappings": "AACA,SAAyB,SAAS;AAI3B,MAAM,sBAAsB,EAAE,KAAK,CAAC,QAAQ,SAAS,UAAU,QAAQ,CAAC;AAGxE,MAAM,uBAAuB,EAAE,KAAK;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAUM,MAAM,yBAAyB,EAAE,QAAQ;AAKzC,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI;AAAA,EACJ,MAAM,EAAE,OAAO;AAAA,EACf,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAEjC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA;AAAA,EAE9C,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,EAChD,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC7B,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EAE9B,OAAO,qBAAqB,SAAS;AAAA,EACrC,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,SAAS,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,UAAU,EACP,MAAM;AAAA,IACL,EAAE;AAAA,MACA,EAAE,OAAO;AAAA,MACT,EAAE,OAAO;AAAA,QACP,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,QAC5B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,QAC7B,eAAe,EAAE,OAAO,EAAE,SAAS;AAAA,MACrC,CAAC;AAAA,IACH;AAAA,IACA,EAAE,MAAM,EAAE,QAAQ,CAAC;AAAA,EACrB,CAAC,EACA,SAAS;AACd,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -67,5 +67,14 @@ describe("oasParameterSchema", () => {
|
|
|
67
67
|
};
|
|
68
68
|
expect(() => oasParameterSchema.parse(validParameter)).not.toThrow();
|
|
69
69
|
});
|
|
70
|
+
it("should validate examples with the explode property", () => {
|
|
71
|
+
const validParameter = {
|
|
72
|
+
in: "query",
|
|
73
|
+
name: "galaxy",
|
|
74
|
+
examples: ["Milky Way", "Andromeda"],
|
|
75
|
+
explode: true
|
|
76
|
+
};
|
|
77
|
+
expect(() => oasParameterSchema.parse(validParameter)).not.toThrow();
|
|
78
|
+
});
|
|
70
79
|
});
|
|
71
80
|
//# sourceMappingURL=parameters.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/entities/spec/parameters.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { oasParameterSchema } from '@/entities/spec/parameters'\nimport { describe, expect, it } from 'vitest'\nimport { z } from 'zod'\n\ndescribe('oasParameterSchema', () => {\n it('should validate a parameter with a correct example', () => {\n const validParameterWithExample = {\n in: 'query',\n name: 'limit',\n example: 10,\n }\n\n expect(() => oasParameterSchema.parse(validParameterWithExample)).not.toThrow()\n })\n\n it('should validate examples as a record with correct structure', () => {\n const validExamples = {\n milkyWay: {\n value: 'Milky Way',\n summary: 'Our galaxy',\n },\n andromeda: {\n value: 'Andromeda',\n summary: 'Nearest major galaxy',\n },\n }\n\n const validParameter = {\n in: 'query',\n name: 'galaxy',\n examples: validExamples,\n }\n\n expect(() => oasParameterSchema.parse(validParameter)).not.toThrow()\n })\n\n it('should fail validation if examples have incorrect structure', () => {\n const invalidExamples = {\n milkyWay: {\n value: 'Milky Way',\n // Summary is optional, so this should not cause a failure\n },\n andromeda: 'This should be an object, not a string',\n }\n\n const invalidParameter = {\n in: 'query',\n name: 'galaxy',\n examples: invalidExamples,\n }\n\n expect(() => oasParameterSchema.parse(invalidParameter)).toThrow(z.ZodError)\n })\n\n it('should validate examples as an array', () => {\n const validParameter = {\n in: 'query',\n name: 'galaxy',\n examples: ['Milky Way', 'Andromeda'],\n }\n\n expect(() => oasParameterSchema.parse(validParameter)).not.toThrow()\n })\n\n it('should validate examples with a single array item', () => {\n const validParameter = {\n in: 'query',\n name: 'galaxy',\n examples: ['Milky Way'],\n }\n\n expect(() => oasParameterSchema.parse(validParameter)).not.toThrow()\n })\n\n it('should validate with an empty array of examples', () => {\n const validParameter = {\n in: 'query',\n name: 'galaxy',\n examples: [],\n }\n\n expect(() => oasParameterSchema.parse(validParameter)).not.toThrow()\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,0BAA0B;AACnC,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,SAAS;AAElB,SAAS,sBAAsB,MAAM;AACnC,KAAG,sDAAsD,MAAM;AAC7D,UAAM,4BAA4B;AAAA,MAChC,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAEA,WAAO,MAAM,mBAAmB,MAAM,yBAAyB,CAAC,EAAE,IAAI,QAAQ;AAAA,EAChF,CAAC;AAED,KAAG,+DAA+D,MAAM;AACtE,UAAM,gBAAgB;AAAA,MACpB,UAAU;AAAA,QACR,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,IACF;AAEA,UAAM,iBAAiB;AAAA,MACrB,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAEA,WAAO,MAAM,mBAAmB,MAAM,cAAc,CAAC,EAAE,IAAI,QAAQ;AAAA,EACrE,CAAC;AAED,KAAG,+DAA+D,MAAM;AACtE,UAAM,kBAAkB;AAAA,MACtB,UAAU;AAAA,QACR,OAAO;AAAA;AAAA,MAET;AAAA,MACA,WAAW;AAAA,IACb;AAEA,UAAM,mBAAmB;AAAA,MACvB,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAEA,WAAO,MAAM,mBAAmB,MAAM,gBAAgB,CAAC,EAAE,QAAQ,EAAE,QAAQ;AAAA,EAC7E,CAAC;AAED,KAAG,wCAAwC,MAAM;AAC/C,UAAM,iBAAiB;AAAA,MACrB,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU,CAAC,aAAa,WAAW;AAAA,IACrC;AAEA,WAAO,MAAM,mBAAmB,MAAM,cAAc,CAAC,EAAE,IAAI,QAAQ;AAAA,EACrE,CAAC;AAED,KAAG,qDAAqD,MAAM;AAC5D,UAAM,iBAAiB;AAAA,MACrB,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU,CAAC,WAAW;AAAA,IACxB;AAEA,WAAO,MAAM,mBAAmB,MAAM,cAAc,CAAC,EAAE,IAAI,QAAQ;AAAA,EACrE,CAAC;AAED,KAAG,mDAAmD,MAAM;AAC1D,UAAM,iBAAiB;AAAA,MACrB,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU,CAAC;AAAA,IACb;AAEA,WAAO,MAAM,mBAAmB,MAAM,cAAc,CAAC,EAAE,IAAI,QAAQ;AAAA,EACrE,CAAC;AACH,CAAC;",
|
|
4
|
+
"sourcesContent": ["import { oasParameterSchema } from '@/entities/spec/parameters'\nimport { describe, expect, it } from 'vitest'\nimport { z } from 'zod'\n\ndescribe('oasParameterSchema', () => {\n it('should validate a parameter with a correct example', () => {\n const validParameterWithExample = {\n in: 'query',\n name: 'limit',\n example: 10,\n }\n\n expect(() => oasParameterSchema.parse(validParameterWithExample)).not.toThrow()\n })\n\n it('should validate examples as a record with correct structure', () => {\n const validExamples = {\n milkyWay: {\n value: 'Milky Way',\n summary: 'Our galaxy',\n },\n andromeda: {\n value: 'Andromeda',\n summary: 'Nearest major galaxy',\n },\n }\n\n const validParameter = {\n in: 'query',\n name: 'galaxy',\n examples: validExamples,\n }\n\n expect(() => oasParameterSchema.parse(validParameter)).not.toThrow()\n })\n\n it('should fail validation if examples have incorrect structure', () => {\n const invalidExamples = {\n milkyWay: {\n value: 'Milky Way',\n // Summary is optional, so this should not cause a failure\n },\n andromeda: 'This should be an object, not a string',\n }\n\n const invalidParameter = {\n in: 'query',\n name: 'galaxy',\n examples: invalidExamples,\n }\n\n expect(() => oasParameterSchema.parse(invalidParameter)).toThrow(z.ZodError)\n })\n\n it('should validate examples as an array', () => {\n const validParameter = {\n in: 'query',\n name: 'galaxy',\n examples: ['Milky Way', 'Andromeda'],\n }\n\n expect(() => oasParameterSchema.parse(validParameter)).not.toThrow()\n })\n\n it('should validate examples with a single array item', () => {\n const validParameter = {\n in: 'query',\n name: 'galaxy',\n examples: ['Milky Way'],\n }\n\n expect(() => oasParameterSchema.parse(validParameter)).not.toThrow()\n })\n\n it('should validate with an empty array of examples', () => {\n const validParameter = {\n in: 'query',\n name: 'galaxy',\n examples: [],\n }\n\n expect(() => oasParameterSchema.parse(validParameter)).not.toThrow()\n })\n\n it('should validate examples with the explode property', () => {\n const validParameter = {\n in: 'query',\n name: 'galaxy',\n examples: ['Milky Way', 'Andromeda'],\n explode: true,\n }\n\n expect(() => oasParameterSchema.parse(validParameter)).not.toThrow()\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,0BAA0B;AACnC,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,SAAS;AAElB,SAAS,sBAAsB,MAAM;AACnC,KAAG,sDAAsD,MAAM;AAC7D,UAAM,4BAA4B;AAAA,MAChC,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAEA,WAAO,MAAM,mBAAmB,MAAM,yBAAyB,CAAC,EAAE,IAAI,QAAQ;AAAA,EAChF,CAAC;AAED,KAAG,+DAA+D,MAAM;AACtE,UAAM,gBAAgB;AAAA,MACpB,UAAU;AAAA,QACR,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,OAAO;AAAA,QACP,SAAS;AAAA,MACX;AAAA,IACF;AAEA,UAAM,iBAAiB;AAAA,M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MAAM,cAAc,CAAC,EAAE,IAAI,QAAQ;AAAA,EACrE,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -554,10 +554,7 @@ describe("createExampleFromRequest", () => {
|
|
|
554
554
|
}
|
|
555
555
|
},
|
|
556
556
|
parameters: {
|
|
557
|
-
headers: [
|
|
558
|
-
{ key: "Accept", value: "*/*", enabled: true },
|
|
559
|
-
{ key: "Content-Type", value: "multipart/form-data", enabled: true }
|
|
560
|
-
],
|
|
557
|
+
headers: [{ key: "Accept", value: "*/*", enabled: true }],
|
|
561
558
|
path: [],
|
|
562
559
|
query: [],
|
|
563
560
|
cookies: []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/entities/spec/request-example.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { operationSchema } from './operation'\nimport {\n convertExampleToXScalar,\n createExampleFromRequest,\n createParamInstance,\n parameterArrayToObject,\n requestExampleSchema,\n} from './request-examples'\n\ndescribe('createParamInstance', () => {\n it('works with schema enum type number', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1.2,\n type: 'number',\n enum: [1.2, 2.1, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1.2',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['1.2', '2.1', '3'],\n type: 'number',\n default: 1.2,\n })\n })\n\n it('works with schema enum type string', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 'foo',\n type: 'string',\n enum: ['foo', 'bar'],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'foo',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['foo', 'bar'],\n type: 'string',\n default: 'foo',\n })\n })\n\n it('works with schema enum type integer', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1,\n type: 'integer',\n enum: [1, 2, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['1', '2', '3'],\n type: 'integer',\n default: 1,\n })\n })\n\n it('works with schema enum type boolean', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: false,\n type: 'boolean',\n enum: [true, false],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'false',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['true', 'false'],\n type: 'boolean',\n default: false,\n })\n })\n\n it('works with schema examples type number', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1.2,\n type: 'number',\n examples: [1.2, 2.1, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1.2',\n enabled: true,\n description: undefined,\n required: true,\n examples: ['1.2', '2.1', '3'],\n type: 'number',\n default: 1.2,\n })\n })\n\n it('works with schema examples type string', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: false,\n type: 'boolean',\n examples: ['foo', 'bar'],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'false',\n enabled: true,\n description: undefined,\n required: true,\n type: 'boolean',\n default: false,\n examples: ['foo', 'bar'],\n })\n })\n\n it('works with schema examples type integer', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1,\n type: 'integer',\n examples: [1, 2, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1',\n enabled: true,\n description: undefined,\n required: true,\n examples: ['1', '2', '3'],\n type: 'integer',\n default: 1,\n })\n })\n\n it('works with schema examples type boolean', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: false,\n type: 'boolean',\n examples: [true, false],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'false',\n enabled: true,\n description: undefined,\n required: true,\n examples: ['true', 'false'],\n type: 'boolean',\n default: false,\n })\n })\n\n it('works with array of types', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n type: ['string', 'null'],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n enabled: true,\n enum: undefined,\n examples: undefined,\n description: undefined,\n required: true,\n type: 'string',\n nullable: true,\n value: '',\n })\n })\n\n it('works with content examples', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: false,\n deprecated: false,\n content: {\n 'application/json': {\n schema: { type: 'integer', maximum: 50 },\n examples: {\n zero: { value: 0 },\n max: { value: 50 },\n },\n },\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '0',\n enabled: false,\n description: undefined,\n required: false,\n })\n })\n\n it('works with content example', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: false,\n deprecated: false,\n content: {\n 'application/json': {\n schema: { type: 'integer' },\n example: 42,\n },\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '42',\n enabled: false,\n description: undefined,\n required: false,\n })\n })\n\n it('works with parameter example', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: false,\n deprecated: false,\n example: 42,\n schema: {\n type: 'integer',\n example: 1,\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '42',\n enabled: false,\n description: undefined,\n required: false,\n type: 'integer',\n })\n })\n})\n\ndescribe('parameterArrayToObject', () => {\n it('converts array of parameters to key-value object', () => {\n const params = [\n { key: 'foo', value: 'bar', enabled: true },\n { key: 'hello', value: 'world', enabled: false },\n ]\n\n const result = parameterArrayToObject(params)\n\n expect(result).toEqual({\n foo: 'bar',\n hello: 'world',\n })\n })\n\n it('handles empty array', () => {\n const result = parameterArrayToObject([])\n expect(result).toEqual({})\n })\n})\n\ndescribe('convertExampleToXScalar', () => {\n it('converts raw JSON body', () => {\n const example = requestExampleSchema.parse({\n uid: 'test-uid',\n requestUid: 'req-uid',\n body: {\n activeBody: 'raw',\n raw: {\n encoding: 'json' as const,\n value: '{\"test\": true}',\n },\n },\n parameters: {\n path: [{ key: 'id', value: '123', enabled: true }],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n },\n })\n\n const result = convertExampleToXScalar(example)\n\n expect(result).toEqual({\n body: {\n encoding: 'application/json',\n content: '{\"test\": true}',\n },\n parameters: {\n path: { id: '123' },\n headers: { Accept: '*/*' },\n },\n })\n })\n\n it('converts form data body', () => {\n const example = requestExampleSchema.parse({\n uid: 'test-uid',\n requestUid: 'req-uid',\n body: {\n activeBody: 'formData',\n formData: {\n encoding: 'form-data' as const,\n value: [\n { key: 'field1', value: 'value1', enabled: true },\n {\n key: 'file1',\n value: 'ignore this',\n file: new File(['test content'], 'test.txt', { type: 'text/plain' }),\n enabled: true,\n },\n ],\n },\n },\n })\n\n const result = convertExampleToXScalar(example)\n\n expect(result).toEqual({\n body: {\n encoding: 'multipart/form-data',\n content: {\n field1: { type: 'string', value: 'value1' },\n file1: { type: 'file', file: null },\n },\n },\n parameters: {\n headers: {\n Accept: '*/*',\n },\n },\n })\n })\n\n it('converts binary body', () => {\n const example = requestExampleSchema.parse({\n uid: 'test-uid',\n requestUid: 'req-uid',\n body: {\n activeBody: 'binary',\n binary: new Blob(['test']),\n },\n })\n\n const result = convertExampleToXScalar(example)\n\n expect(result).toEqual({\n body: {\n encoding: 'binary',\n content: '',\n file: null,\n },\n parameters: {\n headers: {\n Accept: '*/*',\n },\n },\n })\n })\n})\n\ndescribe('createExampleFromRequest', () => {\n it('creates example with JSON request body', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'path',\n name: 'id',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: '123' },\n },\n ],\n requestBody: {\n content: {\n 'application/json': {\n schema: {},\n example: '{\"test\": true}',\n },\n },\n },\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: {\n activeBody: 'raw',\n raw: {\n encoding: 'json',\n value: '{\"test\": true}',\n },\n },\n parameters: {\n path: [\n {\n key: 'id',\n value: '123',\n enabled: true,\n required: true,\n },\n ],\n headers: [\n { key: 'Accept', value: '*/*', enabled: true },\n { key: 'Content-Type', value: 'application/json', enabled: true },\n ],\n query: [],\n cookies: [],\n },\n })\n })\n\n it('does not overwrite the content-type header if it exists', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'path',\n name: 'id',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: '123' },\n },\n {\n in: 'header',\n name: 'Content-Type',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: 'application/testing' },\n },\n ],\n requestBody: {\n content: {\n 'application/json': {\n schema: {},\n example: '{\"test\": true}',\n },\n },\n },\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: {\n activeBody: 'raw',\n raw: {\n encoding: 'json',\n value: '{\"test\": true}',\n },\n },\n parameters: {\n path: [\n {\n key: 'id',\n value: '123',\n enabled: true,\n required: true,\n },\n ],\n headers: [{ key: 'Content-Type', value: 'application/testing', enabled: true }],\n query: [],\n cookies: [],\n },\n })\n })\n\n it('creates example with form-data request body', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [],\n requestBody: {\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n properties: {\n image: {\n type: 'string',\n format: 'binary',\n description: \"The pet's image file\",\n },\n additionalImages: {\n type: 'array',\n items: {\n type: 'string',\n format: 'binary',\n },\n description: 'Additional pet images',\n },\n metadata: {\n type: 'object',\n properties: {\n caption: {\n type: 'string',\n },\n tags: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n })\n\n const result = createExampleFromRequest(operation, 'Form Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Form Example',\n body: {\n activeBody: 'formData',\n formData: {\n encoding: 'form-data',\n value: [\n { key: 'image', value: 'BINARY', file: expect.any(File), enabled: true },\n { key: 'additionalImages', value: 'BINARY', file: expect.any(File), enabled: true },\n { key: 'metadata', value: '{\"caption\":\"\",\"tags\":[\"\"]}', enabled: true },\n ],\n },\n },\n parameters: {\n headers: [\n { key: 'Accept', value: '*/*', enabled: true },\n { key: 'Content-Type', value: 'multipart/form-data', enabled: true },\n ],\n path: [],\n query: [],\n cookies: [],\n },\n })\n })\n})\n\ndescribe('createExampleFromRequest with default body when Content-Type header is exists', () => {\n it.each([\n { contentType: 'application/json', defaultBody: { activeBody: 'raw', raw: { encoding: 'json', value: '{}' } } },\n { contentType: 'application/xml', defaultBody: { activeBody: 'raw', raw: { encoding: 'xml', value: '' } } },\n { contentType: 'application/octet-stream', defaultBody: { activeBody: 'binary', binary: undefined } },\n {\n contentType: 'application/x-www-form-urlencoded',\n defaultBody: { activeBody: 'formData', formData: { encoding: 'urlencoded', value: [] } },\n },\n {\n contentType: 'multipart/form-data',\n defaultBody: { activeBody: 'formData', formData: { encoding: 'form-data', value: [] } },\n },\n ] as const)('when Content-Type header is $contentType', ({ contentType, defaultBody }) => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'header',\n name: 'Content-Type',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: contentType },\n },\n ],\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: defaultBody,\n parameters: {\n headers: [{ key: 'Content-Type', value: contentType, enabled: true }],\n query: [],\n cookies: [],\n },\n })\n })\n\n it('when Content-Type header is not exists', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'header',\n name: 'Content-Type',\n required: true,\n deprecated: false,\n schema: { type: 'string' },\n },\n ],\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: {\n activeBody: 'raw',\n },\n parameters: {\n headers: [{ key: 'Content-Type', value: '', enabled: true }],\n query: [],\n cookies: [],\n },\n })\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,uBAAuB,MAAM;AACpC,KAAG,sCAAsC,MAAM;AAC7C,UAAM,SAAS,oBAAoB;AAAA,MACjC,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,MAAM;AAAA,QACN,MAAM,CAAC,KAAK,KAAK,CAAC;AAAA,MACpB;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,QAAQ;AAAA,MACrB,KAAK;AAAA,MACL,OAAO;AAAA,MACP,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,MACV,MAAM,CAAC,OAAO,OAAO,GAAG;AAAA,MACxB,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH,CAAC;AAED,KAAG,sCAAsC,MAAM;AAC7C,UAAM,SAAS,oBAAoB;AAAA,MACjC,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN,SAAS;AAAA,QACT,MAAM;AAAA,QACN,MAAM,CAAC,OAAO,KAAK;AAAA,MACrB;AAAA,IACF,CAAC;AAED,WAAO,MAAM,EAAE,QAAQ;AAAA,MACrB,KAAK;AAAA,MACL,OAAO;AAAA,MACP,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAA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CAAC;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { operationSchema } from './operation'\nimport {\n convertExampleToXScalar,\n createExampleFromRequest,\n createParamInstance,\n parameterArrayToObject,\n requestExampleSchema,\n} from './request-examples'\n\ndescribe('createParamInstance', () => {\n it('works with schema enum type number', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1.2,\n type: 'number',\n enum: [1.2, 2.1, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1.2',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['1.2', '2.1', '3'],\n type: 'number',\n default: 1.2,\n })\n })\n\n it('works with schema enum type string', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 'foo',\n type: 'string',\n enum: ['foo', 'bar'],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'foo',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['foo', 'bar'],\n type: 'string',\n default: 'foo',\n })\n })\n\n it('works with schema enum type integer', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1,\n type: 'integer',\n enum: [1, 2, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['1', '2', '3'],\n type: 'integer',\n default: 1,\n })\n })\n\n it('works with schema enum type boolean', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: false,\n type: 'boolean',\n enum: [true, false],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'false',\n enabled: true,\n description: undefined,\n required: true,\n enum: ['true', 'false'],\n type: 'boolean',\n default: false,\n })\n })\n\n it('works with schema examples type number', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1.2,\n type: 'number',\n examples: [1.2, 2.1, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1.2',\n enabled: true,\n description: undefined,\n required: true,\n examples: ['1.2', '2.1', '3'],\n type: 'number',\n default: 1.2,\n })\n })\n\n it('works with schema examples type string', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: false,\n type: 'boolean',\n examples: ['foo', 'bar'],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'false',\n enabled: true,\n description: undefined,\n required: true,\n type: 'boolean',\n default: false,\n examples: ['foo', 'bar'],\n })\n })\n\n it('works with schema examples type integer', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: 1,\n type: 'integer',\n examples: [1, 2, 3],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '1',\n enabled: true,\n description: undefined,\n required: true,\n examples: ['1', '2', '3'],\n type: 'integer',\n default: 1,\n })\n })\n\n it('works with schema examples type boolean', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n default: false,\n type: 'boolean',\n examples: [true, false],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: 'false',\n enabled: true,\n description: undefined,\n required: true,\n examples: ['true', 'false'],\n type: 'boolean',\n default: false,\n })\n })\n\n it('works with array of types', () => {\n const result = createParamInstance({\n in: 'path',\n name: 'foo',\n required: true,\n deprecated: false,\n schema: {\n type: ['string', 'null'],\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n enabled: true,\n enum: undefined,\n examples: undefined,\n description: undefined,\n required: true,\n type: 'string',\n nullable: true,\n value: '',\n })\n })\n\n it('works with content examples', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: false,\n deprecated: false,\n content: {\n 'application/json': {\n schema: { type: 'integer', maximum: 50 },\n examples: {\n zero: { value: 0 },\n max: { value: 50 },\n },\n },\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '0',\n enabled: false,\n description: undefined,\n required: false,\n })\n })\n\n it('works with content example', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: false,\n deprecated: false,\n content: {\n 'application/json': {\n schema: { type: 'integer' },\n example: 42,\n },\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '42',\n enabled: false,\n description: undefined,\n required: false,\n })\n })\n\n it('works with parameter example', () => {\n const result = createParamInstance({\n in: 'query',\n name: 'foo',\n required: false,\n deprecated: false,\n example: 42,\n schema: {\n type: 'integer',\n example: 1,\n },\n })\n\n expect(result).toEqual({\n key: 'foo',\n value: '42',\n enabled: false,\n description: undefined,\n required: false,\n type: 'integer',\n })\n })\n})\n\ndescribe('parameterArrayToObject', () => {\n it('converts array of parameters to key-value object', () => {\n const params = [\n { key: 'foo', value: 'bar', enabled: true },\n { key: 'hello', value: 'world', enabled: false },\n ]\n\n const result = parameterArrayToObject(params)\n\n expect(result).toEqual({\n foo: 'bar',\n hello: 'world',\n })\n })\n\n it('handles empty array', () => {\n const result = parameterArrayToObject([])\n expect(result).toEqual({})\n })\n})\n\ndescribe('convertExampleToXScalar', () => {\n it('converts raw JSON body', () => {\n const example = requestExampleSchema.parse({\n uid: 'test-uid',\n requestUid: 'req-uid',\n body: {\n activeBody: 'raw',\n raw: {\n encoding: 'json' as const,\n value: '{\"test\": true}',\n },\n },\n parameters: {\n path: [{ key: 'id', value: '123', enabled: true }],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n },\n })\n\n const result = convertExampleToXScalar(example)\n\n expect(result).toEqual({\n body: {\n encoding: 'application/json',\n content: '{\"test\": true}',\n },\n parameters: {\n path: { id: '123' },\n headers: { Accept: '*/*' },\n },\n })\n })\n\n it('converts form data body', () => {\n const example = requestExampleSchema.parse({\n uid: 'test-uid',\n requestUid: 'req-uid',\n body: {\n activeBody: 'formData',\n formData: {\n encoding: 'form-data' as const,\n value: [\n { key: 'field1', value: 'value1', enabled: true },\n {\n key: 'file1',\n value: 'ignore this',\n file: new File(['test content'], 'test.txt', { type: 'text/plain' }),\n enabled: true,\n },\n ],\n },\n },\n })\n\n const result = convertExampleToXScalar(example)\n\n expect(result).toEqual({\n body: {\n encoding: 'multipart/form-data',\n content: {\n field1: { type: 'string', value: 'value1' },\n file1: { type: 'file', file: null },\n },\n },\n parameters: {\n headers: {\n Accept: '*/*',\n },\n },\n })\n })\n\n it('converts binary body', () => {\n const example = requestExampleSchema.parse({\n uid: 'test-uid',\n requestUid: 'req-uid',\n body: {\n activeBody: 'binary',\n binary: new Blob(['test']),\n },\n })\n\n const result = convertExampleToXScalar(example)\n\n expect(result).toEqual({\n body: {\n encoding: 'binary',\n content: '',\n file: null,\n },\n parameters: {\n headers: {\n Accept: '*/*',\n },\n },\n })\n })\n})\n\ndescribe('createExampleFromRequest', () => {\n it('creates example with JSON request body', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'path',\n name: 'id',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: '123' },\n },\n ],\n requestBody: {\n content: {\n 'application/json': {\n schema: {},\n example: '{\"test\": true}',\n },\n },\n },\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: {\n activeBody: 'raw',\n raw: {\n encoding: 'json',\n value: '{\"test\": true}',\n },\n },\n parameters: {\n path: [\n {\n key: 'id',\n value: '123',\n enabled: true,\n required: true,\n },\n ],\n headers: [\n { key: 'Accept', value: '*/*', enabled: true },\n { key: 'Content-Type', value: 'application/json', enabled: true },\n ],\n query: [],\n cookies: [],\n },\n })\n })\n\n it('does not overwrite the content-type header if it exists', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'path',\n name: 'id',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: '123' },\n },\n {\n in: 'header',\n name: 'Content-Type',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: 'application/testing' },\n },\n ],\n requestBody: {\n content: {\n 'application/json': {\n schema: {},\n example: '{\"test\": true}',\n },\n },\n },\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: {\n activeBody: 'raw',\n raw: {\n encoding: 'json',\n value: '{\"test\": true}',\n },\n },\n parameters: {\n path: [\n {\n key: 'id',\n value: '123',\n enabled: true,\n required: true,\n },\n ],\n headers: [{ key: 'Content-Type', value: 'application/testing', enabled: true }],\n query: [],\n cookies: [],\n },\n })\n })\n\n it('creates example with form-data request body', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [],\n requestBody: {\n content: {\n 'multipart/form-data': {\n schema: {\n type: 'object',\n properties: {\n image: {\n type: 'string',\n format: 'binary',\n description: \"The pet's image file\",\n },\n additionalImages: {\n type: 'array',\n items: {\n type: 'string',\n format: 'binary',\n },\n description: 'Additional pet images',\n },\n metadata: {\n type: 'object',\n properties: {\n caption: {\n type: 'string',\n },\n tags: {\n type: 'array',\n items: {\n type: 'string',\n },\n },\n },\n },\n },\n },\n },\n },\n },\n })\n\n const result = createExampleFromRequest(operation, 'Form Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Form Example',\n body: {\n activeBody: 'formData',\n formData: {\n encoding: 'form-data',\n value: [\n { key: 'image', value: 'BINARY', file: expect.any(File), enabled: true },\n { key: 'additionalImages', value: 'BINARY', file: expect.any(File), enabled: true },\n { key: 'metadata', value: '{\"caption\":\"\",\"tags\":[\"\"]}', enabled: true },\n ],\n },\n },\n parameters: {\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n path: [],\n query: [],\n cookies: [],\n },\n })\n })\n})\n\ndescribe('createExampleFromRequest with default body when Content-Type header is exists', () => {\n it.each([\n { contentType: 'application/json', defaultBody: { activeBody: 'raw', raw: { encoding: 'json', value: '{}' } } },\n { contentType: 'application/xml', defaultBody: { activeBody: 'raw', raw: { encoding: 'xml', value: '' } } },\n { contentType: 'application/octet-stream', defaultBody: { activeBody: 'binary', binary: undefined } },\n {\n contentType: 'application/x-www-form-urlencoded',\n defaultBody: { activeBody: 'formData', formData: { encoding: 'urlencoded', value: [] } },\n },\n {\n contentType: 'multipart/form-data',\n defaultBody: { activeBody: 'formData', formData: { encoding: 'form-data', value: [] } },\n },\n ] as const)('when Content-Type header is $contentType', ({ contentType, defaultBody }) => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'header',\n name: 'Content-Type',\n required: true,\n deprecated: false,\n schema: { type: 'string', default: contentType },\n },\n ],\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: defaultBody,\n parameters: {\n headers: [{ key: 'Content-Type', value: contentType, enabled: true }],\n query: [],\n cookies: [],\n },\n })\n })\n\n it('when Content-Type header is not exists', () => {\n const operation = operationSchema.parse({\n uid: 'request-1',\n path: '/test',\n parameters: [\n {\n in: 'header',\n name: 'Content-Type',\n required: true,\n deprecated: false,\n schema: { type: 'string' },\n },\n ],\n })\n\n const result = createExampleFromRequest(operation, 'Test Example')\n\n expect(result).toMatchObject({\n requestUid: 'request-1',\n name: 'Test Example',\n body: {\n activeBody: 'raw',\n },\n parameters: {\n headers: [{ key: 'Content-Type', value: '', enabled: true }],\n query: [],\n cookies: [],\n },\n })\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,uBAAuB,MAAM;AACpC,KAAG,sCAAsC,MAAM;AAC7C,UAAM,SAAS,oBAAoB;AAAA,MACjC,IAAI;AAAA,MACJ,MAAM;AA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SAAS,KAAK,CAAC;AAAA,QACpE,OAAO,CAAC;AAAA,QACR,SAAS,CAAC;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,KAAG,0CAA0C,MAAM;AACjD,UAAM,YAAY,gBAAgB,MAAM;AAAA,MACtC,KAAK;AAAA,MACL,MAAM;AAAA,MACN,YAAY;AAAA,QACV;AAAA,UACE,IAAI;AAAA,UACJ,MAAM;AAAA,UACN,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,QAAQ,EAAE,MAAM,SAAS;AAAA,QAC3B;AAAA,MACF;AAAA,IACF,CAAC;AAED,UAAM,SAAS,yBAAyB,WAAW,cAAc;AAEjE,WAAO,MAAM,EAAE,cAAc;AAAA,MAC3B,YAAY;AAAA,MACZ,MAAM;AAAA,MACN,MAAM;AAAA,QACJ,YAAY;AAAA,MACd;AAAA,MACA,YAAY;AAAA,QACV,SAAS,CAAC,EAAE,KAAK,gBAAgB,OAAO,IAAI,SAAS,KAAK,CAAC;AAAA,QAC3D,OAAO,CAAC;AAAA,QACR,SAAS,CAAC;AAAA,MACZ;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -314,7 +314,7 @@ function createExampleFromRequest(request, name, server) {
|
|
|
314
314
|
})
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
-
if (requestBody?.mimeType && !contentTypeHeader) {
|
|
317
|
+
if (requestBody?.mimeType && !contentTypeHeader && !requestBody.mimeType.startsWith("multipart/")) {
|
|
318
318
|
parameters.headers.push({
|
|
319
319
|
key: "Content-Type",
|
|
320
320
|
value: requestBody.mimeType,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/entities/spec/request-examples.ts"],
|
|
4
|
-
"sourcesContent": ["import { schemaModel } from '@/helpers/schema-model'\nimport { getServerVariableExamples } from '@/spec-getters/get-server-variable-examples'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { isDefined } from '@/helpers/is-defined'\nimport { getObjectKeys } from '@/helpers/object'\n\nimport { getRequestBodyFromOperation } from '@/spec-getters/get-request-body-from-operation'\nimport type { RequestParameter, ParameterContent } from './parameters'\nimport type { Request } from './requests'\nimport type { Server } from './server'\n\n// ---------------------------------------------------------------------------\n// Example Parameters\n\n/**\n * TODO: Deprecate this.\n *\n * The request schema should be stored in the request and any\n * parameters should be validated against that\n */\nexport const requestExampleParametersSchema = z\n .object({\n key: z.string().default(''),\n value: z.coerce.string().default(''),\n enabled: z.boolean().default(true),\n file: z.any().optional(),\n description: z.string().optional(),\n required: z.boolean().optional(),\n enum: z.array(z.string()).optional(),\n examples: z.array(z.any()).optional(),\n type: z\n .union([\n // 'string'\n z.string(),\n // ['string', 'null']\n z.array(z.string()),\n ])\n .optional(),\n format: z.string().optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n default: z.any().optional(),\n nullable: z.boolean().optional(),\n })\n // set nullable: to true if type is ['string', 'null']\n .transform((_data) => {\n const data = { ..._data }\n\n // type: ['string', 'null'] -> nullable: true\n if (Array.isArray(data.type) && data.type.includes('null')) {\n data.nullable = true\n }\n\n // Hey, if it's just one value and 'null', we can make it a string and ditch the 'null'.\n if (Array.isArray(data.type) && data.type.length === 2 && data.type.includes('null')) {\n data.type = data.type.find((item) => item !== 'null')\n }\n\n return data\n })\n\n/** Convert the array of parameters to an object keyed by the parameter name */\nexport const parameterArrayToObject = (params: RequestExampleParameter[]) =>\n params.reduce<Record<string, string>>((map, param) => {\n map[param.key] = param.value\n return map\n }, {})\n\n/** Request examples - formerly known as instances - are \"children\" of requests */\nexport type RequestExampleParameter = z.infer<typeof requestExampleParametersSchema>\n\nexport const xScalarFileValueSchema = z\n .object({\n url: z.string(),\n base64: z.string().optional(),\n })\n .nullable()\n\n/**\n * When files are required for an example we provide the options\n * to provide a public URL or a base64 encoded string\n */\nexport type XScalarFileValue = z.infer<typeof xScalarFileValueSchema>\n\n/**\n * Schema for the OAS serialization of request example parameters\n *\n * File values can be optionally fetched on import OR inserted as a base64 encoded string\n */\nexport const xScalarFormDataValue = z.union([\n z.object({\n type: z.literal('string'),\n value: z.string(),\n }),\n z.object({\n type: z.literal('file'),\n file: xScalarFileValueSchema,\n }),\n])\n\nexport type XScalarFormDataValue = z.infer<typeof xScalarFormDataValue>\n\n// ---------------------------------------------------------------------------\n// Example Body\n\n/**\n * Possible encodings for example request bodies when using text formats\n *\n * TODO: This list may not be comprehensive enough\n */\nexport const exampleRequestBodyEncoding = ['json', 'text', 'html', 'javascript', 'xml', 'yaml', 'edn'] as const\n\nexport type BodyEncoding = (typeof exampleRequestBodyEncoding)[number]\n\nexport const exampleBodyMime = [\n 'application/json',\n 'text/plain',\n 'text/html',\n 'application/javascript',\n 'application/xml',\n 'application/yaml',\n 'application/edn',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'multipart/form-data',\n /** Used for direct files */\n 'binary',\n] as const\n\nexport type BodyMime = (typeof exampleBodyMime)[number]\n\nconst contentMapping: Record<BodyEncoding, BodyMime> = {\n json: 'application/json',\n text: 'text/plain',\n html: 'text/html',\n javascript: 'application/javascript',\n xml: 'application/xml',\n yaml: 'application/yaml',\n edn: 'application/edn',\n} as const\n\n/**\n * TODO: Migrate away from this layout to the format used in the extension\n *\n * If a user changes the encoding of the body we expect the content to change as well\n */\nexport const exampleRequestBodySchema = z.object({\n raw: z\n .object({\n encoding: z.enum(exampleRequestBodyEncoding),\n value: z.string().default(''),\n mimeType: z.string().optional(),\n })\n .optional(),\n formData: z\n .object({\n encoding: z.union([z.literal('form-data'), z.literal('urlencoded')]).default('form-data'),\n value: requestExampleParametersSchema.array().default([]),\n })\n .optional(),\n binary: z.instanceof(Blob).optional(),\n activeBody: z.union([z.literal('raw'), z.literal('formData'), z.literal('binary')]).default('raw'),\n})\n\nexport type ExampleRequestBody = z.infer<typeof exampleRequestBodySchema>\n\n/** Schema for the OAS serialization of request example bodies */\nexport const xScalarExampleBodySchema = z.object({\n encoding: z.enum(exampleBodyMime),\n /**\n * Body content as an object with a separately specified encoding or a simple pre-encoded string value\n *\n * Ideally we would convert any objects into the proper encoding on import\n */\n content: z.union([z.record(z.string(), z.any()), z.string()]),\n /** When the encoding is `binary` this will be used to link to the file */\n file: xScalarFileValueSchema.optional(),\n})\n\nexport type XScalarExampleBody = z.infer<typeof xScalarExampleBodySchema>\n\n// ---------------------------------------------------------------------------\n// Example Schema\n\nexport const requestExampleSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['EXAMPLE']>(),\n type: z.literal('requestExample').optional().default('requestExample'),\n requestUid: z.string().brand<ENTITY_BRANDS['OPERATION']>().optional(),\n name: z.string().optional().default('Name'),\n body: exampleRequestBodySchema.optional().default({}),\n parameters: z\n .object({\n path: requestExampleParametersSchema.array().default([]),\n query: requestExampleParametersSchema.array().default([]),\n headers: requestExampleParametersSchema.array().default([{ key: 'Accept', value: '*/*', enabled: true }]),\n cookies: requestExampleParametersSchema.array().default([]),\n })\n .optional()\n .default({}),\n /** TODO: Should this be deprecated? */\n serverVariables: z.record(z.string(), z.array(z.string())).optional(),\n})\n\nexport type RequestExample = z.infer<typeof requestExampleSchema>\n\n/** For OAS serialization we just store the simple key/value pairs */\nconst xScalarExampleParameterSchema = z.record(z.string(), z.string()).optional()\n\n/** Schema for the OAS serialization of request examples */\nexport const xScalarExampleSchema = z.object({\n /** TODO: Should this be required? */\n name: z.string().optional(),\n body: xScalarExampleBodySchema.optional(),\n parameters: z.object({\n path: xScalarExampleParameterSchema,\n query: xScalarExampleParameterSchema,\n headers: xScalarExampleParameterSchema,\n cookies: xScalarExampleParameterSchema,\n }),\n})\n\nexport type XScalarExample = z.infer<typeof xScalarExampleSchema>\n\n/**\n * Convert a request example to the xScalar serialized format\n *\n * TODO: The base format should be migrated to align MUCH closer to the serialized format\n */\nexport function convertExampleToXScalar(example: RequestExample) {\n const active = example.body?.activeBody\n\n const xScalarBody: XScalarExampleBody = {\n encoding: 'text/plain',\n content: '',\n }\n\n if (example.body?.activeBody === 'binary') {\n xScalarBody.encoding = 'binary'\n // TODO: Need to allow users to set these properties\n xScalarBody.file = null\n }\n\n if (active === 'formData' && example.body?.[active]) {\n const body = example.body[active]\n xScalarBody.encoding = body.encoding === 'form-data' ? 'multipart/form-data' : 'application/x-www-form-urlencoded'\n\n // TODO: Need to allow users to set these properties\n xScalarBody.content = body.value.reduce<Record<string, XScalarFormDataValue>>((map, param) => {\n /** TODO: We need to ensure only file or value is set */\n map[param.key] = param.file\n ? {\n type: 'file',\n file: null,\n }\n : {\n type: 'string',\n value: param.value,\n }\n return map\n }, {})\n }\n\n if (example.body?.activeBody === 'raw') {\n xScalarBody.encoding = contentMapping[example.body.raw?.encoding ?? 'text'] ?? 'text/plain'\n\n xScalarBody.content = example.body.raw?.value ?? ''\n }\n\n const parameters: XScalarExample['parameters'] = {}\n\n keysOf(example.parameters ?? {}).forEach((key) => {\n if (example.parameters?.[key].length) {\n parameters[key] = parameterArrayToObject(example.parameters[key])\n }\n })\n\n return xScalarExampleSchema.parse({\n /** Only add the body if we have content or the body should be a file */\n body: xScalarBody.content || xScalarBody.encoding === 'binary' ? xScalarBody : undefined,\n parameters,\n })\n}\n\n// ---------------------------------------------------------------------------\n// Example Helpers\n\n/** Create new instance parameter from a request parameter */\nexport function createParamInstance(param: RequestParameter) {\n const schema = param.schema as any\n\n const firstExample = (() => {\n if (param.examples && !Array.isArray(param.examples) && getObjectKeys(param.examples).length > 0) {\n const exampleValues = Object.entries(param.examples).map(([_, example]) => {\n // returns the external value if it exists\n if (example.externalValue) {\n return example.externalValue\n }\n\n // returns the value if it exists and is defined\n // e.g. { examples: { foo: { value: 'bar' } } } would return ['bar']\n return example.value\n })\n\n // returns the first example as selected value along other examples\n return { value: exampleValues[0], examples: exampleValues }\n }\n\n // param example e.g. { example: 'foo' }\n if (isDefined(param.example)) {\n return { value: param.example }\n }\n\n // param examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(param.examples) && param.examples.length > 0) {\n return { value: param.examples[0] }\n }\n\n // schema example e.g. { example: 'foo' } while being discouraged\n // see https://spec.openapis.org/oas/v3.1.1.html#fixed-fields-20\n if (isDefined(schema?.example)) {\n return { value: schema.example }\n }\n\n // schema examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(schema?.examples) && schema.examples.length > 0) {\n // For boolean type, default to false when using schema examples\n if (schema?.type === 'boolean') {\n return { value: schema.default ?? false }\n }\n return { value: schema.examples[0] }\n }\n\n // content examples e.g. { content: { 'application/json': { examples: { foo: { value: 'bar' } } } } }\n if (param.content) {\n const firstContentType = getObjectKeys(param.content)[0]\n if (firstContentType) {\n const content = (param.content as ParameterContent)[firstContentType]\n if (content?.examples) {\n const firstExampleKey = Object.keys(content.examples)[0]\n if (firstExampleKey) {\n const example = content.examples[firstExampleKey]\n if (isDefined(example?.value)) {\n return { value: example.value }\n }\n }\n }\n // content example e.g. { example: 'foo' }\n if (isDefined(content?.example)) {\n return { value: content.example }\n }\n }\n }\n\n return null\n })() as null | { value: any; examples?: string[] }\n\n /**\n * TODO:\n * - Need better value defaulting here\n * - Need to handle non-string parameters much better\n * - Need to handle unions/array values for schema\n */\n const value = String(firstExample?.value ?? schema?.default ?? '')\n\n // Handle non-string enums and enums within items for array types\n const parseEnum = (() => {\n if (schema?.enum && schema?.type !== 'string') {\n return schema.enum?.map(String)\n }\n\n if (schema?.items?.enum && schema?.type === 'array') {\n return schema.items.enum.map(String)\n }\n\n return schema?.enum\n })()\n\n // Handle parameter examples\n const examples =\n firstExample?.examples ||\n (schema?.examples && schema?.type !== 'string' ? schema.examples?.map(String) : schema?.examples)\n\n // safe parse the example\n const example = schemaModel(\n {\n ...schema,\n key: param.name,\n value,\n description: param.description,\n required: param.required,\n /** Initialized all required properties to enabled */\n enabled: !!param.required,\n enum: parseEnum,\n examples,\n },\n requestExampleParametersSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${param.name} is invalid.`)\n return requestExampleParametersSchema.parse({})\n }\n\n return example\n}\n\n/**\n * Create new request example from a request\n * Iterates the name of the example if provided\n */\nexport function createExampleFromRequest(request: Request, name: string, server?: Server): RequestExample {\n // ---------------------------------------------------------------------------\n // Populate all parameters with an example value\n const parameters: Record<'path' | 'cookie' | 'header' | 'query' | 'headers', RequestExampleParameter[]> = {\n path: [],\n query: [],\n cookie: [],\n // deprecated TODO: add zod transform to remove\n header: [],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n }\n\n // Populated the separated params\n request.parameters?.forEach((p) => parameters[p.in].push(createParamInstance(p)))\n\n // TODO: add zod transform to remove header and only support headers\n if (parameters.header.length > 0) {\n parameters.headers = parameters.header\n parameters.header = []\n }\n\n // Get content type header\n const contentTypeHeader = parameters.headers.find((h) => h.key.toLowerCase() === 'content-type')\n\n // ---------------------------------------------------------------------------\n // Handle request body defaulting for various content type encodings\n const body: ExampleRequestBody = {\n activeBody: 'raw',\n }\n\n // If we have a request body or a content type header\n if (request.requestBody || contentTypeHeader?.value) {\n const requestBody = getRequestBodyFromOperation({\n path: request.path,\n information: {\n requestBody: request.requestBody,\n },\n })\n\n const contentType = request.requestBody ? requestBody?.mimeType : contentTypeHeader?.value\n\n // Handle JSON and JSON-like mimetypes\n if (contentType?.includes('/json') || contentType?.endsWith('+json')) {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'json',\n mimeType: contentType,\n value: requestBody?.text ?? JSON.stringify({}),\n }\n }\n\n if (contentType === 'application/xml') {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'xml',\n value: requestBody?.text ?? '',\n }\n }\n\n /**\n * TODO: Are we loading example files from somewhere based on the spec?\n * How are we handling the body values\n */\n if (contentType === 'application/octet-stream') {\n body.activeBody = 'binary'\n body.binary = undefined\n }\n\n if (contentType === 'application/x-www-form-urlencoded' || contentType === 'multipart/form-data') {\n body.activeBody = 'formData'\n body.formData = {\n encoding: contentType === 'application/x-www-form-urlencoded' ? 'urlencoded' : 'form-data',\n value: (requestBody?.params || []).map((param) => {\n if (param.value instanceof File) {\n return {\n key: param.name,\n value: 'BINARY',\n file: param.value,\n enabled: true,\n }\n }\n return {\n key: param.name,\n value: param.value || '',\n enabled: true,\n }\n }),\n }\n }\n\n // Add the content-type header if it doesn't exist\n if (requestBody?.mimeType && !contentTypeHeader) {\n parameters.headers.push({\n key: 'Content-Type',\n value: requestBody.mimeType,\n enabled: true,\n })\n }\n }\n\n const serverVariables = server ? getServerVariableExamples(server) : {}\n\n // safe parse the example\n const example = schemaModel(\n {\n requestUid: request.uid,\n parameters,\n name,\n body,\n serverVariables,\n },\n requestExampleSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${request.uid} is invalid.`)\n return requestExampleSchema.parse({})\n }\n return example\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,iCAAiC;AAC1C,SAAS,cAAc;AACvB,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AAElB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,SAAS,mCAAmC;AAcrC,MAAM,iCAAiC,EAC3C,OAAO;AAAA,EACN,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA,EAC1B,OAAO,EAAE,OAAO,OAAO,EAAE,QAAQ,EAAE;AAAA,EACnC,SAAS,EAAE,QAAQ,EAAE,QAAQ,IAAI;AAAA,EACjC,MAAM,EAAE,IAAI,EAAE,SAAS;AAAA,EACvB,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACnC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACpC,MAAM,EACH,MAAM;AAAA;AAAA,IAEL,EAAE,OAAO;AAAA;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AAAA,IACF;AAGA,QAAI,aAAa,YAAY,CAAC,
|
|
4
|
+
"sourcesContent": ["import { schemaModel } from '@/helpers/schema-model'\nimport { getServerVariableExamples } from '@/spec-getters/get-server-variable-examples'\nimport { keysOf } from '@scalar/object-utils/arrays'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { z } from 'zod'\n\nimport { isDefined } from '@/helpers/is-defined'\nimport { getObjectKeys } from '@/helpers/object'\n\nimport { getRequestBodyFromOperation } from '@/spec-getters/get-request-body-from-operation'\nimport type { RequestParameter, ParameterContent } from './parameters'\nimport type { Request } from './requests'\nimport type { Server } from './server'\n\n// ---------------------------------------------------------------------------\n// Example Parameters\n\n/**\n * TODO: Deprecate this.\n *\n * The request schema should be stored in the request and any\n * parameters should be validated against that\n */\nexport const requestExampleParametersSchema = z\n .object({\n key: z.string().default(''),\n value: z.coerce.string().default(''),\n enabled: z.boolean().default(true),\n file: z.any().optional(),\n description: z.string().optional(),\n required: z.boolean().optional(),\n enum: z.array(z.string()).optional(),\n examples: z.array(z.any()).optional(),\n type: z\n .union([\n // 'string'\n z.string(),\n // ['string', 'null']\n z.array(z.string()),\n ])\n .optional(),\n format: z.string().optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n default: z.any().optional(),\n nullable: z.boolean().optional(),\n })\n // set nullable: to true if type is ['string', 'null']\n .transform((_data) => {\n const data = { ..._data }\n\n // type: ['string', 'null'] -> nullable: true\n if (Array.isArray(data.type) && data.type.includes('null')) {\n data.nullable = true\n }\n\n // Hey, if it's just one value and 'null', we can make it a string and ditch the 'null'.\n if (Array.isArray(data.type) && data.type.length === 2 && data.type.includes('null')) {\n data.type = data.type.find((item) => item !== 'null')\n }\n\n return data\n })\n\n/** Convert the array of parameters to an object keyed by the parameter name */\nexport const parameterArrayToObject = (params: RequestExampleParameter[]) =>\n params.reduce<Record<string, string>>((map, param) => {\n map[param.key] = param.value\n return map\n }, {})\n\n/** Request examples - formerly known as instances - are \"children\" of requests */\nexport type RequestExampleParameter = z.infer<typeof requestExampleParametersSchema>\n\nexport const xScalarFileValueSchema = z\n .object({\n url: z.string(),\n base64: z.string().optional(),\n })\n .nullable()\n\n/**\n * When files are required for an example we provide the options\n * to provide a public URL or a base64 encoded string\n */\nexport type XScalarFileValue = z.infer<typeof xScalarFileValueSchema>\n\n/**\n * Schema for the OAS serialization of request example parameters\n *\n * File values can be optionally fetched on import OR inserted as a base64 encoded string\n */\nexport const xScalarFormDataValue = z.union([\n z.object({\n type: z.literal('string'),\n value: z.string(),\n }),\n z.object({\n type: z.literal('file'),\n file: xScalarFileValueSchema,\n }),\n])\n\nexport type XScalarFormDataValue = z.infer<typeof xScalarFormDataValue>\n\n// ---------------------------------------------------------------------------\n// Example Body\n\n/**\n * Possible encodings for example request bodies when using text formats\n *\n * TODO: This list may not be comprehensive enough\n */\nexport const exampleRequestBodyEncoding = ['json', 'text', 'html', 'javascript', 'xml', 'yaml', 'edn'] as const\n\nexport type BodyEncoding = (typeof exampleRequestBodyEncoding)[number]\n\nexport const exampleBodyMime = [\n 'application/json',\n 'text/plain',\n 'text/html',\n 'application/javascript',\n 'application/xml',\n 'application/yaml',\n 'application/edn',\n 'application/octet-stream',\n 'application/x-www-form-urlencoded',\n 'multipart/form-data',\n /** Used for direct files */\n 'binary',\n] as const\n\nexport type BodyMime = (typeof exampleBodyMime)[number]\n\nconst contentMapping: Record<BodyEncoding, BodyMime> = {\n json: 'application/json',\n text: 'text/plain',\n html: 'text/html',\n javascript: 'application/javascript',\n xml: 'application/xml',\n yaml: 'application/yaml',\n edn: 'application/edn',\n} as const\n\n/**\n * TODO: Migrate away from this layout to the format used in the extension\n *\n * If a user changes the encoding of the body we expect the content to change as well\n */\nexport const exampleRequestBodySchema = z.object({\n raw: z\n .object({\n encoding: z.enum(exampleRequestBodyEncoding),\n value: z.string().default(''),\n mimeType: z.string().optional(),\n })\n .optional(),\n formData: z\n .object({\n encoding: z.union([z.literal('form-data'), z.literal('urlencoded')]).default('form-data'),\n value: requestExampleParametersSchema.array().default([]),\n })\n .optional(),\n binary: z.instanceof(Blob).optional(),\n activeBody: z.union([z.literal('raw'), z.literal('formData'), z.literal('binary')]).default('raw'),\n})\n\nexport type ExampleRequestBody = z.infer<typeof exampleRequestBodySchema>\n\n/** Schema for the OAS serialization of request example bodies */\nexport const xScalarExampleBodySchema = z.object({\n encoding: z.enum(exampleBodyMime),\n /**\n * Body content as an object with a separately specified encoding or a simple pre-encoded string value\n *\n * Ideally we would convert any objects into the proper encoding on import\n */\n content: z.union([z.record(z.string(), z.any()), z.string()]),\n /** When the encoding is `binary` this will be used to link to the file */\n file: xScalarFileValueSchema.optional(),\n})\n\nexport type XScalarExampleBody = z.infer<typeof xScalarExampleBodySchema>\n\n// ---------------------------------------------------------------------------\n// Example Schema\n\nexport const requestExampleSchema = z.object({\n uid: nanoidSchema.brand<ENTITY_BRANDS['EXAMPLE']>(),\n type: z.literal('requestExample').optional().default('requestExample'),\n requestUid: z.string().brand<ENTITY_BRANDS['OPERATION']>().optional(),\n name: z.string().optional().default('Name'),\n body: exampleRequestBodySchema.optional().default({}),\n parameters: z\n .object({\n path: requestExampleParametersSchema.array().default([]),\n query: requestExampleParametersSchema.array().default([]),\n headers: requestExampleParametersSchema.array().default([{ key: 'Accept', value: '*/*', enabled: true }]),\n cookies: requestExampleParametersSchema.array().default([]),\n })\n .optional()\n .default({}),\n /** TODO: Should this be deprecated? */\n serverVariables: z.record(z.string(), z.array(z.string())).optional(),\n})\n\nexport type RequestExample = z.infer<typeof requestExampleSchema>\n\n/** For OAS serialization we just store the simple key/value pairs */\nconst xScalarExampleParameterSchema = z.record(z.string(), z.string()).optional()\n\n/** Schema for the OAS serialization of request examples */\nexport const xScalarExampleSchema = z.object({\n /** TODO: Should this be required? */\n name: z.string().optional(),\n body: xScalarExampleBodySchema.optional(),\n parameters: z.object({\n path: xScalarExampleParameterSchema,\n query: xScalarExampleParameterSchema,\n headers: xScalarExampleParameterSchema,\n cookies: xScalarExampleParameterSchema,\n }),\n})\n\nexport type XScalarExample = z.infer<typeof xScalarExampleSchema>\n\n/**\n * Convert a request example to the xScalar serialized format\n *\n * TODO: The base format should be migrated to align MUCH closer to the serialized format\n */\nexport function convertExampleToXScalar(example: RequestExample) {\n const active = example.body?.activeBody\n\n const xScalarBody: XScalarExampleBody = {\n encoding: 'text/plain',\n content: '',\n }\n\n if (example.body?.activeBody === 'binary') {\n xScalarBody.encoding = 'binary'\n // TODO: Need to allow users to set these properties\n xScalarBody.file = null\n }\n\n if (active === 'formData' && example.body?.[active]) {\n const body = example.body[active]\n xScalarBody.encoding = body.encoding === 'form-data' ? 'multipart/form-data' : 'application/x-www-form-urlencoded'\n\n // TODO: Need to allow users to set these properties\n xScalarBody.content = body.value.reduce<Record<string, XScalarFormDataValue>>((map, param) => {\n /** TODO: We need to ensure only file or value is set */\n map[param.key] = param.file\n ? {\n type: 'file',\n file: null,\n }\n : {\n type: 'string',\n value: param.value,\n }\n return map\n }, {})\n }\n\n if (example.body?.activeBody === 'raw') {\n xScalarBody.encoding = contentMapping[example.body.raw?.encoding ?? 'text'] ?? 'text/plain'\n\n xScalarBody.content = example.body.raw?.value ?? ''\n }\n\n const parameters: XScalarExample['parameters'] = {}\n\n keysOf(example.parameters ?? {}).forEach((key) => {\n if (example.parameters?.[key].length) {\n parameters[key] = parameterArrayToObject(example.parameters[key])\n }\n })\n\n return xScalarExampleSchema.parse({\n /** Only add the body if we have content or the body should be a file */\n body: xScalarBody.content || xScalarBody.encoding === 'binary' ? xScalarBody : undefined,\n parameters,\n })\n}\n\n// ---------------------------------------------------------------------------\n// Example Helpers\n\n/** Create new instance parameter from a request parameter */\nexport function createParamInstance(param: RequestParameter) {\n const schema = param.schema as any\n\n const firstExample = (() => {\n if (param.examples && !Array.isArray(param.examples) && getObjectKeys(param.examples).length > 0) {\n const exampleValues = Object.entries(param.examples).map(([_, example]) => {\n // returns the external value if it exists\n if (example.externalValue) {\n return example.externalValue\n }\n\n // returns the value if it exists and is defined\n // e.g. { examples: { foo: { value: 'bar' } } } would return ['bar']\n return example.value\n })\n\n // returns the first example as selected value along other examples\n return { value: exampleValues[0], examples: exampleValues }\n }\n\n // param example e.g. { example: 'foo' }\n if (isDefined(param.example)) {\n return { value: param.example }\n }\n\n // param examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(param.examples) && param.examples.length > 0) {\n return { value: param.examples[0] }\n }\n\n // schema example e.g. { example: 'foo' } while being discouraged\n // see https://spec.openapis.org/oas/v3.1.1.html#fixed-fields-20\n if (isDefined(schema?.example)) {\n return { value: schema.example }\n }\n\n // schema examples e.g. { examples: ['foo', 'bar'] }\n if (Array.isArray(schema?.examples) && schema.examples.length > 0) {\n // For boolean type, default to false when using schema examples\n if (schema?.type === 'boolean') {\n return { value: schema.default ?? false }\n }\n return { value: schema.examples[0] }\n }\n\n // content examples e.g. { content: { 'application/json': { examples: { foo: { value: 'bar' } } } } }\n if (param.content) {\n const firstContentType = getObjectKeys(param.content)[0]\n if (firstContentType) {\n const content = (param.content as ParameterContent)[firstContentType]\n if (content?.examples) {\n const firstExampleKey = Object.keys(content.examples)[0]\n if (firstExampleKey) {\n const example = content.examples[firstExampleKey]\n if (isDefined(example?.value)) {\n return { value: example.value }\n }\n }\n }\n // content example e.g. { example: 'foo' }\n if (isDefined(content?.example)) {\n return { value: content.example }\n }\n }\n }\n\n return null\n })() as null | { value: any; examples?: string[] }\n\n /**\n * TODO:\n * - Need better value defaulting here\n * - Need to handle non-string parameters much better\n * - Need to handle unions/array values for schema\n */\n const value = String(firstExample?.value ?? schema?.default ?? '')\n\n // Handle non-string enums and enums within items for array types\n const parseEnum = (() => {\n if (schema?.enum && schema?.type !== 'string') {\n return schema.enum?.map(String)\n }\n\n if (schema?.items?.enum && schema?.type === 'array') {\n return schema.items.enum.map(String)\n }\n\n return schema?.enum\n })()\n\n // Handle parameter examples\n const examples =\n firstExample?.examples ||\n (schema?.examples && schema?.type !== 'string' ? schema.examples?.map(String) : schema?.examples)\n\n // safe parse the example\n const example = schemaModel(\n {\n ...schema,\n key: param.name,\n value,\n description: param.description,\n required: param.required,\n /** Initialized all required properties to enabled */\n enabled: !!param.required,\n enum: parseEnum,\n examples,\n },\n requestExampleParametersSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${param.name} is invalid.`)\n return requestExampleParametersSchema.parse({})\n }\n\n return example\n}\n\n/**\n * Create new request example from a request\n * Iterates the name of the example if provided\n */\nexport function createExampleFromRequest(request: Request, name: string, server?: Server): RequestExample {\n // ---------------------------------------------------------------------------\n // Populate all parameters with an example value\n const parameters: Record<'path' | 'cookie' | 'header' | 'query' | 'headers', RequestExampleParameter[]> = {\n path: [],\n query: [],\n cookie: [],\n // deprecated TODO: add zod transform to remove\n header: [],\n headers: [{ key: 'Accept', value: '*/*', enabled: true }],\n }\n\n // Populated the separated params\n request.parameters?.forEach((p) => parameters[p.in].push(createParamInstance(p)))\n\n // TODO: add zod transform to remove header and only support headers\n if (parameters.header.length > 0) {\n parameters.headers = parameters.header\n parameters.header = []\n }\n\n // Get content type header\n const contentTypeHeader = parameters.headers.find((h) => h.key.toLowerCase() === 'content-type')\n\n // ---------------------------------------------------------------------------\n // Handle request body defaulting for various content type encodings\n const body: ExampleRequestBody = {\n activeBody: 'raw',\n }\n\n // If we have a request body or a content type header\n if (request.requestBody || contentTypeHeader?.value) {\n const requestBody = getRequestBodyFromOperation({\n path: request.path,\n information: {\n requestBody: request.requestBody,\n },\n })\n\n const contentType = request.requestBody ? requestBody?.mimeType : contentTypeHeader?.value\n\n // Handle JSON and JSON-like mimetypes\n if (contentType?.includes('/json') || contentType?.endsWith('+json')) {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'json',\n mimeType: contentType,\n value: requestBody?.text ?? JSON.stringify({}),\n }\n }\n\n if (contentType === 'application/xml') {\n body.activeBody = 'raw'\n body.raw = {\n encoding: 'xml',\n value: requestBody?.text ?? '',\n }\n }\n\n /**\n * TODO: Are we loading example files from somewhere based on the spec?\n * How are we handling the body values\n */\n if (contentType === 'application/octet-stream') {\n body.activeBody = 'binary'\n body.binary = undefined\n }\n\n if (contentType === 'application/x-www-form-urlencoded' || contentType === 'multipart/form-data') {\n body.activeBody = 'formData'\n body.formData = {\n encoding: contentType === 'application/x-www-form-urlencoded' ? 'urlencoded' : 'form-data',\n value: (requestBody?.params || []).map((param) => {\n if (param.value instanceof File) {\n return {\n key: param.name,\n value: 'BINARY',\n file: param.value,\n enabled: true,\n }\n }\n return {\n key: param.name,\n value: param.value || '',\n enabled: true,\n }\n }),\n }\n }\n\n // Add the content-type header if it doesn't exist and if it's not multipart request\n if (requestBody?.mimeType && !contentTypeHeader && !requestBody.mimeType.startsWith('multipart/')) {\n parameters.headers.push({\n key: 'Content-Type',\n value: requestBody.mimeType,\n enabled: true,\n })\n }\n }\n\n const serverVariables = server ? getServerVariableExamples(server) : {}\n\n // safe parse the example\n const example = schemaModel(\n {\n requestUid: request.uid,\n parameters,\n name,\n body,\n serverVariables,\n },\n requestExampleSchema,\n false,\n )\n\n if (!example) {\n console.warn(`Example at ${request.uid} is invalid.`)\n return requestExampleSchema.parse({})\n }\n return example\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,iCAAiC;AAC1C,SAAS,cAAc;AACvB,SAA6B,oBAAoB;AACjD,SAAS,SAAS;AAElB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,SAAS,mCAAmC;AAcrC,MAAM,iCAAiC,EAC3C,OAAO;AAAA,EACN,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE;AAAA,EAC1B,OAAO,EAAE,OAAO,OAAO,EAAE,QAAQ,EAAE;AAAA,EACnC,SAAS,EAAE,QAAQ,EAAE,QAAQ,IAAI;AAAA,EACjC,MAAM,EAAE,IAAI,EAAE,SAAS;AAAA,EACvB,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,MAAM,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,MAAM;AAAA,cACZ,SAAS;AAAA,YACX;AAAA,UACF;AACA,iBAAO;AAAA,YACL,KAAK,MAAM;AAAA,YACX,OAAO,MAAM,SAAS;AAAA,YACtB,SAAS;AAAA,UACX;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAGA,QAAI,aAAa,YAAY,CAAC,qBAAqB,CAAC,YAAY,SAAS,WAAW,YAAY,GAAG;AACjG,iBAAW,QAAQ,KAAK;AAAA,QACtB,KAAK;AAAA,QACL,OAAO,YAAY;AAAA,QACnB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,kBAAkB,SAAS,0BAA0B,MAAM,IAAI,CAAC;AAGtE,QAAM,UAAU;AAAA,IACd;AAAA,MACE,YAAY,QAAQ;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,CAAC,SAAS;AACZ,YAAQ,KAAK,cAAc,QAAQ,GAAG,cAAc;AACpD,WAAO,qBAAqB,MAAM,CAAC,CAAC;AAAA,EACtC;AACA,SAAO;AACT;",
|
|
6
6
|
"names": ["example"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { type PostResponseSchema, XPostResponseSchema } from '@scalar/openapi-types/schemas/extensions';
|
|
2
3
|
import { XScalarStability } from '@scalar/types';
|
|
3
4
|
import { type RequestExample } from './request-examples.js';
|
|
4
5
|
export declare const requestMethods: readonly ["connect", "delete", "get", "head", "options", "patch", "post", "put", "trace"];
|
|
@@ -13,6 +14,8 @@ export type ResponseInstance = Omit<Response, 'headers'> & {
|
|
|
13
14
|
duration: number;
|
|
14
15
|
/** The response status */
|
|
15
16
|
status: number;
|
|
17
|
+
/** The response status text */
|
|
18
|
+
statusText: string;
|
|
16
19
|
/** The response method */
|
|
17
20
|
method: RequestMethod;
|
|
18
21
|
/** The request path */
|
|
@@ -78,6 +81,7 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
78
81
|
schema: z.ZodOptional<z.ZodUnknown>;
|
|
79
82
|
content: z.ZodOptional<z.ZodUnknown>;
|
|
80
83
|
style: z.ZodOptional<z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
|
|
84
|
+
explode: z.ZodOptional<z.ZodBoolean>;
|
|
81
85
|
example: z.ZodOptional<z.ZodUnknown>;
|
|
82
86
|
examples: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
83
87
|
value: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -107,6 +111,7 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
107
111
|
schema?: unknown;
|
|
108
112
|
content?: unknown;
|
|
109
113
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
114
|
+
explode?: boolean | undefined;
|
|
110
115
|
}, {
|
|
111
116
|
name: string;
|
|
112
117
|
in: "cookie" | "path" | "query" | "header";
|
|
@@ -122,6 +127,7 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
122
127
|
schema?: unknown;
|
|
123
128
|
content?: unknown;
|
|
124
129
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
130
|
+
explode?: boolean | undefined;
|
|
125
131
|
}>, "many">>;
|
|
126
132
|
/**
|
|
127
133
|
* External documentation object
|
|
@@ -145,6 +151,8 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
145
151
|
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
146
152
|
/** Response formats */
|
|
147
153
|
responses: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
154
|
+
/** Callbacks */
|
|
155
|
+
callbacks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>>;
|
|
148
156
|
/** xScalar examples */
|
|
149
157
|
'x-scalar-examples': z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
150
158
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -227,6 +235,7 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
227
235
|
}>>>;
|
|
228
236
|
/** Hide operations */
|
|
229
237
|
'x-internal': z.ZodOptional<z.ZodBoolean>;
|
|
238
|
+
/** Ignore operations */
|
|
230
239
|
'x-scalar-ignore': z.ZodOptional<z.ZodBoolean>;
|
|
231
240
|
}, "strip", z.ZodTypeAny, {
|
|
232
241
|
description?: string | undefined;
|
|
@@ -256,9 +265,11 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
256
265
|
schema?: unknown;
|
|
257
266
|
content?: unknown;
|
|
258
267
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
268
|
+
explode?: boolean | undefined;
|
|
259
269
|
}[] | undefined;
|
|
260
270
|
requestBody?: any;
|
|
261
271
|
responses?: Record<string, any> | undefined;
|
|
272
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
262
273
|
'x-scalar-examples'?: Record<string, {
|
|
263
274
|
parameters: {
|
|
264
275
|
path?: Record<string, string> | undefined;
|
|
@@ -304,9 +315,11 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
304
315
|
schema?: unknown;
|
|
305
316
|
content?: unknown;
|
|
306
317
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
318
|
+
explode?: boolean | undefined;
|
|
307
319
|
}[] | undefined;
|
|
308
320
|
requestBody?: any;
|
|
309
321
|
responses?: Record<string, any> | undefined;
|
|
322
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
310
323
|
'x-scalar-examples'?: Record<string, {
|
|
311
324
|
parameters: {
|
|
312
325
|
path?: Record<string, string> | undefined;
|
|
@@ -325,8 +338,10 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
325
338
|
} | undefined;
|
|
326
339
|
}> | undefined;
|
|
327
340
|
}>;
|
|
341
|
+
export type PostResponseScript = z.infer<typeof PostResponseSchema>;
|
|
342
|
+
export type PostResponseScripts = z.infer<typeof XPostResponseSchema>['x-post-response'];
|
|
328
343
|
/** Unified request schema for client usage */
|
|
329
|
-
export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<Omit<{
|
|
344
|
+
export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<z.objectUtil.extendShape<Omit<{
|
|
330
345
|
/**
|
|
331
346
|
* A list of tags for API documentation control. Tags can be used for logical
|
|
332
347
|
* grouping of operations by resources or any other qualifier.
|
|
@@ -371,6 +386,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
371
386
|
schema: z.ZodOptional<z.ZodUnknown>;
|
|
372
387
|
content: z.ZodOptional<z.ZodUnknown>;
|
|
373
388
|
style: z.ZodOptional<z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
|
|
389
|
+
explode: z.ZodOptional<z.ZodBoolean>;
|
|
374
390
|
example: z.ZodOptional<z.ZodUnknown>;
|
|
375
391
|
examples: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
376
392
|
value: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -400,6 +416,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
400
416
|
schema?: unknown;
|
|
401
417
|
content?: unknown;
|
|
402
418
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
419
|
+
explode?: boolean | undefined;
|
|
403
420
|
}, {
|
|
404
421
|
name: string;
|
|
405
422
|
in: "cookie" | "path" | "query" | "header";
|
|
@@ -415,6 +432,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
415
432
|
schema?: unknown;
|
|
416
433
|
content?: unknown;
|
|
417
434
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
435
|
+
explode?: boolean | undefined;
|
|
418
436
|
}>, "many">>;
|
|
419
437
|
/**
|
|
420
438
|
* External documentation object
|
|
@@ -438,6 +456,8 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
438
456
|
deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
439
457
|
/** Response formats */
|
|
440
458
|
responses: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
459
|
+
/** Callbacks */
|
|
460
|
+
callbacks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>>;
|
|
441
461
|
/** xScalar examples */
|
|
442
462
|
'x-scalar-examples': z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
443
463
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -520,6 +540,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
520
540
|
}>>>;
|
|
521
541
|
/** Hide operations */
|
|
522
542
|
'x-internal': z.ZodOptional<z.ZodBoolean>;
|
|
543
|
+
/** Ignore operations */
|
|
523
544
|
'x-scalar-ignore': z.ZodOptional<z.ZodBoolean>;
|
|
524
545
|
}, "x-scalar-examples">, {
|
|
525
546
|
'x-codeSamples': z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -535,23 +556,21 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
535
556
|
label?: unknown;
|
|
536
557
|
lang?: unknown;
|
|
537
558
|
}>, "many">>>;
|
|
538
|
-
'x-code-samples': z.ZodCatch<z.ZodOptional<z.ZodArray
|
|
559
|
+
'x-code-samples': z.ZodCatch<z.ZodOptional<z.ZodArray /** Store headers as an object to match what we had with axios */<z.ZodObject<{
|
|
539
560
|
lang: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
540
|
-
label: z.ZodCatch<z.ZodOptional<z.ZodString
|
|
561
|
+
label: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
541
562
|
source: z.ZodString;
|
|
542
563
|
}, "strip", z.ZodTypeAny, {
|
|
543
564
|
source: string;
|
|
544
|
-
label
|
|
565
|
+
label?: string | undefined;
|
|
545
566
|
lang?: string | undefined;
|
|
546
567
|
}, {
|
|
547
568
|
source: string;
|
|
548
569
|
label?: unknown;
|
|
549
570
|
lang?: unknown;
|
|
550
571
|
}>, "many">>>;
|
|
551
|
-
'x-custom-examples': z.ZodCatch<z.ZodOptional<z.ZodArray
|
|
552
|
-
lang:
|
|
553
|
-
/** A stream reader for a streamable response body */
|
|
554
|
-
z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
572
|
+
'x-custom-examples': z.ZodCatch<z.ZodOptional<z.ZodArray /** The response data */<z.ZodObject<{
|
|
573
|
+
lang: z.ZodCatch<z.ZodOptional<z.ZodString /** The response size in bytes */>>;
|
|
555
574
|
label: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
556
575
|
source: z.ZodString;
|
|
557
576
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -580,6 +599,8 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
580
599
|
examples: z.ZodDefault<z.ZodArray<z.ZodBranded<z.ZodString, "example">, "many">>;
|
|
581
600
|
/** List of security scheme UIDs associated with the request */
|
|
582
601
|
selectedSecuritySchemeUids: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodBranded<z.ZodString, "securityScheme">, z.ZodArray<z.ZodBranded<z.ZodString, "securityScheme">, "many">]>, "many">>;
|
|
602
|
+
}>, {
|
|
603
|
+
'x-post-response': z.ZodOptional<z.ZodString>;
|
|
583
604
|
}>, "strip", z.ZodTypeAny, {
|
|
584
605
|
uid: string & z.BRAND<"operation">;
|
|
585
606
|
path: string;
|
|
@@ -616,10 +637,13 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
616
637
|
schema?: unknown;
|
|
617
638
|
content?: unknown;
|
|
618
639
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
640
|
+
explode?: boolean | undefined;
|
|
619
641
|
}[] | undefined;
|
|
620
642
|
requestBody?: any;
|
|
621
643
|
responses?: Record<string, any> | undefined;
|
|
644
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
622
645
|
'x-scalar-stability'?: XScalarStability | undefined;
|
|
646
|
+
'x-post-response'?: string | undefined;
|
|
623
647
|
'x-codeSamples'?: {
|
|
624
648
|
source: string;
|
|
625
649
|
label?: string | undefined;
|
|
@@ -670,11 +694,14 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
670
694
|
schema?: unknown;
|
|
671
695
|
content?: unknown;
|
|
672
696
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
697
|
+
explode?: boolean | undefined;
|
|
673
698
|
}[] | undefined;
|
|
674
699
|
requestBody?: any;
|
|
675
700
|
responses?: Record<string, any> | undefined;
|
|
701
|
+
callbacks?: Record<string, Record<string, Record<string, any>>> | undefined;
|
|
676
702
|
'x-scalar-stability'?: unknown;
|
|
677
703
|
method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
|
|
704
|
+
'x-post-response'?: string | undefined;
|
|
678
705
|
'x-codeSamples'?: unknown;
|
|
679
706
|
'x-code-samples'?: unknown;
|
|
680
707
|
'x-custom-examples'?: unknown;
|
|
@@ -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;AAEvC,OAAO,EACL,KAAK,kBAAkB,EAEvB,mBAAmB,EACpB,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAGhD,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,oBAAoB,CAAA;AAG9E,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,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,0BAA0B;IAC1B,MAAM,EAAE,aAAa,CAAA;IACrB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,CACE;IACE,wBAAwB;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,qDAAqD;IACrD,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAA;CAChD,CACJ,CAAA;AAEH,iEAAiE;AACjE,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;;;;;;;;;;;;;;;;;;;EAsJ3B,CAAA;AAE7B,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,7 +1,10 @@
|
|
|
1
1
|
import { selectedSecuritySchemeUidSchema } from "../../entities/shared/utility.js";
|
|
2
2
|
import { nanoidSchema } from "@scalar/types/utils";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
XCodeSamplesSchema,
|
|
6
|
+
XPostResponseSchema
|
|
7
|
+
} from "@scalar/openapi-types/schemas/extensions";
|
|
5
8
|
import { XScalarStability } from "@scalar/types";
|
|
6
9
|
import { oasSecurityRequirementSchema } from "@scalar/types/entities";
|
|
7
10
|
import { oasParameterSchema } from "./parameters.js";
|
|
@@ -53,10 +56,13 @@ const oasRequestSchema = z.object({
|
|
|
53
56
|
"deprecated": z.boolean().optional(),
|
|
54
57
|
/** Response formats */
|
|
55
58
|
"responses": z.record(z.string(), z.any()).optional(),
|
|
59
|
+
/** Callbacks */
|
|
60
|
+
"callbacks": z.record(z.string(), z.record(z.string(), z.record(z.string(), z.any()))).optional(),
|
|
56
61
|
/** xScalar examples */
|
|
57
62
|
"x-scalar-examples": z.record(z.string(), xScalarExampleSchema).optional(),
|
|
58
63
|
/** Hide operations */
|
|
59
64
|
"x-internal": z.boolean().optional(),
|
|
65
|
+
/** Ignore operations */
|
|
60
66
|
"x-scalar-ignore": z.boolean().optional()
|
|
61
67
|
});
|
|
62
68
|
const ScalarStabilitySchema = z.object({
|
|
@@ -78,7 +84,7 @@ const extendedRequestSchema = z.object({
|
|
|
78
84
|
/** List of security scheme UIDs associated with the request */
|
|
79
85
|
selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema
|
|
80
86
|
});
|
|
81
|
-
const requestSchema = oasRequestSchema.omit({ "x-scalar-examples": true }).merge(XCodeSamplesSchema).merge(ScalarStabilitySchema).merge(extendedRequestSchema);
|
|
87
|
+
const requestSchema = oasRequestSchema.omit({ "x-scalar-examples": true }).merge(XCodeSamplesSchema).merge(ScalarStabilitySchema).merge(extendedRequestSchema).merge(XPostResponseSchema);
|
|
82
88
|
export {
|
|
83
89
|
oasRequestSchema,
|
|
84
90
|
requestMethods,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/entities/spec/requests.ts"],
|
|
4
|
-
"sourcesContent": ["import { selectedSecuritySchemeUidSchema } from '@/entities/shared/utility'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { type ZodSchema, z } from 'zod'\n\nimport { XCodeSamplesSchema
|
|
5
|
-
"mappings": "AAAA,SAAS,uCAAuC;AAChD,SAA6B,oBAAoB;AACjD,SAAyB,SAAS;AAElC,
|
|
4
|
+
"sourcesContent": ["import { selectedSecuritySchemeUidSchema } from '@/entities/shared/utility'\nimport { type ENTITY_BRANDS, nanoidSchema } from '@scalar/types/utils'\nimport { type ZodSchema, z } from 'zod'\n\nimport {\n type PostResponseSchema,\n XCodeSamplesSchema,\n XPostResponseSchema,\n} from '@scalar/openapi-types/schemas/extensions'\nimport { XScalarStability } from '@scalar/types'\nimport { oasSecurityRequirementSchema } from '@scalar/types/entities'\nimport { oasParameterSchema } from './parameters'\nimport { type RequestExample, xScalarExampleSchema } from './request-examples'\nimport { oasExternalDocumentationSchema } from './spec-objects'\n\nexport const requestMethods = ['connect', 'delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace'] as const\n\nexport type RequestMethod = (typeof requestMethods)[number]\n\n/** A single set of populated values for a sent request */\nexport type ResponseInstance = Omit<Response, 'headers'> & {\n /** Store headers as an object to match what we had with axios */\n headers: Record<string, string>\n /** Keys of headers which set cookies */\n cookieHeaderKeys: string[]\n /** Time in ms the request took */\n duration: number\n /** The response status */\n status: number\n /** The response status text */\n statusText: string\n /** The response method */\n method: RequestMethod\n /** The request path */\n path: string\n} & (\n | {\n /** The response data */\n data: string | Blob\n /** The response size in bytes */\n size: number\n }\n | {\n /** A stream reader for a streamable response body */\n reader: ReadableStreamDefaultReader<Uint8Array>\n }\n )\n\n/** A single request/response set to save to the history stack */\nexport type RequestEvent = {\n request: RequestExample\n response: ResponseInstance\n timestamp: number\n}\n\n// TODO: Type body definitions\ntype RequestBody = object\nconst requestBodySchema = z.any() satisfies ZodSchema<RequestBody>\n\n/** Open API Compliant Request Validator */\nexport const oasRequestSchema = z.object({\n /**\n * A list of tags for API documentation control. Tags can be used for logical\n * grouping of operations by resources or any other qualifier.\n *\n * These tags are the openapi spec tag names, not uids\n */\n 'tags': z.string().array().optional(),\n /** A short summary of what the operation does. */\n 'summary': z.string().optional(),\n /** A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation. */\n 'description': z.string().optional(),\n /**\n * Unique string used to identify the operation. The id MUST be unique among all operations described in the API.\n * The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an\n * operation, therefore, it is RECOMMENDED to follow bin common programming naming conventions./\n */\n 'operationId': z.string().optional(),\n /**\n * A declaration of which security mechanisms can be used across the API. The list of\n * values includes alternative security requirement objects that can be used. Only\n * one of the security requirement objects need to be satisfied to authorize a request.\n * Individual operations can override this definition. To make security optional, an empty\n * security requirement ({}) can be included in the array.\n */\n 'security': z.array(oasSecurityRequirementSchema).optional(),\n /**\n * The request body applicable for this operation. The requestBody is fully supported in HTTP methods where the\n * HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request bodies. In other cases where the\n * HTTP spec is vague (such as GET, HEAD and DELETE), requestBody is permitted but does not have well-defined\n * semantics and SHOULD be avoided if possible.\n */\n 'requestBody': requestBodySchema.optional(),\n /**\n * Request parameters\n */\n 'parameters': oasParameterSchema.array().optional(),\n /**\n * External documentation object\n */\n 'externalDocs': oasExternalDocumentationSchema.optional(),\n 'deprecated': z.boolean().optional(),\n /** Response formats */\n 'responses': z.record(z.string(), z.any()).optional(),\n /** Callbacks */\n 'callbacks': z.record(z.string(), z.record(z.string(), z.record(z.string(), z.any()))).optional(),\n /** xScalar examples */\n 'x-scalar-examples': z.record(z.string(), xScalarExampleSchema).optional(),\n /** Hide operations */\n 'x-internal': z.boolean().optional(),\n /** Ignore operations */\n 'x-scalar-ignore': z.boolean().optional(),\n})\n\n/**\n * An OpenAPI extension to indicate the stability of the operation\n *\n * @example\n * ```yaml\n * x-scalar-stability: deprecated\n * ```\n */\nconst ScalarStabilitySchema = z.object({\n 'x-scalar-stability': z\n .enum([XScalarStability.Deprecated, XScalarStability.Experimental, XScalarStability.Stable])\n .optional()\n .catch(undefined),\n})\n\n/**\n * Extended properties added to the spec definition for client usage\n *\n * WARNING: DO NOT ADD PROPERTIES THAT SHARE A NAME WITH OAS OPERATION ENTITIES\n *\n * This object is directly converted to a spec operation during saving\n */\nconst extendedRequestSchema = z.object({\n type: z.literal('request').optional().default('request'),\n uid: nanoidSchema.brand<ENTITY_BRANDS['OPERATION']>(),\n /** Path Key */\n path: z.string().optional().default(''),\n /** Request Method */\n method: z.enum(requestMethods).default('get'),\n /** List of server UIDs specific to the request */\n servers: z.string().brand<ENTITY_BRANDS['SERVER']>().array().default([]),\n /** The currently selected server */\n selectedServerUid: z.string().brand<ENTITY_BRANDS['SERVER']>().optional().nullable().default(null),\n /** List of example UIDs associated with the request */\n examples: z.string().brand<ENTITY_BRANDS['EXAMPLE']>().array().default([]),\n /** List of security scheme UIDs associated with the request */\n selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,\n})\n\nexport type PostResponseScript = z.infer<typeof PostResponseSchema>\nexport type PostResponseScripts = z.infer<typeof XPostResponseSchema>['x-post-response']\n\n/** Unified request schema for client usage */\nexport const requestSchema = oasRequestSchema\n .omit({ 'x-scalar-examples': true })\n .merge(XCodeSamplesSchema)\n .merge(ScalarStabilitySchema)\n .merge(extendedRequestSchema)\n .merge(XP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
import type { Operation } from '../../entities/spec/operation.js';
|
|
3
3
|
/** Parses a list of selected security scheme uids which may be an array or single uid and returns a flattened array of security schemes */
|
|
4
4
|
export declare const getSchemes: (selectedSecuritySchemes: Operation["selectedSecuritySchemeUids"], securitySchemes: Record<SecurityScheme["uid"], SecurityScheme>) => NonNullable<{
|
|
5
|
-
name: string;
|
|
6
|
-
value: string;
|
|
7
5
|
type: "apiKey";
|
|
6
|
+
value: string;
|
|
7
|
+
name: string;
|
|
8
8
|
uid: string & import("zod").BRAND<"securityScheme">;
|
|
9
9
|
nameKey: string;
|
|
10
10
|
in: "cookie" | "query" | "header";
|
package/package.json
CHANGED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2
|
|
19
|
+
"version": "0.3.2",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=20"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"main": "dist/index.js",
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
"type-fest": "^4.20.0",
|
|
94
94
|
"yaml": "^2.4.5",
|
|
95
95
|
"zod": "3.24.1",
|
|
96
|
-
"@scalar/object-utils": "1.1
|
|
97
|
-
"@scalar/openapi-types": "0.
|
|
98
|
-
"@scalar/
|
|
99
|
-
"@scalar/
|
|
96
|
+
"@scalar/object-utils": "1.2.1",
|
|
97
|
+
"@scalar/openapi-types": "0.3.1",
|
|
98
|
+
"@scalar/themes": "0.12.1",
|
|
99
|
+
"@scalar/types": "0.2.1"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@types/node": "^20.17.10",
|
|
@@ -104,9 +104,9 @@
|
|
|
104
104
|
"vite": "5.4.19",
|
|
105
105
|
"vitest": "^1.6.0",
|
|
106
106
|
"zod-to-ts": "github:amritk/zod-to-ts#build",
|
|
107
|
-
"@scalar/build-tooling": "0.
|
|
108
|
-
"@scalar/openapi-parser": "0.
|
|
109
|
-
"@scalar/openapi-types": "0.
|
|
107
|
+
"@scalar/build-tooling": "0.2.0",
|
|
108
|
+
"@scalar/openapi-parser": "0.12.0",
|
|
109
|
+
"@scalar/openapi-types": "0.3.1"
|
|
110
110
|
},
|
|
111
111
|
"scripts": {
|
|
112
112
|
"build": "scalar-build-esbuild",
|