@scalar/oas-utils 0.2.137 → 0.2.139

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.139
4
+
5
+ ### Patch Changes
6
+
7
+ - d2f27f4: feat: improves request examples entity example defaulting
8
+
9
+ ## 0.2.138
10
+
11
+ ### Patch Changes
12
+
13
+ - 5d24800: feat: add a few security scheme helpers
14
+
3
15
  ## 0.2.137
4
16
 
5
17
  ### Patch Changes
@@ -23,29 +23,33 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
23
23
  style: import("zod").ZodOptional<import("zod").ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
24
24
  example: import("zod").ZodOptional<import("zod").ZodUnknown>;
25
25
  examples: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
26
- value: import("zod").ZodUnknown;
26
+ value: import("zod").ZodOptional<import("zod").ZodUnknown>;
27
27
  summary: import("zod").ZodOptional<import("zod").ZodString>;
28
+ externalValue: import("zod").ZodOptional<import("zod").ZodString>;
28
29
  }, "strip", import("zod").ZodTypeAny, {
29
30
  value?: unknown;
30
31
  summary?: string | undefined;
32
+ externalValue?: string | undefined;
31
33
  }, {
32
34
  value?: unknown;
33
35
  summary?: string | undefined;
36
+ externalValue?: string | undefined;
34
37
  }>>, import("zod").ZodArray<import("zod").ZodUnknown, "many">]>>;
35
38
  }, "strip", import("zod").ZodTypeAny, {
36
39
  name: string;
37
40
  required: boolean;
38
- in: "cookie" | "path" | "query" | "header";
39
41
  deprecated: boolean;
42
+ in: "cookie" | "path" | "query" | "header";
40
43
  description?: string | undefined;
41
44
  example?: unknown;
42
- schema?: unknown;
43
- content?: unknown;
44
- style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
45
45
  examples?: unknown[] | Record<string, {
46
46
  value?: unknown;
47
47
  summary?: string | undefined;
48
+ externalValue?: string | undefined;
48
49
  }> | undefined;
50
+ schema?: unknown;
51
+ content?: unknown;
52
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
49
53
  }, {
50
54
  name: string;
51
55
  in: "cookie" | "path" | "query" | "header";
@@ -53,13 +57,14 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
53
57
  required?: boolean | undefined;
54
58
  example?: unknown;
55
59
  deprecated?: boolean | undefined;
56
- schema?: unknown;
57
- content?: unknown;
58
- style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
59
60
  examples?: unknown[] | Record<string, {
60
61
  value?: unknown;
61
62
  summary?: string | undefined;
63
+ externalValue?: string | undefined;
62
64
  }> | undefined;
65
+ schema?: unknown;
66
+ content?: unknown;
67
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
63
68
  }>, "many">>;
64
69
  externalDocs: import("zod").ZodOptional<import("zod").ZodEffects<import("zod").ZodObject<{
65
70
  description: import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodString>>;
@@ -95,15 +100,15 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
95
100
  base64?: string | undefined;
96
101
  }>>>;
