@scalar/oas-utils 0.2.64 → 0.2.65
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 +17 -0
- package/dist/entities/environment/environment.js +1 -1
- package/dist/entities/spec/parameters.d.ts +21 -0
- package/dist/entities/spec/parameters.d.ts.map +1 -1
- package/dist/entities/spec/parameters.js +7 -0
- package/dist/entities/spec/request-examples.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.js +8 -1
- package/dist/entities/spec/requests.d.ts +62 -0
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/security.d.ts +1 -27
- package/dist/entities/spec/security.d.ts.map +1 -1
- package/dist/entities/spec/security.js +23 -14
- package/dist/migrations/v-2.1.0/migration.d.ts +5 -0
- package/dist/migrations/v-2.1.0/migration.d.ts.map +1 -1
- package/dist/spec-getters/getExampleFromSchema.d.ts.map +1 -1
- package/dist/spec-getters/getExampleFromSchema.js +22 -9
- package/dist/transforms/import-spec.d.ts +3 -1
- package/dist/transforms/import-spec.d.ts.map +1 -1
- package/dist/transforms/import-spec.js +3 -3
- package/dist/transforms/index.js +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @scalar/oas-utils
|
|
2
2
|
|
|
3
|
+
## 0.2.65
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3bec045: fix: adds example and examples to parameter schema
|
|
8
|
+
- 743474e: feat: favors hexa for environment color
|
|
9
|
+
- cfe9b85: fix: added safe parsing for oauth examples
|
|
10
|
+
- 4d45f7b: fix: improve parameter instance creation by handling enum values for number types
|
|
11
|
+
- 6599473: fix: arrays with allOf items render invalid examples
|
|
12
|
+
- 0e19781: feat: fix reactivitiy of references + client
|
|
13
|
+
- Updated dependencies [fb798c8]
|
|
14
|
+
- Updated dependencies [bb3dc9d]
|
|
15
|
+
- Updated dependencies [0e19781]
|
|
16
|
+
- @scalar/types@0.0.18
|
|
17
|
+
- @scalar/themes@0.9.45
|
|
18
|
+
- @scalar/object-utils@1.1.11
|
|
19
|
+
|
|
3
20
|
## 0.2.64
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ import { nanoidSchema } from '../shared/utility.js';
|
|
|
4
4
|
const environmentSchema = z.object({
|
|
5
5
|
uid: nanoidSchema,
|
|
6
6
|
name: z.string().optional().default('Default Environment'),
|
|
7
|
-
color: z.string().optional().default('
|
|
7
|
+
color: z.string().optional().default('#0082D0'),
|
|
8
8
|
value: z.string().default(''),
|
|
9
9
|
isDefault: z.boolean().optional(),
|
|
10
10
|
});
|
|
@@ -18,6 +18,17 @@ export declare const oasParameterSchema: z.ZodObject<{
|
|
|
18
18
|
content: z.ZodOptional<z.ZodUnknown>;
|
|
19
19
|
/** Defaulted according to @url https://spec.openapis.org/oas/v3.1.0#parameter-object */
|
|
20
20
|
style: z.ZodOptional<z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
|
|
21
|
+
example: z.ZodOptional<z.ZodUnknown>;
|
|
22
|
+
examples: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
23
|
+
value: z.ZodUnknown;
|
|
24
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
value?: unknown;
|
|
27
|
+
summary?: string | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
value?: unknown;
|
|
30
|
+
summary?: string | undefined;
|
|
31
|
+
}>>>;
|
|
21
32
|
}, "strip", z.ZodTypeAny, {
|
|
22
33
|
required: boolean;
|
|
23
34
|
name: string;
|
|
@@ -27,6 +38,11 @@ export declare const oasParameterSchema: z.ZodObject<{
|
|
|
27
38
|
schema?: unknown;
|
|
28
39
|
content?: unknown;
|
|
29
40
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
41
|
+
example?: unknown;
|
|
42
|
+
examples?: Record<string, {
|
|
43
|
+
value?: unknown;
|
|
44
|
+
summary?: string | undefined;
|
|
45
|
+
}> | undefined;
|
|
30
46
|
}, {
|
|
31
47
|
name: string;
|
|
32
48
|
in: "path" | "query" | "header" | "cookie";
|
|
@@ -36,6 +52,11 @@ export declare const oasParameterSchema: z.ZodObject<{
|
|
|
36
52
|
schema?: unknown;
|
|
37
53
|
content?: unknown;
|
|
38
54
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
55
|
+
example?: unknown;
|
|
56
|
+
examples?: Record<string, {
|
|
57
|
+
value?: unknown;
|
|
58
|
+
summary?: string | undefined;
|
|
59
|
+
}> | undefined;
|
|
39
60
|
}>;
|
|
40
61
|
export type RequestParameter = z.infer<typeof oasParameterSchema>;
|
|
41
62
|
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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYjD,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"}
|
|
@@ -25,6 +25,13 @@ const oasParameterSchema = z.object({
|
|
|
25
25
|
content: z.unknown().optional(),
|
|
26
26
|
/** Defaulted according to @url https://spec.openapis.org/oas/v3.1.0#parameter-object */
|
|
27
27
|
style: parameterStyleSchema.optional(),
|
|
28
|
+
example: z.unknown().optional(),
|
|
29
|
+
examples: z
|
|
30
|
+
.record(z.string(), z.object({
|
|
31
|
+
value: z.unknown(),
|
|
32
|
+
summary: z.string().optional(),
|
|
33
|
+
}))
|
|
34
|
+
.optional(),
|
|
28
35
|
});
|
|
29
36
|
|
|
30
37
|
export { oasParameterSchema, parameterStyleSchema, parameterTypeSchema };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-examples.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/request-examples.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuElF,CAAA;AAEF,qDAAqD;AACrD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAKxE,6DAA6D;AAC7D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB;;;;;;;;;;;;;;;EAyC1D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,GACd,cAAc,CAiGhB"}
|
|
@@ -83,7 +83,13 @@ function createParamInstance(param) {
|
|
|
83
83
|
* - Need to handle non-string parameters much better
|
|
84
84
|
* - Need to handle unions/array values for schema
|
|
85
85
|
*/
|
|
86
|
-
const value = String(schema?.default ??
|
|
86
|
+
const value = String(schema?.default ??
|
|
87
|
+
schema?.examples?.[0] ??
|
|
88
|
+
schema?.example ??
|
|
89
|
+
param.examples?.[Object.keys(param.examples)[0]]?.value ??
|
|
90
|
+
param.example ??
|
|
91
|
+
'');
|
|
92
|
+
const parseEnum = schema?.type === 'number' ? schema?.enum?.map(String) : schema?.enum;
|
|
87
93
|
// safe parse the example
|
|
88
94
|
const example = schemaModel({
|
|
89
95
|
...schema,
|
|
@@ -93,6 +99,7 @@ function createParamInstance(param) {
|
|
|
93
99
|
required: param.required,
|
|
94
100
|
/** Initialized all required properties to enabled */
|
|
95
101
|
enabled: !!param.required,
|
|
102
|
+
enum: parseEnum,
|
|
96
103
|
}, requestExampleParametersSchema, false);
|
|
97
104
|
if (!example) {
|
|
98
105
|
console.warn(`Example at ${param.name} is invalid.`);
|
|
@@ -73,6 +73,17 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
73
73
|
schema: z.ZodOptional<z.ZodUnknown>;
|
|
74
74
|
content: z.ZodOptional<z.ZodUnknown>;
|
|
75
75
|
style: z.ZodOptional<z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
|
|
76
|
+
example: z.ZodOptional<z.ZodUnknown>;
|
|
77
|
+
examples: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
78
|
+
value: z.ZodUnknown;
|
|
79
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
value?: unknown;
|
|
82
|
+
summary?: string | undefined;
|
|
83
|
+
}, {
|
|
84
|
+
value?: unknown;
|
|
85
|
+
summary?: string | undefined;
|
|
86
|
+
}>>>;
|
|
76
87
|
}, "strip", z.ZodTypeAny, {
|
|
77
88
|
required: boolean;
|
|
78
89
|
name: string;
|
|
@@ -82,6 +93,11 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
82
93
|
schema?: unknown;
|
|
83
94
|
content?: unknown;
|
|
84
95
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
96
|
+
example?: unknown;
|
|
97
|
+
examples?: Record<string, {
|
|
98
|
+
value?: unknown;
|
|
99
|
+
summary?: string | undefined;
|
|
100
|
+
}> | undefined;
|
|
85
101
|
}, {
|
|
86
102
|
name: string;
|
|
87
103
|
in: "path" | "query" | "header" | "cookie";
|
|
@@ -91,6 +107,11 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
91
107
|
schema?: unknown;
|
|
92
108
|
content?: unknown;
|
|
93
109
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
110
|
+
example?: unknown;
|
|
111
|
+
examples?: Record<string, {
|
|
112
|
+
value?: unknown;
|
|
113
|
+
summary?: string | undefined;
|
|
114
|
+
}> | undefined;
|
|
94
115
|
}>, "many">>;
|
|
95
116
|
/**
|
|
96
117
|
* External documentation object
|
|
@@ -128,6 +149,11 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
128
149
|
schema?: unknown;
|
|
129
150
|
content?: unknown;
|
|
130
151
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
152
|
+
example?: unknown;
|
|
153
|
+
examples?: Record<string, {
|
|
154
|
+
value?: unknown;
|
|
155
|
+
summary?: string | undefined;
|
|
156
|
+
}> | undefined;
|
|
131
157
|
}[] | undefined;
|
|
132
158
|
requestBody?: any;
|
|
133
159
|
responses?: Record<string, any> | undefined;
|
|
@@ -151,6 +177,11 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
151
177
|
schema?: unknown;
|
|
152
178
|
content?: unknown;
|
|
153
179
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
180
|
+
example?: unknown;
|
|
181
|
+
examples?: Record<string, {
|
|
182
|
+
value?: unknown;
|
|
183
|
+
summary?: string | undefined;
|
|
184
|
+
}> | undefined;
|
|
154
185
|
}[] | undefined;
|
|
155
186
|
requestBody?: any;
|
|
156
187
|
responses?: Record<string, any> | undefined;
|
|
@@ -201,6 +232,17 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
201
232
|
schema: z.ZodOptional<z.ZodUnknown>;
|
|
202
233
|
content: z.ZodOptional<z.ZodUnknown>;
|
|
203
234
|
style: z.ZodOptional<z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
|
|
235
|
+
example: z.ZodOptional<z.ZodUnknown>;
|
|
236
|
+
examples: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
237
|
+
value: z.ZodUnknown;
|
|
238
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
239
|
+
}, "strip", z.ZodTypeAny, {
|
|
240
|
+
value?: unknown;
|
|
241
|
+
summary?: string | undefined;
|
|
242
|
+
}, {
|
|
243
|
+
value?: unknown;
|
|
244
|
+
summary?: string | undefined;
|
|
245
|
+
}>>>;
|
|
204
246
|
}, "strip", z.ZodTypeAny, {
|
|
205
247
|
required: boolean;
|
|
206
248
|
name: string;
|
|
@@ -210,6 +252,11 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
210
252
|
schema?: unknown;
|
|
211
253
|
content?: unknown;
|
|
212
254
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
255
|
+
example?: unknown;
|
|
256
|
+
examples?: Record<string, {
|
|
257
|
+
value?: unknown;
|
|
258
|
+
summary?: string | undefined;
|
|
259
|
+
}> | undefined;
|
|
213
260
|
}, {
|
|
214
261
|
name: string;
|
|
215
262
|
in: "path" | "query" | "header" | "cookie";
|
|
@@ -219,6 +266,11 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
219
266
|
schema?: unknown;
|
|
220
267
|
content?: unknown;
|
|
221
268
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
269
|
+
example?: unknown;
|
|
270
|
+
examples?: Record<string, {
|
|
271
|
+
value?: unknown;
|
|
272
|
+
summary?: string | undefined;
|
|
273
|
+
}> | undefined;
|
|
222
274
|
}>, "many">>;
|
|
223
275
|
/**
|
|
224
276
|
* External documentation object
|
|
@@ -279,6 +331,11 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
279
331
|
schema?: unknown;
|
|
280
332
|
content?: unknown;
|
|
281
333
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
334
|
+
example?: unknown;
|
|
335
|
+
examples?: Record<string, {
|
|
336
|
+
value?: unknown;
|
|
337
|
+
summary?: string | undefined;
|
|
338
|
+
}> | undefined;
|
|
282
339
|
}[] | undefined;
|
|
283
340
|
requestBody?: any;
|
|
284
341
|
responses?: Record<string, any> | undefined;
|
|
@@ -310,6 +367,11 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
310
367
|
schema?: unknown;
|
|
311
368
|
content?: unknown;
|
|
312
369
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
370
|
+
example?: unknown;
|
|
371
|
+
examples?: Record<string, {
|
|
372
|
+
value?: unknown;
|
|
373
|
+
summary?: string | undefined;
|
|
374
|
+
}> | undefined;
|
|
313
375
|
}[] | undefined;
|
|
314
376
|
requestBody?: any;
|
|
315
377
|
responses?: Record<string, any> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/requests.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAIxD,eAAO,MAAM,cAAc,2FAUjB,CAAA;AAEV,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3D,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG;IACzD,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,wCAAwC;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,0BAA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AAiE;AACjE,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,cAAc,CAAA;IACvB,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAMD,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB;IAC3B;;;;;OAKG;;IAEH,kDAAkD;;IAElD,mHAAmH;;IAEnH;;;;OAIG;;IAEH;;;;;;OAMG;;IAEH;;;;;OAKG;;IAEH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;OAEG;;;;;;;;;;;;IAGH,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE0B,CAAA;AA0BnD,8CAA8C;AAC9C,eAAO,MAAM,aAAa;IAtExB;;;;;OAKG;;IAEH,kDAAkD;;IAElD,mHAAmH;;IAEnH;;;;OAIG;;IAEH;;;;;;OAMG;;IAEH;;;;;OAKG;;IAEH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;OAEG;;;;;;;;;;;;IAGH,uBAAuB;;;;;IAcvB,eAAe;;IAEf,qBAAqB;;IAErB,kDAAkD;;IAElD,oCAAoC;;IAEpC,uDAAuD;;IAEvD,+DAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKS,CAAA;AAC1E,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"}
|
|
@@ -92,33 +92,7 @@ export type SecuritySchemeOauth2ExampleValue = Extract<SecuritySchemeExampleValu
|
|
|
92
92
|
*
|
|
93
93
|
* TODO: we can probably remove this unless we really want to keep it separate
|
|
94
94
|
*/
|
|
95
|
-
export declare function authExampleFromSchema(scheme: SecurityScheme, baseValues?: any):
|
|
96
|
-
type: "apiKey";
|
|
97
|
-
value: string;
|
|
98
|
-
name: string;
|
|
99
|
-
} | {
|
|
100
|
-
type: "http";
|
|
101
|
-
username: string;
|
|
102
|
-
password: string;
|
|
103
|
-
token: string;
|
|
104
|
-
} | {
|
|
105
|
-
type: "oauth-implicit";
|
|
106
|
-
token: string;
|
|
107
|
-
} | {
|
|
108
|
-
type: "oauth-password";
|
|
109
|
-
username: string;
|
|
110
|
-
password: string;
|
|
111
|
-
token: string;
|
|
112
|
-
clientSecret: string;
|
|
113
|
-
} | {
|
|
114
|
-
type: "oauth-clientCredentials";
|
|
115
|
-
token: string;
|
|
116
|
-
clientSecret: string;
|
|
117
|
-
} | {
|
|
118
|
-
type: "oauth-authorizationCode";
|
|
119
|
-
token: string;
|
|
120
|
-
clientSecret: string;
|
|
121
|
-
};
|
|
95
|
+
export declare function authExampleFromSchema(scheme: SecurityScheme, baseValues?: any): SecuritySchemeExampleValue | null;
|
|
122
96
|
export declare const securitySchemeApiKeyIn: readonly ["query", "header", "cookie"];
|
|
123
97
|
export declare const securityApiKeySchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
124
98
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/security.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/security.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA6CvB;;;GAGG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAO3C,CAAA;AAEF,MAAM,MAAM,0BAA0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IA5DH,0EAA0E;;;;;;;;;;;;;;;;;;IAwI1E,6FAA6F;;QAnD7F;;;WAGG;;QAEH;;;WAGG;;;;;;;;;;;;;;;;;;;;;;QARH;;;WAGG;;QAEH;;;WAGG;;;;;;;;;;;;;;;;;;;QARH;;;WAGG;;QAEH;;;WAGG;;;;;;;;;;;;;;;;;;;QARH;;;WAGG;;QAEH;;;WAGG;;;;;;;;;;;;;;;;;;;;;;;;;IA6CH,oEAAoE;;;;IA1IpE,0EAA0E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAoL1E,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACjE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { schemaModel } from '../../helpers/schema-model.js';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
import { nanoidSchema } from '../shared/utility.js';
|
|
3
4
|
|
|
@@ -53,21 +54,29 @@ const securitySchemeExampleValueSchema = z.union([
|
|
|
53
54
|
* TODO: we can probably remove this unless we really want to keep it separate
|
|
54
55
|
*/
|
|
55
56
|
function authExampleFromSchema(scheme, baseValues = {}) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (scheme.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
try {
|
|
58
|
+
if (scheme.type === 'apiKey') {
|
|
59
|
+
return schemaModel({ name: scheme.name, ...baseValues }, apiKeyExampleSchema, false);
|
|
60
|
+
}
|
|
61
|
+
if (scheme.type === 'http') {
|
|
62
|
+
return schemaModel(baseValues, httpExampleSchema, false);
|
|
63
|
+
}
|
|
64
|
+
if (scheme.type === 'oauth2') {
|
|
65
|
+
if (scheme.flow.type === 'authorizationCode')
|
|
66
|
+
return schemaModel(baseValues, oauthAuthorizationCodeExampleSchema, false);
|
|
67
|
+
if (scheme.flow.type === 'clientCredentials')
|
|
68
|
+
return schemaModel(baseValues, oauthClientCredentialsExampleSchema, false);
|
|
69
|
+
if (scheme.flow.type === 'implicit')
|
|
70
|
+
return schemaModel(baseValues, oauthImplicitExampleSchema, false);
|
|
71
|
+
if (scheme.flow.type === 'password')
|
|
72
|
+
return schemaModel(baseValues, oauthPasswordExampleSchema, false);
|
|
73
|
+
}
|
|
69
74
|
}
|
|
70
|
-
|
|
75
|
+
catch (e) {
|
|
76
|
+
console.error(e);
|
|
77
|
+
}
|
|
78
|
+
console.warn('[@scalar/oas-utils:security] Invalid schema for oauth example', baseValues);
|
|
79
|
+
return null;
|
|
71
80
|
}
|
|
72
81
|
// ---------------------------------------------------------------------------
|
|
73
82
|
// COMMON PROPS FOR ALL SECURITY SCHEMES
|
|
@@ -203,6 +203,11 @@ export declare const migrate_v_2_1_0: (data: Omit<v_0_0_0.Data, "folders">) => {
|
|
|
203
203
|
schema?: unknown;
|
|
204
204
|
content?: unknown;
|
|
205
205
|
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
206
|
+
example?: unknown;
|
|
207
|
+
examples?: Record<string, {
|
|
208
|
+
value?: unknown;
|
|
209
|
+
summary?: string | undefined;
|
|
210
|
+
}> | undefined;
|
|
206
211
|
}[];
|
|
207
212
|
type: "request";
|
|
208
213
|
method: "options" | "delete" | "get" | "connect" | "head" | "patch" | "post" | "put" | "trace";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.1.0/migration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAIn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AUU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA0Iyd,CAAC;;6BAA4E,CAAC;;;;;;;;;;CADljB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExampleFromSchema.d.ts","sourceRoot":"","sources":["../../src/spec-getters/getExampleFromSchema.ts"],"names":[],"mappings":"AAwDA;;GAEG;AACH,eAAO,MAAM,oBAAoB,WACvB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YACjB;IACR;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B;;OAEG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAA;CACzC,UACM,MAAM,iBACE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,SAC3B,MAAM,KACZ,
|
|
1
|
+
{"version":3,"file":"getExampleFromSchema.d.ts","sourceRoot":"","sources":["../../src/spec-getters/getExampleFromSchema.ts"],"names":[],"mappings":"AAwDA;;GAEG;AACH,eAAO,MAAM,oBAAoB,WACvB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YACjB;IACR;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B;;OAEG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAA;CACzC,UACM,MAAM,iBACE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,SAC3B,MAAM,KACZ,GAqTF,CAAA"}
|
|
@@ -170,19 +170,32 @@ const getExampleFromSchema = (schema, options, level = 0, parentSchema, name) =>
|
|
|
170
170
|
}
|
|
171
171
|
// Check whether the array has a anyOf, oneOf, or allOf rule
|
|
172
172
|
if (schema.items) {
|
|
173
|
-
//
|
|
174
|
-
|
|
173
|
+
// First handle allOf separately since it needs special handling
|
|
174
|
+
if (schema.items.allOf) {
|
|
175
|
+
// If the first item is an object type, merge all schemas
|
|
176
|
+
if (schema.items.allOf[0].type === 'object') {
|
|
177
|
+
const mergedExample = getExampleFromSchema({ type: 'object', allOf: schema.items.allOf }, options, level + 1, schema);
|
|
178
|
+
return cache(schema, wrapItems
|
|
179
|
+
? [{ [itemsXmlTagName]: mergedExample }]
|
|
180
|
+
: [mergedExample]);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
// For non-objects (like strings), collect all examples
|
|
184
|
+
const examples = schema.items.allOf
|
|
185
|
+
.map((item) => getExampleFromSchema(item, options, level + 1, schema))
|
|
186
|
+
.filter((item) => item !== undefined);
|
|
187
|
+
return cache(schema, wrapItems
|
|
188
|
+
? examples.map((example) => ({ [itemsXmlTagName]: example }))
|
|
189
|
+
: examples);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Handle other rules (anyOf, oneOf)
|
|
193
|
+
const rules = ['anyOf', 'oneOf'];
|
|
175
194
|
for (const rule of rules) {
|
|
176
|
-
// Skip early if the rule is not defined
|
|
177
195
|
if (!schema.items[rule]) {
|
|
178
196
|
continue;
|
|
179
197
|
}
|
|
180
|
-
|
|
181
|
-
const schemas = ['anyOf', 'oneOf'].includes(rule)
|
|
182
|
-
? // Use the first item only
|
|
183
|
-
schema.items[rule].slice(0, 1)
|
|
184
|
-
: // Use all items
|
|
185
|
-
schema.items[rule];
|
|
198
|
+
const schemas = schema.items[rule].slice(0, 1);
|
|
186
199
|
const exampleFromRule = schemas
|
|
187
200
|
.map((item) => getExampleFromSchema(item, options, level + 1, schema))
|
|
188
201
|
.filter((item) => item !== undefined);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type Collection, type CollectionPayload, type Request, type RequestExample, type Server, type Tag } from '../entities/spec/index.js';
|
|
2
|
-
import { type SecurityScheme } from '../entities/spec/security.js';
|
|
2
|
+
import { type SecurityScheme, type SecuritySchemeExampleValue } from '../entities/spec/security.js';
|
|
3
3
|
import type { OpenAPIV3, OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
4
4
|
import type { ReferenceConfiguration } from '@scalar/types/legacy';
|
|
5
5
|
import type { UnknownObject } from '@scalar/types/utils';
|
|
6
|
+
/** Pre-fill baseValues if we have authentication config */
|
|
7
|
+
export declare const getBaseAuthValues: (scheme: SecurityScheme, auth?: ReferenceConfiguration["authentication"]) => Record<string, never> | Partial<SecuritySchemeExampleValue>;
|
|
6
8
|
/** Takes a string or object and parses it into an openapi spec compliant schema */
|
|
7
9
|
export declare const parseSchema: (spec: string | UnknownObject) => Promise<{
|
|
8
10
|
schema: OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,GAAG,EAOT,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"import-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/import-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,GAAG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E,CAAA;IACX,eAAe,EAAE,cAAc,EAAE,CAAA;CAClC,GACD;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAC5C,CA8QA"}
|
|
@@ -42,7 +42,7 @@ const convertOauth2Flows = (security, nameKey, auth) => {
|
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
/** Pre-fill baseValues if we have authentication config */
|
|
45
|
-
const
|
|
45
|
+
const getBaseAuthValues = (scheme, auth) => {
|
|
46
46
|
if (!auth)
|
|
47
47
|
return {};
|
|
48
48
|
// ApiKey
|
|
@@ -262,7 +262,7 @@ async function importSpecToWorkspace(spec, { authentication, documentUrl, setCol
|
|
|
262
262
|
// Generate Collection
|
|
263
263
|
// Create the auth examples
|
|
264
264
|
const auth = securitySchemes?.reduce((prev, s) => {
|
|
265
|
-
const baseValues =
|
|
265
|
+
const baseValues = getBaseAuthValues(s, authentication);
|
|
266
266
|
const example = authExampleFromSchema(s, baseValues);
|
|
267
267
|
if (example)
|
|
268
268
|
prev[s.uid] = example;
|
|
@@ -307,4 +307,4 @@ async function importSpecToWorkspace(spec, { authentication, documentUrl, setCol
|
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
export { importSpecToWorkspace, parseSchema };
|
|
310
|
+
export { getBaseAuthValues, importSpecToWorkspace, parseSchema };
|
package/dist/transforms/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { importSpecToWorkspace, parseSchema } from './import-spec.js';
|
|
1
|
+
export { getBaseAuthValues, importSpecToWorkspace, parseSchema } from './import-spec.js';
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.65",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -107,19 +107,19 @@
|
|
|
107
107
|
"yaml": "^2.4.5",
|
|
108
108
|
"zod": "^3.23.8",
|
|
109
109
|
"@scalar/import": "0.0.3",
|
|
110
|
-
"@scalar/object-utils": "1.1.10",
|
|
111
110
|
"@scalar/openapi-types": "0.1.4",
|
|
112
|
-
"@scalar/
|
|
113
|
-
"@scalar/types": "0.0.
|
|
111
|
+
"@scalar/object-utils": "1.1.11",
|
|
112
|
+
"@scalar/types": "0.0.18",
|
|
113
|
+
"@scalar/themes": "0.9.45"
|
|
114
114
|
},
|
|
115
115
|
"devDependencies": {
|
|
116
116
|
"type-fest": "^4.20.0",
|
|
117
117
|
"vite": "^5.4.9",
|
|
118
118
|
"vitest": "^1.6.0",
|
|
119
119
|
"zod-to-ts": "^1.2.0",
|
|
120
|
+
"@scalar/build-tooling": "0.1.11",
|
|
120
121
|
"@scalar/openapi-parser": "0.8.8",
|
|
121
|
-
"@scalar/openapi-types": "0.1.4"
|
|
122
|
-
"@scalar/build-tooling": "0.1.11"
|
|
122
|
+
"@scalar/openapi-types": "0.1.4"
|
|
123
123
|
},
|
|
124
124
|
"scripts": {
|
|
125
125
|
"build": "scalar-build-rollup",
|