@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 +12 -0
- package/dist/entities/spec/operation.d.ts +29 -22
- package/dist/entities/spec/operation.d.ts.map +1 -1
- package/dist/entities/spec/parameters.d.ts +21 -8
- package/dist/entities/spec/parameters.d.ts.map +1 -1
- package/dist/entities/spec/parameters.js +3 -1
- package/dist/entities/spec/request-examples.d.ts +136 -136
- package/dist/entities/spec/request-examples.d.ts.map +1 -1
- package/dist/entities/spec/request-examples.js +59 -9
- package/dist/entities/spec/requests.d.ts +57 -43
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/helpers/security/get-schemes.d.ts +82 -0
- package/dist/helpers/security/get-schemes.d.ts.map +1 -0
- package/dist/helpers/security/get-schemes.js +11 -0
- package/dist/helpers/security/has-token.d.ts +4 -0
- package/dist/helpers/security/has-token.d.ts.map +1 -0
- package/dist/helpers/security/has-token.js +21 -0
- package/dist/helpers/security/index.d.ts +3 -0
- package/dist/helpers/security/index.d.ts.map +1 -0
- package/dist/helpers/security/index.js +2 -0
- package/package.json +9 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-examples.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/request-examples.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"request-examples.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/request-examples.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,iBAAiB,CAAA;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKzC;;;;;GAKG;AACH,eA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;;;;;;;;;EAEvC,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAKjE,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB;IAC/B,qCAAqC;;;;QAzCrC;;;;WAIG;;QAEH,0EAA0E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4C1E,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,cAAc;;;;;;;;;;;;;;;;EAqD9D;AAKD,6DAA6D;AAC7D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB;;;;;;;;;;;;;;;EAsH1D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CA8GxG"}
|
|
@@ -2,6 +2,8 @@ import { schemaModel } from '../../helpers/schema-model.js';
|
|
|
2
2
|
import { getServerVariableExamples } from '../../spec-getters/get-server-variable-examples.js';
|
|
3
3
|
import { nanoidSchema } from '@scalar/types/utils';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
+
import { isDefined } from '../../helpers/is-defined.js';
|
|
6
|
+
import { getObjectKeys } from '../../helpers/object.js';
|
|
5
7
|
import { getRequestBodyFromOperation } from '../../spec-getters/get-request-body-from-operation.js';
|
|
6
8
|
|
|
7
9
|
// ---------------------------------------------------------------------------
|
|
@@ -21,7 +23,7 @@ const requestExampleParametersSchema = z
|
|
|
21
23
|
description: z.string().optional(),
|
|
22
24
|
required: z.boolean().optional(),
|
|
23
25
|
enum: z.array(z.string()).optional(),
|
|
24
|
-
examples: z.array(z.
|
|
26
|
+
examples: z.array(z.any()).optional(),
|
|
25
27
|
type: z
|
|
26
28
|
.union([
|
|
27
29
|
// 'string'
|
|
@@ -43,7 +45,7 @@ const requestExampleParametersSchema = z
|
|
|
43
45
|
if (Array.isArray(data.type) && data.type.includes('null')) {
|
|
44
46
|
data.nullable = true;
|
|
45
47
|
}
|
|
46
|
-
// Hey, if it
|
|
48
|
+
// Hey, if it's just one value and 'null', we can make it a string and ditch the 'null'.
|
|
47
49
|
if (Array.isArray(data.type) && data.type.length === 2 && data.type.includes('null')) {
|
|
48
50
|
data.type = data.type.find((item) => item !== 'null');
|
|
49
51
|
}
|
|
@@ -165,14 +167,61 @@ const xScalarExampleSchema = z.object({
|
|
|
165
167
|
/** Create new instance parameter from a request parameter */
|
|
166
168
|
function createParamInstance(param) {
|
|
167
169
|
const schema = param.schema;
|
|
168
|
-
const keys = Object.keys(param?.examples ?? {});
|
|
169
170
|
const firstExample = (() => {
|
|
170
|
-
if (
|
|
171
|
-
|
|
171
|
+
if (param.examples && !Array.isArray(param.examples) && getObjectKeys(param.examples).length > 0) {
|
|
172
|
+
const exampleValues = Object.entries(param.examples).map(([_, example]) => {
|
|
173
|
+
// returns the external value if it exists
|
|
174
|
+
if (example.externalValue) {
|
|
175
|
+
return example.externalValue;
|
|
176
|
+
}
|
|
177
|
+
// returns the value if it exists and is defined
|
|
178
|
+
// e.g. { examples: { foo: { value: 'bar' } } } would return ['bar']
|
|
179
|
+
return example.value;
|
|
180
|
+
});
|
|
181
|
+
// returns the first example as selected value along other examples
|
|
182
|
+
return { value: exampleValues[0], examples: exampleValues };
|
|
183
|
+
}
|
|
184
|
+
// param example e.g. { example: 'foo' }
|
|
185
|
+
if (isDefined(param.example)) {
|
|
186
|
+
return { value: param.example };
|
|
172
187
|
}
|
|
188
|
+
// param examples e.g. { examples: ['foo', 'bar'] }
|
|
173
189
|
if (Array.isArray(param.examples) && param.examples.length > 0) {
|
|
174
190
|
return { value: param.examples[0] };
|
|
175
191
|
}
|
|
192
|
+
// schema example e.g. { example: 'foo' } while being discouraged
|
|
193
|
+
// see https://spec.openapis.org/oas/v3.1.1.html#fixed-fields-20
|
|
194
|
+
if (isDefined(schema?.example)) {
|
|
195
|
+
return { value: schema.example };
|
|
196
|
+
}
|
|
197
|
+
// schema examples e.g. { examples: ['foo', 'bar'] }
|
|
198
|
+
if (Array.isArray(schema?.examples) && schema.examples.length > 0) {
|
|
199
|
+
// For boolean type, default to false when using schema examples
|
|
200
|
+
if (schema?.type === 'boolean') {
|
|
201
|
+
return { value: schema.default ?? false };
|
|
202
|
+
}
|
|
203
|
+
return { value: schema.examples[0] };
|
|
204
|
+
}
|
|
205
|
+
// content examples e.g. { content: { 'application/json': { examples: { foo: { value: 'bar' } } } } }
|
|
206
|
+
if (param.content) {
|
|
207
|
+
const firstContentType = getObjectKeys(param.content)[0];
|
|
208
|
+
if (firstContentType) {
|
|
209
|
+
const content = param.content[firstContentType];
|
|
210
|
+
if (content?.examples) {
|
|
211
|
+
const firstExampleKey = Object.keys(content.examples)[0];
|
|
212
|
+
if (firstExampleKey) {
|
|
213
|
+
const example = content.examples[firstExampleKey];
|
|
214
|
+
if (isDefined(example?.value)) {
|
|
215
|
+
return { value: example.value };
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// content example e.g. { example: 'foo' }
|
|
220
|
+
if (isDefined(content?.example)) {
|
|
221
|
+
return { value: content.example };
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
176
225
|
return null;
|
|
177
226
|
})();
|
|
178
227
|
/**
|
|
@@ -181,7 +230,7 @@ function createParamInstance(param) {
|
|
|
181
230
|
* - Need to handle non-string parameters much better
|
|
182
231
|
* - Need to handle unions/array values for schema
|
|
183
232
|
*/
|
|
184
|
-
const value = String(
|
|
233
|
+
const value = String(firstExample?.value ?? schema?.default ?? '');
|
|
185
234
|
// Handle non-string enums and enums within items for array types
|
|
186
235
|
const parseEnum = (() => {
|
|
187
236
|
if (schema?.enum && schema?.type !== 'string') {
|
|
@@ -192,8 +241,9 @@ function createParamInstance(param) {
|
|
|
192
241
|
}
|
|
193
242
|
return schema?.enum;
|
|
194
243
|
})();
|
|
195
|
-
// Handle
|
|
196
|
-
const
|
|
244
|
+
// Handle parameter examples
|
|
245
|
+
const examples = firstExample?.examples ||
|
|
246
|
+
(schema?.examples && schema?.type !== 'string' ? schema.examples?.map(String) : schema?.examples);
|
|
197
247
|
// safe parse the example
|
|
198
248
|
const example = schemaModel({
|
|
199
249
|
...schema,
|
|
@@ -204,7 +254,7 @@ function createParamInstance(param) {
|
|
|
204
254
|
/** Initialized all required properties to enabled */
|
|
205
255
|
enabled: !!param.required,
|
|
206
256
|
enum: parseEnum,
|
|
207
|
-
examples
|
|
257
|
+
examples,
|
|
208
258
|
}, requestExampleParametersSchema, false);
|
|
209
259
|
if (!example) {
|
|
210
260
|
console.warn(`Example at ${param.name} is invalid.`);
|
|
@@ -80,29 +80,33 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
80
80
|
style: z.ZodOptional<z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
|
|
81
81
|
example: z.ZodOptional<z.ZodUnknown>;
|
|
82
82
|
examples: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
83
|
-
value: z.ZodUnknown
|
|
83
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
84
84
|
summary: z.ZodOptional<z.ZodString>;
|
|
85
|
+
externalValue: z.ZodOptional<z.ZodString>;
|
|
85
86
|
}, "strip", z.ZodTypeAny, {
|
|
86
87
|
value?: unknown;
|
|
87
88
|
summary?: string | undefined;
|
|
89
|
+
externalValue?: string | undefined;
|
|
88
90
|
}, {
|
|
89
91
|
value?: unknown;
|
|
90
92
|
summary?: string | undefined;
|
|
93
|
+
externalValue?: string | undefined;
|
|
91
94
|
}>>, z.ZodArray<z.ZodUnknown, "many">]>>;
|
|
92
95
|
}, "strip", z.ZodTypeAny, {
|
|
93
96
|
name: string;
|
|
94
97
|
required: boolean;
|
|
95
|
-
in: "cookie" | "path" | "query" | "header";
|
|
96
98
|
deprecated: boolean;
|
|
99
|
+
in: "cookie" | "path" | "query" | "header";
|
|
97
100
|
description?: string | undefined;
|
|
98
101
|
example?: unknown;
|
|
99
|
-
schema?: unknown;
|
|
100
|
-
content?: unknown;
|
|
101
|
-
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
102
102
|
examples?: unknown[] | Record<string, {
|
|
103
103
|
value?: unknown;
|
|
104
104
|
summary?: string | undefined;
|
|
105
|
+
externalValue?: string | undefined;
|
|
105
106
|
}> | undefined;
|
|
107
|
+
schema?: unknown;
|
|
108
|
+
content?: unknown;
|
|
109
|
+
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
106
110
|
}, {
|
|
107
111
|
name: string;
|
|
108
112
|
in: "cookie" | "path" | "query" | "header";
|
|
@@ -110,13 +114,14 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
110
114
|
required?: boolean | undefined;
|
|
111
115
|
example?: unknown;
|
|
112
116
|
deprecated?: boolean | undefined;
|
|
113
|
-
schema?: unknown;
|
|
114
|
-
content?: unknown;
|
|
115
|
-
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
116
117
|
examples?: unknown[] | Record<string, {
|
|
117
118
|
value?: unknown;
|
|
118
119
|
summary?: string | undefined;
|
|
120
|
+
externalValue?: string | undefined;
|
|
119
121
|
}> | undefined;
|
|
122
|
+
schema?: unknown;
|
|
123
|
+
content?: unknown;
|
|
124
|
+
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
120
125
|
}>, "many">>;
|
|
121
126
|
/**
|
|
122
127
|
* External documentation object
|
|
@@ -157,15 +162,15 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
157
162
|
base64?: string | undefined;
|
|
158
163
|
}>>>;
|
|
159
164
|
}, "strip", z.ZodTypeAny, {
|
|
165
|
+
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";
|
|
160
166
|
content: string | Record<string, any>;
|
|
161
|
-
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";
|
|
162
167
|
file?: {
|
|
163
168
|
url: string;
|
|
164
169
|
base64?: string | undefined;
|
|
165
170
|
} | null | undefined;
|
|
166
171
|
}, {
|
|
172
|
+
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";
|
|
167
173
|
content: string | Record<string, any>;
|
|
168
|
-
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";
|
|
169
174
|
file?: {
|
|
170
175
|
url: string;
|
|
171
176
|
base64?: string | undefined;
|
|
@@ -196,8 +201,8 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
196
201
|
};
|
|
197
202
|
name?: string | undefined;
|
|
198
203
|
body?: {
|
|
204
|
+
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";
|
|
199
205
|
content: string | Record<string, any>;
|
|
200
|
-
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";
|
|
201
206
|
file?: {
|
|
202
207
|
url: string;
|
|
203
208
|
base64?: string | undefined;
|
|
@@ -212,8 +217,8 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
212
217
|
};
|
|
213
218
|
name?: string | undefined;
|
|
214
219
|
body?: {
|
|
220
|
+
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";
|
|
215
221
|
content: string | Record<string, any>;
|
|
216
|
-
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";
|
|
217
222
|
file?: {
|
|
218
223
|
url: string;
|
|
219
224
|
base64?: string | undefined;
|
|
@@ -239,17 +244,18 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
239
244
|
parameters?: {
|
|
240
245
|
name: string;
|
|
241
246
|
required: boolean;
|
|
242
|
-
in: "cookie" | "path" | "query" | "header";
|
|
243
247
|
deprecated: boolean;
|
|
248
|
+
in: "cookie" | "path" | "query" | "header";
|
|
244
249
|
description?: string | undefined;
|
|
245
250
|
example?: unknown;
|
|
246
|
-
schema?: unknown;
|
|
247
|
-
content?: unknown;
|
|
248
|
-
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
249
251
|
examples?: unknown[] | Record<string, {
|
|
250
252
|
value?: unknown;
|
|
251
253
|
summary?: string | undefined;
|
|
254
|
+
externalValue?: string | undefined;
|
|
252
255
|
}> | undefined;
|
|
256
|
+
schema?: unknown;
|
|
257
|
+
content?: unknown;
|
|
258
|
+
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
253
259
|
}[] | undefined;
|
|
254
260
|
requestBody?: any;
|
|
255
261
|
responses?: Record<string, any> | undefined;
|
|
@@ -262,8 +268,8 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
262
268
|
};
|
|
263
269
|
name?: string | undefined;
|
|
264
270
|
body?: {
|
|
271
|
+
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";
|
|
265
272
|
content: string | Record<string, any>;
|
|
266
|
-
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";
|
|
267
273
|
file?: {
|
|
268
274
|
url: string;
|
|
269
275
|
base64?: string | undefined;
|
|
@@ -290,13 +296,14 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
290
296
|
required?: boolean | undefined;
|
|
291
297
|
example?: unknown;
|
|
292
298
|
deprecated?: boolean | undefined;
|
|
293
|
-
schema?: unknown;
|
|
294
|
-
content?: unknown;
|
|
295
|
-
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
296
299
|
examples?: unknown[] | Record<string, {
|
|
297
300
|
value?: unknown;
|
|
298
301
|
summary?: string | undefined;
|
|
302
|
+
externalValue?: string | undefined;
|
|
299
303
|
}> | undefined;
|
|
304
|
+
schema?: unknown;
|
|
305
|
+
content?: unknown;
|
|
306
|
+
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
300
307
|
}[] | undefined;
|
|
301
308
|
requestBody?: any;
|
|
302
309
|
responses?: Record<string, any> | undefined;
|
|
@@ -309,8 +316,8 @@ export declare const oasRequestSchema: z.ZodObject<{
|
|
|
309
316
|
};
|
|
310
317
|
name?: string | undefined;
|
|
311
318
|
body?: {
|
|
319
|
+
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";
|
|
312
320
|
content: string | Record<string, any>;
|
|
313
|
-
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";
|
|
314
321
|
file?: {
|
|
315
322
|
url: string;
|
|
316
323
|
base64?: string | undefined;
|
|
@@ -366,29 +373,33 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
366
373
|
style: z.ZodOptional<z.ZodEnum<["matrix", "simple", "form", "label", "spaceDelimited", "pipeDelimited", "deepObject"]>>;
|
|
367
374
|
example: z.ZodOptional<z.ZodUnknown>;
|
|
368
375
|
examples: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
369
|
-
value: z.ZodUnknown
|
|
376
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
370
377
|
summary: z.ZodOptional<z.ZodString>;
|
|
378
|
+
externalValue: z.ZodOptional<z.ZodString>;
|
|
371
379
|
}, "strip", z.ZodTypeAny, {
|
|
372
380
|
value?: unknown;
|
|
373
381
|
summary?: string | undefined;
|
|
382
|
+
externalValue?: string | undefined;
|
|
374
383
|
}, {
|
|
375
384
|
value?: unknown;
|
|
376
385
|
summary?: string | undefined;
|
|
386
|
+
externalValue?: string | undefined;
|
|
377
387
|
}>>, z.ZodArray<z.ZodUnknown, "many">]>>;
|
|
378
388
|
}, "strip", z.ZodTypeAny, {
|
|
379
389
|
name: string;
|
|
380
390
|
required: boolean;
|
|
381
|
-
in: "cookie" | "path" | "query" | "header";
|
|
382
391
|
deprecated: boolean;
|
|
392
|
+
in: "cookie" | "path" | "query" | "header";
|
|
383
393
|
description?: string | undefined;
|
|
384
394
|
example?: unknown;
|
|
385
|
-
schema?: unknown;
|
|
386
|
-
content?: unknown;
|
|
387
|
-
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
388
395
|
examples?: unknown[] | Record<string, {
|
|
389
396
|
value?: unknown;
|
|
390
397
|
summary?: string | undefined;
|
|
398
|
+
externalValue?: string | undefined;
|
|
391
399
|
}> | undefined;
|
|
400
|
+
schema?: unknown;
|
|
401
|
+
content?: unknown;
|
|
402
|
+
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
392
403
|
}, {
|
|
393
404
|
name: string;
|
|
394
405
|
in: "cookie" | "path" | "query" | "header";
|
|
@@ -396,13 +407,14 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
396
407
|
required?: boolean | undefined;
|
|
397
408
|
example?: unknown;
|
|
398
409
|
deprecated?: boolean | undefined;
|
|
399
|
-
schema?: unknown;
|
|
400
|
-
content?: unknown;
|
|
401
|
-
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
402
410
|
examples?: unknown[] | Record<string, {
|
|
403
411
|
value?: unknown;
|
|
404
412
|
summary?: string | undefined;
|
|
413
|
+
externalValue?: string | undefined;
|
|
405
414
|
}> | undefined;
|
|
415
|
+
schema?: unknown;
|
|
416
|
+
content?: unknown;
|
|
417
|
+
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
406
418
|
}>, "many">>;
|
|
407
419
|
/**
|
|
408
420
|
* External documentation object
|
|
@@ -443,15 +455,15 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
443
455
|
base64?: string | undefined;
|
|
444
456
|
}>>>;
|
|
445
457
|
}, "strip", z.ZodTypeAny, {
|
|
458
|
+
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";
|
|
446
459
|
content: string | Record<string, any>;
|
|
447
|
-
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";
|
|
448
460
|
file?: {
|
|
449
461
|
url: string;
|
|
450
462
|
base64?: string | undefined;
|
|
451
463
|
} | null | undefined;
|
|
452
464
|
}, {
|
|
465
|
+
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";
|
|
453
466
|
content: string | Record<string, any>;
|
|
454
|
-
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";
|
|
455
467
|
file?: {
|
|
456
468
|
url: string;
|
|
457
469
|
base64?: string | undefined;
|
|
@@ -482,8 +494,8 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
482
494
|
};
|
|
483
495
|
name?: string | undefined;
|
|
484
496
|
body?: {
|
|
497
|
+
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";
|
|
485
498
|
content: string | Record<string, any>;
|
|
486
|
-
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";
|
|
487
499
|
file?: {
|
|
488
500
|
url: string;
|
|
489
501
|
base64?: string | undefined;
|
|
@@ -498,8 +510,8 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
498
510
|
};
|
|
499
511
|
name?: string | undefined;
|
|
500
512
|
body?: {
|
|
513
|
+
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";
|
|
501
514
|
content: string | Record<string, any>;
|
|
502
|
-
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";
|
|
503
515
|
file?: {
|
|
504
516
|
url: string;
|
|
505
517
|
base64?: string | undefined;
|
|
@@ -594,20 +606,22 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
594
606
|
parameters?: {
|
|
595
607
|
name: string;
|
|
596
608
|
required: boolean;
|
|
597
|
-
in: "cookie" | "path" | "query" | "header";
|
|
598
609
|
deprecated: boolean;
|
|
610
|
+
in: "cookie" | "path" | "query" | "header";
|
|
599
611
|
description?: string | undefined;
|
|
600
612
|
example?: unknown;
|
|
601
|
-
schema?: unknown;
|
|
602
|
-
content?: unknown;
|
|
603
|
-
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
604
613
|
examples?: unknown[] | Record<string, {
|
|
605
614
|
value?: unknown;
|
|
606
615
|
summary?: string | undefined;
|
|
616
|
+
externalValue?: string | undefined;
|
|
607
617
|
}> | undefined;
|
|
618
|
+
schema?: unknown;
|
|
619
|
+
content?: unknown;
|
|
620
|
+
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
608
621
|
}[] | undefined;
|
|
609
622
|
requestBody?: any;
|
|
610
623
|
responses?: Record<string, any> | undefined;
|
|
624
|
+
'x-scalar-stability'?: XScalarStability | undefined;
|
|
611
625
|
'x-codeSamples'?: {
|
|
612
626
|
source: string;
|
|
613
627
|
label?: string | undefined;
|
|
@@ -623,7 +637,6 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
623
637
|
label?: string | undefined;
|
|
624
638
|
lang?: string | undefined;
|
|
625
639
|
}[] | undefined;
|
|
626
|
-
'x-scalar-stability'?: XScalarStability | undefined;
|
|
627
640
|
}, {
|
|
628
641
|
uid?: string | undefined;
|
|
629
642
|
path?: string | undefined;
|
|
@@ -651,21 +664,22 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objec
|
|
|
651
664
|
required?: boolean | undefined;
|
|
652
665
|
example?: unknown;
|
|
653
666
|
deprecated?: boolean | undefined;
|
|
654
|
-
schema?: unknown;
|
|
655
|
-
content?: unknown;
|
|
656
|
-
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
657
667
|
examples?: unknown[] | Record<string, {
|
|
658
668
|
value?: unknown;
|
|
659
669
|
summary?: string | undefined;
|
|
670
|
+
externalValue?: string | undefined;
|
|
660
671
|
}> | undefined;
|
|
672
|
+
schema?: unknown;
|
|
673
|
+
content?: unknown;
|
|
674
|
+
style?: "matrix" | "simple" | "form" | "label" | "spaceDelimited" | "pipeDelimited" | "deepObject" | undefined;
|
|
661
675
|
}[] | undefined;
|
|
662
676
|
requestBody?: any;
|
|
663
677
|
responses?: Record<string, any> | undefined;
|
|
678
|
+
'x-scalar-stability'?: unknown;
|
|
679
|
+
method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
|
|
664
680
|
'x-codeSamples'?: unknown;
|
|
665
681
|
'x-code-samples'?: unknown;
|
|
666
682
|
'x-custom-examples'?: unknown;
|
|
667
|
-
'x-scalar-stability'?: unknown;
|
|
668
|
-
method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
|
|
669
683
|
}>;
|
|
670
684
|
export type Request = z.infer<typeof requestSchema>;
|
|
671
685
|
export type RequestPayload = z.input<typeof requestSchema>;
|
|
@@ -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;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM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CAAC;YACiB,CAAC;;;aAGX,CAAC;YAIN,CADC;;yBAGD,EAAA,QADK,CAAC,EAAE,WAAW,CAAC,EAAE,QAAQ,CAAC,EAC/B,SAAA;cACF,EAAA,QACA;QACE,qDAAqD;QACrD,EAAA,WADI,CAAE,EAAC,SAAS;eAAkB,EAAG,QAAQ,CAAC,EAAE,WACnD,CAAG,EAAA,SAAS;gBAAmB,EAAG,SAAS;gBAE9C;IAEF,iEAAiE;IACjE,UADS;;aAAyC,CAAC;YAChC,CAAC;;;aAGhB,CAAC;YAGA,CAAC;;;;;;;IAiFJ,eAAe;;IAEf,qBAAqB;;IAErB,kDAAkD;;IAElD,oCAAoC;;IAEpC,uDAAuD;;IAEvD,+DAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASlC,CAAA;AAE/B,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { SecurityScheme } from '@scalar/types/entities';
|
|
2
|
+
import type { Operation } from '../../entities/spec/operation.ts';
|
|
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
|
+
export declare const getSchemes: (selectedSecuritySchemes: Operation["selectedSecuritySchemeUids"], securitySchemes: Record<SecurityScheme["uid"], SecurityScheme>) => NonNullable<{
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
type: "apiKey";
|
|
8
|
+
uid: string & import("zod").BRAND<"securityScheme">;
|
|
9
|
+
nameKey: string;
|
|
10
|
+
in: "cookie" | "query" | "header";
|
|
11
|
+
description?: string | undefined;
|
|
12
|
+
} | {
|
|
13
|
+
type: "http";
|
|
14
|
+
uid: string & import("zod").BRAND<"securityScheme">;
|
|
15
|
+
nameKey: string;
|
|
16
|
+
scheme: "basic" | "bearer";
|
|
17
|
+
bearerFormat: string;
|
|
18
|
+
username: string;
|
|
19
|
+
password: string;
|
|
20
|
+
token: string;
|
|
21
|
+
description?: string | undefined;
|
|
22
|
+
} | {
|
|
23
|
+
type: "openIdConnect";
|
|
24
|
+
uid: string & import("zod").BRAND<"securityScheme">;
|
|
25
|
+
nameKey: string;
|
|
26
|
+
openIdConnectUrl: string;
|
|
27
|
+
description?: string | undefined;
|
|
28
|
+
} | {
|
|
29
|
+
type: "oauth2";
|
|
30
|
+
uid: string & import("zod").BRAND<"securityScheme">;
|
|
31
|
+
nameKey: string;
|
|
32
|
+
flows: {
|
|
33
|
+
password?: {
|
|
34
|
+
type: "password";
|
|
35
|
+
username: string;
|
|
36
|
+
password: string;
|
|
37
|
+
token: string;
|
|
38
|
+
refreshUrl: string;
|
|
39
|
+
scopes: Record<string, string>;
|
|
40
|
+
selectedScopes: string[];
|
|
41
|
+
"x-scalar-client-id": string;
|
|
42
|
+
tokenUrl: string;
|
|
43
|
+
clientSecret: string;
|
|
44
|
+
} | undefined;
|
|
45
|
+
implicit?: {
|
|
46
|
+
type: "implicit";
|
|
47
|
+
token: string;
|
|
48
|
+
refreshUrl: string;
|
|
49
|
+
scopes: Record<string, string>;
|
|
50
|
+
selectedScopes: string[];
|
|
51
|
+
"x-scalar-client-id": string;
|
|
52
|
+
authorizationUrl: string;
|
|
53
|
+
"x-scalar-redirect-uri": string;
|
|
54
|
+
} | undefined;
|
|
55
|
+
clientCredentials?: {
|
|
56
|
+
type: "clientCredentials";
|
|
57
|
+
token: string;
|
|
58
|
+
refreshUrl: string;
|
|
59
|
+
scopes: Record<string, string>;
|
|
60
|
+
selectedScopes: string[];
|
|
61
|
+
"x-scalar-client-id": string;
|
|
62
|
+
tokenUrl: string;
|
|
63
|
+
clientSecret: string;
|
|
64
|
+
} | undefined;
|
|
65
|
+
authorizationCode?: {
|
|
66
|
+
type: "authorizationCode";
|
|
67
|
+
token: string;
|
|
68
|
+
refreshUrl: string;
|
|
69
|
+
scopes: Record<string, string>;
|
|
70
|
+
selectedScopes: string[];
|
|
71
|
+
"x-scalar-client-id": string;
|
|
72
|
+
authorizationUrl: string;
|
|
73
|
+
"x-scalar-redirect-uri": string;
|
|
74
|
+
tokenUrl: string;
|
|
75
|
+
clientSecret: string;
|
|
76
|
+
"x-usePkce": "SHA-256" | "plain" | "no";
|
|
77
|
+
} | undefined;
|
|
78
|
+
};
|
|
79
|
+
description?: string | undefined;
|
|
80
|
+
'x-default-scopes'?: string | string[] | undefined;
|
|
81
|
+
}>[];
|
|
82
|
+
//# sourceMappingURL=get-schemes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-schemes.d.ts","sourceRoot":"","sources":["../../../src/helpers/security/get-schemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAG7D,2IAA2I;AAC3I,eAAO,MAAM,UAAU,4BACI,SAAS,CAAC,4BAA4B,CAAC,mBAC/C,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAOyr3D,CAAC;;;;;;;;;;;;gBAA4X,CAAC;;;;;;;;;;yBAA4V,CAAC;;;;;;;;;;yBAAkV,CAAC;;;;;;;;;;;;;;;;IADty5D,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isDefined } from '../is-defined.js';
|
|
2
|
+
|
|
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
|
+
const getSchemes = (selectedSecuritySchemes, securitySchemes) => {
|
|
5
|
+
const uids = new Set(selectedSecuritySchemes.flat());
|
|
6
|
+
return Array.from(uids)
|
|
7
|
+
.map((uid) => securitySchemes[uid])
|
|
8
|
+
.filter(isDefined);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { getSchemes };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SecurityScheme } from '@scalar/types/entities';
|
|
2
|
+
/** Pass in a security scheme and it will return true if it has a token or value depending on the scheme type */
|
|
3
|
+
export declare const hasToken: (scheme: SecurityScheme) => Boolean;
|
|
4
|
+
//# sourceMappingURL=has-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-token.d.ts","sourceRoot":"","sources":["../../../src/helpers/security/has-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE5D,gHAAgH;AAChH,eAAO,MAAM,QAAQ,WAAY,cAAc,KAAG,OAwBjD,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Pass in a security scheme and it will return true if it has a token or value depending on the scheme type */
|
|
2
|
+
const hasToken = (scheme) => {
|
|
3
|
+
// ApiKey
|
|
4
|
+
if (scheme.type === 'apiKey') {
|
|
5
|
+
return Boolean(scheme.value);
|
|
6
|
+
}
|
|
7
|
+
// Http
|
|
8
|
+
if (scheme.type === 'http') {
|
|
9
|
+
return Boolean((scheme.scheme === 'bearer' && scheme.token) || (scheme.scheme === 'basic' && scheme.username && scheme.password));
|
|
10
|
+
}
|
|
11
|
+
// OAuth2 just check for A token
|
|
12
|
+
if (scheme.type === 'oauth2') {
|
|
13
|
+
return Boolean(scheme.flows.authorizationCode?.token ||
|
|
14
|
+
scheme.flows.clientCredentials?.token ||
|
|
15
|
+
scheme.flows.password?.token ||
|
|
16
|
+
scheme.flows.implicit?.token);
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { hasToken };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/security/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.139",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -58,6 +58,11 @@
|
|
|
58
58
|
"types": "./dist/helpers/index.d.ts",
|
|
59
59
|
"default": "./dist/helpers/index.js"
|
|
60
60
|
},
|
|
61
|
+
"./helpers/security": {
|
|
62
|
+
"import": "./dist/helpers/security/index.js",
|
|
63
|
+
"types": "./dist/helpers/security/index.d.ts",
|
|
64
|
+
"default": "./dist/helpers/security/index.js"
|
|
65
|
+
},
|
|
61
66
|
"./migrations": {
|
|
62
67
|
"import": "./dist/migrations/index.js",
|
|
63
68
|
"types": "./dist/migrations/index.d.ts",
|
|
@@ -86,11 +91,11 @@
|
|
|
86
91
|
"nanoid": "^5.1.5",
|
|
87
92
|
"type-fest": "^4.20.0",
|
|
88
93
|
"yaml": "^2.4.5",
|
|
89
|
-
"zod": "
|
|
94
|
+
"zod": "3.24.1",
|
|
95
|
+
"@scalar/object-utils": "1.1.13",
|
|
90
96
|
"@scalar/openapi-types": "0.2.1",
|
|
91
|
-
"@scalar/types": "0.1.12",
|
|
92
97
|
"@scalar/themes": "0.10.4",
|
|
93
|
-
"@scalar/
|
|
98
|
+
"@scalar/types": "0.1.12"
|
|
94
99
|
},
|
|
95
100
|
"devDependencies": {
|
|
96
101
|
"@types/node": "^20.17.10",
|