97
102
  }, "strip", import("zod").ZodTypeAny, {
103
+ encoding: "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "binary" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
98
104
  content: string | Record<string, any>;
99
- encoding: "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn" | "binary";
100
105
  file?: {
101
106
  url: string;
102
107
  base64?: string | undefined;
103
108
  } | null | undefined;
104
109
  }, {
110
+ encoding: "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "binary" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
105
111
  content: string | Record<string, any>;
106
- encoding: "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn" | "binary";
107
112
  file?: {
108
113
  url: string;
109
114
  base64?: string | undefined;
@@ -134,8 +139,8 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
134
139
  };
135
140
  name?: string | undefined;
136
141
  body?: {
142
+ encoding: "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "binary" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
137
143
  content: string | Record<string, any>;
138
- encoding: "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn" | "binary";
139
144
  file?: {
140
145
  url: string;
141
146
  base64?: string | undefined;
@@ -150,8 +155,8 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
150
155
  };
151
156
  name?: string | undefined;
152
157
  body?: {
158
+ encoding: "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "binary" | "text/html" | "application/javascript" | "application/yaml" | "application/edn";
153
159
  content: string | Record<string, any>;
154
- encoding: "application/json" | "application/octet-stream" | "application/x-www-form-urlencoded" | "application/xml" | "multipart/form-data" | "text/plain" | "text/html" | "application/javascript" | "application/yaml" | "application/edn" | "binary";
155
160
  file?: {
156
161
  url: string;
157
162
  base64?: string | undefined;
@@ -235,20 +240,22 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
235
240
  parameters?: {
236
241
  name: string;
237
242
  required: boolean;
238
- in: "cookie" | "path" | "query" | "header";
239
243
  deprecated: boolean;
244
+ in: "cookie" | "path" | "query" | "header";
240
245
  description?: string | undefined;
241
246
  example?: unknown;
242
- schema?: unknown;
243
- content?: unknown;
244
- style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
245
247
  examples?: unknown[] | Record<string, {
246
248
  value?: unknown;
247
249
  summary?: string | undefined;
250
+ externalValue?: string | undefined;
248
251
  }> | undefined;
252
+ schema?: unknown;
253
+ content?: unknown;
254
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
249
255
  }[] | undefined;
250
256
  requestBody?: any;
251
257
  responses?: Record<string, any> | undefined;
258
+ 'x-scalar-stability'?: import("@scalar/types").XScalarStability | undefined;
252
259
  'x-codeSamples'?: {
253
260
  source: string;
254
261
  label?: string | undefined;
@@ -264,7 +271,6 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
264
271
  label?: string | undefined;
265
272
  lang?: string | undefined;
266
273
  }[] | undefined;
267
- 'x-scalar-stability'?: import("@scalar/types").XScalarStability | undefined;
268
274
  }, {
269
275
  uid?: string | undefined;
270
276
  path?: string | undefined;
@@ -292,20 +298,21 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
292
298
  required?: boolean | undefined;
293
299
  example?: unknown;
294
300
  deprecated?: boolean | undefined;
295
- schema?: unknown;
296
- content?: unknown;
297
- style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
298
301
  examples?: unknown[] | Record<string, {
299
302
  value?: unknown;
300
303
  summary?: string | undefined;
304
+ externalValue?: string | undefined;
301
305
  }> | undefined;
306
+ schema?: unknown;
307
+ content?: unknown;
308
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
302
309
  }[] | undefined;
303
310
  requestBody?: any;
304
311
  responses?: Record<string, any> | undefined;
312
+ 'x-scalar-stability'?: unknown;
313
+ method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
305
314
  'x-codeSamples'?: unknown;
306
315
  'x-code-samples'?: unknown;
307
316
  'x-custom-examples'?: unknown;
308
- 'x-scalar-stability'?: unknown;
309
- method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
310
317
  }>;
311
318
  //# sourceMappingURL=operation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,IAAI,WAAW,EAAiB,MAAM,eAAe,CAAA;AAE/F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aACqV,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAqT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAwT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADrzC,CAAA"}
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,IAAI,WAAW,EAAiB,MAAM,eAAe,CAAA;AAE/F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aACqV,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAqT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;aAAwT,CAAC;YAAkC,CAAC;;;aAAoE,CAAC;YAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADrzC,CAAA"}
@@ -1,8 +1,16 @@
1
1
  import { z } from 'zod';
2
+ import type { OpenAPIV3_1 } from '@scalar/openapi-types';
3
+ import type { RequestExampleParameter } from './request-examples.ts';
2
4
  export declare const parameterTypeSchema: z.ZodEnum<["path", "query", "header", "cookie"]>;
3
5
  export type ParamType = z.infer<typeof parameterTypeSchema>;
4
6
  export declare const parameterStyleSchema: z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>;
5
7
  export type ParameterStyle = z.infer<typeof parameterStyleSchema>;
8
+ export type ParameterContent = Record<string, {
9
+ schema?: OpenAPIV3_1.Document;
10
+ examples?: Record<string, RequestExampleParameter>;
11
+ example?: RequestExampleParameter;
12
+ }>;
13
+ export declare const parameterExampleSchema: z.ZodUnknown;
6
14
  /**
7
15
  * OpenAPI compliant parameters object
8
16
  */
@@ -20,29 +28,33 @@ export declare const oasParameterSchema: z.ZodObject<{
20
28
  style: z.ZodOptional<z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
21
29
  example: z.ZodOptional<z.ZodUnknown>;
22
30
  examples: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
23
- value: z.ZodUnknown;
31
+ value: z.ZodOptional<z.ZodUnknown>;
24
32
  summary: z.ZodOptional<z.ZodString>;
33
+ externalValue: z.ZodOptional<z.ZodString>;
25
34
  }, "strip", z.ZodTypeAny, {
26
35
  value?: unknown;
27
36
  summary?: string | undefined;
37
+ externalValue?: string | undefined;
28
38
  }, {
29
39
  value?: unknown;
30
40
  summary?: string | undefined;
41
+ externalValue?: string | undefined;
31
42
  }>>, z.ZodArray<z.ZodUnknown, "many">]>>;
32
43
  }, "strip", z.ZodTypeAny, {
33
44
  name: string;
34
45
  required: boolean;
35
- in: "cookie" | "path" | "query" | "header";
36
46
  deprecated: boolean;
47
+ in: "cookie" | "path" | "query" | "header";
37
48
  description?: string | undefined;
38
49
  example?: unknown;
39
- schema?: unknown;
40
- content?: unknown;
41
- style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
42
50
  examples?: unknown[] | Record<string, {
43
51
  value?: unknown;
44
52
  summary?: string | undefined;
53
+ externalValue?: string | undefined;
45
54
  }> | undefined;
55
+ schema?: unknown;
56
+ content?: unknown;
57
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
46
58
  }, {
47
59
  name: string;
48
60
  in: "cookie" | "path" | "query" | "header";
@@ -50,13 +62,14 @@ export declare const oasParameterSchema: z.ZodObject<{
50
62
  required?: boolean | undefined;
51
63
  example?: unknown;
52
64
  deprecated?: boolean | undefined;
53
- schema?: unknown;
54
- content?: unknown;
55
- style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
56
65
  examples?: unknown[] | Record<string, {
57
66
  value?: unknown;
58
67
  summary?: string | undefined;
68
+ externalValue?: string | undefined;
59
69
  }> | undefined;
70
+ schema?: unknown;
71
+ content?: unknown;
72
+ style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
60
73
  }>;
61
74
  export type RequestParameter = z.infer<typeof oasParameterSchema>;
62
75
  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;AAEvC,eAAO,MAAM,mBAAmB,kDAAgD,CAAA;AAChF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE3D,eAAO,MAAM,oBAAoB,mGAQ/B,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;IAI7B,yBAAyB;;IAEzB,yBAAyB;;;;IAIzB,wFAAwF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAejD,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"}
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,uBAAuB,CAAA;AAEpE,eAAO,MAAM,mBAAmB,kDAAgD,CAAA;AAChF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE3D,eAAO,MAAM,oBAAoB,mGAQ/B,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CACnC,MAAM,EACN;IACE,MAAM,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAA;IAClD,OAAO,CAAC,EAAE,uBAAuB,CAAA;CAClC,CACF,CAAA;AACD,eAAO,MAAM,sBAAsB,cAAc,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;IAI7B,yBAAyB;;IAEzB,yBAAyB;;;;IAIzB,wFAAwF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBjD,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"}
@@ -10,6 +10,7 @@ const parameterStyleSchema = z.enum([
10
10
  'pipeDelimited',
11
11
  'deepObject',
12
12
  ]);
13
+ z.unknown();
13
14
  /**
14
15
  * OpenAPI compliant parameters object
15
16
  */
@@ -29,8 +30,9 @@ const oasParameterSchema = z.object({
29
30
  examples: z
30
31
  .union([
31
32
  z.record(z.string(), z.object({
32
- value: z.unknown(),
33
+ value: z.unknown().optional(),
33
34
  summary: z.string().optional(),
35
+ externalValue: z.string().optional(),
34
36
  })),
35
37
  z.array(z.unknown()),
36
38
  ])