@scalar/openapi-parser 0.1.0 → 0.2.0
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 +6 -0
- package/README.md +4 -4
- package/dist/index.d.ts +595 -76
- package/dist/index.js +9377 -5479
- package/package.json +9 -5
- /package/dist/{schema-7A4Uwe4k.js → schema-BQQoKgNw.js} +0 -0
- /package/dist/{schema-Oq6-IuPi.js → schema-BjykgtPd.js} +0 -0
- /package/dist/{schema-IrONjwxQ.js → schema-ZROhtp0X.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
import { OpenAPI } from 'openapi-types';
|
|
2
|
+
import { OpenAPIV2 } from 'openapi-types';
|
|
3
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
4
|
+
import { OpenAPIV3_1 } from 'openapi-types';
|
|
5
|
+
|
|
1
6
|
export declare type AjvOptions = {
|
|
2
7
|
strict?: boolean | 'log';
|
|
3
8
|
};
|
|
4
9
|
|
|
5
|
-
export declare type
|
|
10
|
+
export declare type AnyObject = Record<string, any>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Get versions of the OpenAPI specification.
|
|
14
|
+
*/
|
|
15
|
+
export declare function details(specification: AnyObject): {
|
|
16
|
+
version: "2.0" | "3.0" | "3.1";
|
|
17
|
+
specificationType: string;
|
|
18
|
+
specificationVersion: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
declare type EmptyObject = Record<string, never>;
|
|
6
22
|
|
|
7
23
|
export declare type ErrorObject = {
|
|
8
24
|
start: {
|
|
@@ -14,7 +30,36 @@ export declare type ErrorObject = {
|
|
|
14
30
|
path: string;
|
|
15
31
|
};
|
|
16
32
|
|
|
17
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Not literally a filesystem, but a list of files with their content.
|
|
35
|
+
* This is an abstraction layer to handle multiple files in the browser (without access to the hard disk).
|
|
36
|
+
*/
|
|
37
|
+
export declare type Filesystem = FilesystemEntry[];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Holds all information about a single file (doesn’t have to be a literal file, see Filesystem).
|
|
41
|
+
*/
|
|
42
|
+
export declare type FilesystemEntry = {
|
|
43
|
+
dir: string;
|
|
44
|
+
isEntrypoint: boolean;
|
|
45
|
+
references: string[];
|
|
46
|
+
filename: string;
|
|
47
|
+
specification: AnyObject;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Filter the specification based on the callback
|
|
52
|
+
*/
|
|
53
|
+
export declare function filter(specification: AnyObject, callback: (schema: AnyObject) => boolean): AnyObject;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Walks through the specification and returns all references as an array.
|
|
57
|
+
*
|
|
58
|
+
* Warning: Doesn’t return internal references.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getListOfReferences(specification: AnyObject): string[];
|
|
61
|
+
|
|
62
|
+
declare interface IJsonSchema {
|
|
18
63
|
id?: string;
|
|
19
64
|
$schema?: string;
|
|
20
65
|
title?: string;
|
|
@@ -57,15 +102,464 @@ export declare interface IJsonSchema {
|
|
|
57
102
|
$ref?: string;
|
|
58
103
|
}
|
|
59
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Check if the value is a filesystem
|
|
107
|
+
*/
|
|
108
|
+
export declare function isFilesystem(value: any): boolean;
|
|
109
|
+
|
|
110
|
+
declare function loadAction(specification: string | AnyObject): {
|
|
111
|
+
get: () => AnyObject;
|
|
112
|
+
details: () => {
|
|
113
|
+
version: "2.0" | "3.0" | "3.1";
|
|
114
|
+
specificationType: string;
|
|
115
|
+
specificationVersion: string;
|
|
116
|
+
};
|
|
117
|
+
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
118
|
+
get: () => AnyObject;
|
|
119
|
+
details: () => {
|
|
120
|
+
version: "2.0" | "3.0" | "3.1";
|
|
121
|
+
specificationType: string;
|
|
122
|
+
specificationVersion: string;
|
|
123
|
+
};
|
|
124
|
+
filter: () => any;
|
|
125
|
+
upgrade: () => {
|
|
126
|
+
get: () => AnyObject;
|
|
127
|
+
details: () => {
|
|
128
|
+
version: "2.0" | "3.0" | "3.1";
|
|
129
|
+
specificationType: string;
|
|
130
|
+
specificationVersion: string;
|
|
131
|
+
};
|
|
132
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
133
|
+
validate: () => Promise<{
|
|
134
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
135
|
+
get: () => AnyObject;
|
|
136
|
+
details: () => {
|
|
137
|
+
version: "2.0" | "3.0" | "3.1";
|
|
138
|
+
specificationType: string;
|
|
139
|
+
specificationVersion: string;
|
|
140
|
+
};
|
|
141
|
+
resolve: () => Promise<{
|
|
142
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
143
|
+
toJson: () => string;
|
|
144
|
+
toYaml: () => string;
|
|
145
|
+
valid: boolean;
|
|
146
|
+
version: string;
|
|
147
|
+
specification?: OpenAPI.Document<{}>;
|
|
148
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
149
|
+
errors?: ErrorObject[];
|
|
150
|
+
}>;
|
|
151
|
+
toJson: () => string;
|
|
152
|
+
toYaml: () => string;
|
|
153
|
+
valid: boolean;
|
|
154
|
+
specification?: OpenAPI.Document<{}>;
|
|
155
|
+
version?: string;
|
|
156
|
+
errors?: ErrorObject[];
|
|
157
|
+
}>;
|
|
158
|
+
resolve: () => Promise<{
|
|
159
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
160
|
+
toJson: () => string;
|
|
161
|
+
toYaml: () => string;
|
|
162
|
+
valid: boolean;
|
|
163
|
+
version: string;
|
|
164
|
+
specification?: OpenAPI.Document<{}>;
|
|
165
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
166
|
+
errors?: ErrorObject[];
|
|
167
|
+
}>;
|
|
168
|
+
toJson: () => string;
|
|
169
|
+
toYaml: () => string;
|
|
170
|
+
};
|
|
171
|
+
validate: () => Promise<{
|
|
172
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
173
|
+
get: () => AnyObject;
|
|
174
|
+
details: () => {
|
|
175
|
+
version: "2.0" | "3.0" | "3.1";
|
|
176
|
+
specificationType: string;
|
|
177
|
+
specificationVersion: string;
|
|
178
|
+
};
|
|
179
|
+
resolve: () => Promise<{
|
|
180
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
181
|
+
toJson: () => string;
|
|
182
|
+
toYaml: () => string;
|
|
183
|
+
valid: boolean;
|
|
184
|
+
version: string;
|
|
185
|
+
specification?: OpenAPI.Document<{}>;
|
|
186
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
187
|
+
errors?: ErrorObject[];
|
|
188
|
+
}>;
|
|
189
|
+
toJson: () => string;
|
|
190
|
+
toYaml: () => string;
|
|
191
|
+
valid: boolean;
|
|
192
|
+
specification?: OpenAPI.Document<{}>;
|
|
193
|
+
version?: string;
|
|
194
|
+
errors?: ErrorObject[];
|
|
195
|
+
}>;
|
|
196
|
+
resolve: () => Promise<{
|
|
197
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
198
|
+
toJson: () => string;
|
|
199
|
+
toYaml: () => string;
|
|
200
|
+
valid: boolean;
|
|
201
|
+
version: string;
|
|
202
|
+
specification?: OpenAPI.Document<{}>;
|
|
203
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
204
|
+
errors?: ErrorObject[];
|
|
205
|
+
}>;
|
|
206
|
+
toJson: () => string;
|
|
207
|
+
toYaml: () => string;
|
|
208
|
+
};
|
|
209
|
+
upgrade: () => {
|
|
210
|
+
get: () => AnyObject;
|
|
211
|
+
details: () => {
|
|
212
|
+
version: "2.0" | "3.0" | "3.1";
|
|
213
|
+
specificationType: string;
|
|
214
|
+
specificationVersion: string;
|
|
215
|
+
};
|
|
216
|
+
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
217
|
+
get: () => AnyObject;
|
|
218
|
+
details: () => {
|
|
219
|
+
version: "2.0" | "3.0" | "3.1";
|
|
220
|
+
specificationType: string;
|
|
221
|
+
specificationVersion: string;
|
|
222
|
+
};
|
|
223
|
+
filter: () => any;
|
|
224
|
+
upgrade: () => any;
|
|
225
|
+
validate: () => Promise<{
|
|
226
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
227
|
+
get: () => AnyObject;
|
|
228
|
+
details: () => {
|
|
229
|
+
version: "2.0" | "3.0" | "3.1";
|
|
230
|
+
specificationType: string;
|
|
231
|
+
specificationVersion: string;
|
|
232
|
+
};
|
|
233
|
+
resolve: () => Promise<{
|
|
234
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
235
|
+
toJson: () => string;
|
|
236
|
+
toYaml: () => string;
|
|
237
|
+
valid: boolean;
|
|
238
|
+
version: string;
|
|
239
|
+
specification?: OpenAPI.Document<{}>;
|
|
240
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
241
|
+
errors?: ErrorObject[];
|
|
242
|
+
}>;
|
|
243
|
+
toJson: () => string;
|
|
244
|
+
toYaml: () => string;
|
|
245
|
+
valid: boolean;
|
|
246
|
+
specification?: OpenAPI.Document<{}>;
|
|
247
|
+
version?: string;
|
|
248
|
+
errors?: ErrorObject[];
|
|
249
|
+
}>;
|
|
250
|
+
resolve: () => Promise<{
|
|
251
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
252
|
+
toJson: () => string;
|
|
253
|
+
toYaml: () => string;
|
|
254
|
+
valid: boolean;
|
|
255
|
+
version: string;
|
|
256
|
+
specification?: OpenAPI.Document<{}>;
|
|
257
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
258
|
+
errors?: ErrorObject[];
|
|
259
|
+
}>;
|
|
260
|
+
toJson: () => string;
|
|
261
|
+
toYaml: () => string;
|
|
262
|
+
};
|
|
263
|
+
validate: () => Promise<{
|
|
264
|
+
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
265
|
+
get: () => AnyObject;
|
|
266
|
+
details: () => {
|
|
267
|
+
version: "2.0" | "3.0" | "3.1";
|
|
268
|
+
specificationType: string;
|
|
269
|
+
specificationVersion: string;
|
|
270
|
+
};
|
|
271
|
+
filter: () => any;
|
|
272
|
+
upgrade: () => any;
|
|
273
|
+
validate: () => Promise<any>;
|
|
274
|
+
resolve: () => Promise<{
|
|
275
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
276
|
+
toJson: () => string;
|
|
277
|
+
toYaml: () => string;
|
|
278
|
+
valid: boolean;
|
|
279
|
+
version: string;
|
|
280
|
+
specification?: OpenAPI.Document<{}>;
|
|
281
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
282
|
+
errors?: ErrorObject[];
|
|
283
|
+
}>;
|
|
284
|
+
toJson: () => string;
|
|
285
|
+
toYaml: () => string;
|
|
286
|
+
};
|
|
287
|
+
get: () => AnyObject;
|
|
288
|
+
details: () => {
|
|
289
|
+
version: "2.0" | "3.0" | "3.1";
|
|
290
|
+
specificationType: string;
|
|
291
|
+
specificationVersion: string;
|
|
292
|
+
};
|
|
293
|
+
resolve: () => Promise<{
|
|
294
|
+
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
295
|
+
get: () => AnyObject;
|
|
296
|
+
details: () => {
|
|
297
|
+
version: "2.0" | "3.0" | "3.1";
|
|
298
|
+
specificationType: string;
|
|
299
|
+
specificationVersion: string;
|
|
300
|
+
};
|
|
301
|
+
filter: () => any;
|
|
302
|
+
upgrade: () => any;
|
|
303
|
+
validate: () => Promise<any>;
|
|
304
|
+
resolve: () => Promise<any>;
|
|
305
|
+
toJson: () => string;
|
|
306
|
+
toYaml: () => string;
|
|
307
|
+
};
|
|
308
|
+
toJson: () => string;
|
|
309
|
+
toYaml: () => string;
|
|
310
|
+
valid: boolean;
|
|
311
|
+
version: string;
|
|
312
|
+
specification?: OpenAPI.Document<{}>;
|
|
313
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
314
|
+
errors?: ErrorObject[];
|
|
315
|
+
}>;
|
|
316
|
+
toJson: () => string;
|
|
317
|
+
toYaml: () => string;
|
|
318
|
+
valid: boolean;
|
|
319
|
+
specification?: OpenAPI.Document<{}>;
|
|
320
|
+
version?: string;
|
|
321
|
+
errors?: ErrorObject[];
|
|
322
|
+
}>;
|
|
323
|
+
resolve: () => Promise<{
|
|
324
|
+
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
325
|
+
get: () => AnyObject;
|
|
326
|
+
details: () => {
|
|
327
|
+
version: "2.0" | "3.0" | "3.1";
|
|
328
|
+
specificationType: string;
|
|
329
|
+
specificationVersion: string;
|
|
330
|
+
};
|
|
331
|
+
filter: () => any;
|
|
332
|
+
upgrade: () => any;
|
|
333
|
+
validate: () => Promise<{
|
|
334
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
335
|
+
get: () => AnyObject;
|
|
336
|
+
details: () => {
|
|
337
|
+
version: "2.0" | "3.0" | "3.1";
|
|
338
|
+
specificationType: string;
|
|
339
|
+
specificationVersion: string;
|
|
340
|
+
};
|
|
341
|
+
resolve: () => Promise<any>;
|
|
342
|
+
toJson: () => string;
|
|
343
|
+
toYaml: () => string;
|
|
344
|
+
valid: boolean;
|
|
345
|
+
specification?: OpenAPI.Document<{}>;
|
|
346
|
+
version?: string;
|
|
347
|
+
errors?: ErrorObject[];
|
|
348
|
+
}>;
|
|
349
|
+
resolve: () => Promise<any>;
|
|
350
|
+
toJson: () => string;
|
|
351
|
+
toYaml: () => string;
|
|
352
|
+
};
|
|
353
|
+
toJson: () => string;
|
|
354
|
+
toYaml: () => string;
|
|
355
|
+
valid: boolean;
|
|
356
|
+
version: string;
|
|
357
|
+
specification?: OpenAPI.Document<{}>;
|
|
358
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
359
|
+
errors?: ErrorObject[];
|
|
360
|
+
}>;
|
|
361
|
+
toJson: () => string;
|
|
362
|
+
toYaml: () => string;
|
|
363
|
+
};
|
|
364
|
+
validate: () => Promise<{
|
|
365
|
+
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
366
|
+
get: () => AnyObject;
|
|
367
|
+
details: () => {
|
|
368
|
+
version: "2.0" | "3.0" | "3.1";
|
|
369
|
+
specificationType: string;
|
|
370
|
+
specificationVersion: string;
|
|
371
|
+
};
|
|
372
|
+
filter: () => any;
|
|
373
|
+
upgrade: () => {
|
|
374
|
+
get: () => AnyObject;
|
|
375
|
+
details: () => {
|
|
376
|
+
version: "2.0" | "3.0" | "3.1";
|
|
377
|
+
specificationType: string;
|
|
378
|
+
specificationVersion: string;
|
|
379
|
+
};
|
|
380
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
381
|
+
validate: () => Promise<any>;
|
|
382
|
+
resolve: () => Promise<{
|
|
383
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
384
|
+
toJson: () => string;
|
|
385
|
+
toYaml: () => string;
|
|
386
|
+
valid: boolean;
|
|
387
|
+
version: string;
|
|
388
|
+
specification?: OpenAPI.Document<{}>;
|
|
389
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
390
|
+
errors?: ErrorObject[];
|
|
391
|
+
}>;
|
|
392
|
+
toJson: () => string;
|
|
393
|
+
toYaml: () => string;
|
|
394
|
+
};
|
|
395
|
+
validate: () => Promise<any>;
|
|
396
|
+
resolve: () => Promise<{
|
|
397
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
398
|
+
toJson: () => string;
|
|
399
|
+
toYaml: () => string;
|
|
400
|
+
valid: boolean;
|
|
401
|
+
version: string;
|
|
402
|
+
specification?: OpenAPI.Document<{}>;
|
|
403
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
404
|
+
errors?: ErrorObject[];
|
|
405
|
+
}>;
|
|
406
|
+
toJson: () => string;
|
|
407
|
+
toYaml: () => string;
|
|
408
|
+
};
|
|
409
|
+
get: () => AnyObject;
|
|
410
|
+
details: () => {
|
|
411
|
+
version: "2.0" | "3.0" | "3.1";
|
|
412
|
+
specificationType: string;
|
|
413
|
+
specificationVersion: string;
|
|
414
|
+
};
|
|
415
|
+
resolve: () => Promise<{
|
|
416
|
+
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
417
|
+
get: () => AnyObject;
|
|
418
|
+
details: () => {
|
|
419
|
+
version: "2.0" | "3.0" | "3.1";
|
|
420
|
+
specificationType: string;
|
|
421
|
+
specificationVersion: string;
|
|
422
|
+
};
|
|
423
|
+
filter: () => any;
|
|
424
|
+
upgrade: () => {
|
|
425
|
+
get: () => AnyObject;
|
|
426
|
+
details: () => {
|
|
427
|
+
version: "2.0" | "3.0" | "3.1";
|
|
428
|
+
specificationType: string;
|
|
429
|
+
specificationVersion: string;
|
|
430
|
+
};
|
|
431
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
432
|
+
validate: () => Promise<any>;
|
|
433
|
+
resolve: () => Promise<any>;
|
|
434
|
+
toJson: () => string;
|
|
435
|
+
toYaml: () => string;
|
|
436
|
+
};
|
|
437
|
+
validate: () => Promise<any>;
|
|
438
|
+
resolve: () => Promise<any>;
|
|
439
|
+
toJson: () => string;
|
|
440
|
+
toYaml: () => string;
|
|
441
|
+
};
|
|
442
|
+
toJson: () => string;
|
|
443
|
+
toYaml: () => string;
|
|
444
|
+
valid: boolean;
|
|
445
|
+
version: string;
|
|
446
|
+
specification?: OpenAPI.Document<{}>;
|
|
447
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
448
|
+
errors?: ErrorObject[];
|
|
449
|
+
}>;
|
|
450
|
+
toJson: () => string;
|
|
451
|
+
toYaml: () => string;
|
|
452
|
+
valid: boolean;
|
|
453
|
+
specification?: OpenAPI.Document<{}>;
|
|
454
|
+
version?: string;
|
|
455
|
+
errors?: ErrorObject[];
|
|
456
|
+
}>;
|
|
457
|
+
resolve: () => Promise<{
|
|
458
|
+
filter: (callback: (Specification: AnyObject) => boolean) => {
|
|
459
|
+
get: () => AnyObject;
|
|
460
|
+
details: () => {
|
|
461
|
+
version: "2.0" | "3.0" | "3.1";
|
|
462
|
+
specificationType: string;
|
|
463
|
+
specificationVersion: string;
|
|
464
|
+
};
|
|
465
|
+
filter: () => any;
|
|
466
|
+
upgrade: () => {
|
|
467
|
+
get: () => AnyObject;
|
|
468
|
+
details: () => {
|
|
469
|
+
version: "2.0" | "3.0" | "3.1";
|
|
470
|
+
specificationType: string;
|
|
471
|
+
specificationVersion: string;
|
|
472
|
+
};
|
|
473
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
474
|
+
validate: () => Promise<{
|
|
475
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
476
|
+
get: () => AnyObject;
|
|
477
|
+
details: () => {
|
|
478
|
+
version: "2.0" | "3.0" | "3.1";
|
|
479
|
+
specificationType: string;
|
|
480
|
+
specificationVersion: string;
|
|
481
|
+
};
|
|
482
|
+
resolve: () => Promise<any>;
|
|
483
|
+
toJson: () => string;
|
|
484
|
+
toYaml: () => string;
|
|
485
|
+
valid: boolean;
|
|
486
|
+
specification?: OpenAPI.Document<{}>;
|
|
487
|
+
version?: string;
|
|
488
|
+
errors?: ErrorObject[];
|
|
489
|
+
}>;
|
|
490
|
+
resolve: () => Promise<any>;
|
|
491
|
+
toJson: () => string;
|
|
492
|
+
toYaml: () => string;
|
|
493
|
+
};
|
|
494
|
+
validate: () => Promise<{
|
|
495
|
+
filter: (callback: (Specification: AnyObject) => boolean) => any;
|
|
496
|
+
get: () => AnyObject;
|
|
497
|
+
details: () => {
|
|
498
|
+
version: "2.0" | "3.0" | "3.1";
|
|
499
|
+
specificationType: string;
|
|
500
|
+
specificationVersion: string;
|
|
501
|
+
};
|
|
502
|
+
resolve: () => Promise<any>;
|
|
503
|
+
toJson: () => string;
|
|
504
|
+
toYaml: () => string;
|
|
505
|
+
valid: boolean;
|
|
506
|
+
specification?: OpenAPI.Document<{}>;
|
|
507
|
+
version?: string;
|
|
508
|
+
errors?: ErrorObject[];
|
|
509
|
+
}>;
|
|
510
|
+
resolve: () => Promise<any>;
|
|
511
|
+
toJson: () => string;
|
|
512
|
+
toYaml: () => string;
|
|
513
|
+
};
|
|
514
|
+
toJson: () => string;
|
|
515
|
+
toYaml: () => string;
|
|
516
|
+
valid: boolean;
|
|
517
|
+
version: string;
|
|
518
|
+
specification?: OpenAPI.Document<{}>;
|
|
519
|
+
schema?: ResolvedOpenAPI.Document<EmptyObject>;
|
|
520
|
+
errors?: ErrorObject[];
|
|
521
|
+
}>;
|
|
522
|
+
toJson: () => string;
|
|
523
|
+
toYaml: () => string;
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Load a given file from the filesystem, and all its references. (Node-only)
|
|
528
|
+
*/
|
|
529
|
+
export declare function loadFiles(file: string, basePath?: string): any[];
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Normalize the OpenAPI specification to a JavaScript object.
|
|
533
|
+
* Don’t touch the object if it’s a `Filesystem` (multiple files).
|
|
534
|
+
*/
|
|
535
|
+
export declare function normalize(specification: string | AnyObject | Filesystem): AnyObject | Filesystem;
|
|
536
|
+
|
|
537
|
+
export { OpenAPI }
|
|
538
|
+
|
|
539
|
+
export declare function openapi(): {
|
|
540
|
+
load: typeof loadAction;
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
export { OpenAPIV2 }
|
|
544
|
+
|
|
545
|
+
export { OpenAPIV3 }
|
|
546
|
+
|
|
547
|
+
export { OpenAPIV3_1 }
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Validates an OpenAPI schema and resolves all references.
|
|
551
|
+
*/
|
|
552
|
+
export declare function resolve(value: string | AnyObject | Filesystem): Promise<ResolveResult>;
|
|
553
|
+
|
|
60
554
|
/**
|
|
61
555
|
* These types are copied from 'openapi-types', but the `ReferenceObject` type is removed.
|
|
62
|
-
* After an
|
|
556
|
+
* After an ResolvedOpenAPI schema is parsed, all references are resolved and replaced with the actual object.
|
|
63
557
|
*/
|
|
64
|
-
export declare namespace
|
|
65
|
-
export type Document<T extends {} = EmptyObject> =
|
|
66
|
-
export type Operation<T extends {} = EmptyObject> =
|
|
67
|
-
export type Parameter =
|
|
68
|
-
export type Parameters =
|
|
558
|
+
export declare namespace ResolvedOpenAPI {
|
|
559
|
+
export type Document<T extends {} = EmptyObject> = ResolvedOpenAPIV2.Document<T> | ResolvedOpenAPIV3.Document<T> | ResolvedOpenAPIV3_1.Document<T>;
|
|
560
|
+
export type Operation<T extends {} = EmptyObject> = ResolvedOpenAPIV2.OperationObject<T> | ResolvedOpenAPIV3.OperationObject<T> | ResolvedOpenAPIV3_1.OperationObject<T>;
|
|
561
|
+
export type Parameter = ResolvedOpenAPIV3_1.ParameterObject | ResolvedOpenAPIV3.ParameterObject | ResolvedOpenAPIV2.Parameter;
|
|
562
|
+
export type Parameters = ResolvedOpenAPIV3_1.ParameterObject[] | ResolvedOpenAPIV3.ParameterObject[] | ResolvedOpenAPIV2.Parameter[];
|
|
69
563
|
export interface Request {
|
|
70
564
|
body?: any;
|
|
71
565
|
headers?: object;
|
|
@@ -74,7 +568,7 @@ export declare namespace OpenAPI {
|
|
|
74
568
|
}
|
|
75
569
|
}
|
|
76
570
|
|
|
77
|
-
export declare namespace
|
|
571
|
+
export declare namespace ResolvedOpenAPIV2 {
|
|
78
572
|
export interface Document<T extends {} = EmptyObject> {
|
|
79
573
|
'basePath'?: string;
|
|
80
574
|
'consumes'?: MimeTypes;
|
|
@@ -93,6 +587,7 @@ export declare namespace OpenAPIV2 {
|
|
|
93
587
|
'tags'?: TagObject[];
|
|
94
588
|
'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
|
|
95
589
|
'x-express-openapi-validation-strict'?: boolean;
|
|
590
|
+
'components': undefined;
|
|
96
591
|
}
|
|
97
592
|
export interface TagObject {
|
|
98
593
|
name: string;
|
|
@@ -157,6 +652,7 @@ export declare namespace OpenAPIV2 {
|
|
|
157
652
|
schema?: Schema;
|
|
158
653
|
headers?: HeadersObject;
|
|
159
654
|
examples?: ExampleObject;
|
|
655
|
+
content: undefined;
|
|
160
656
|
}
|
|
161
657
|
export interface HeadersObject {
|
|
162
658
|
[index: string]: HeaderObject;
|
|
@@ -296,9 +792,9 @@ export declare namespace OpenAPIV2 {
|
|
|
296
792
|
}
|
|
297
793
|
}
|
|
298
794
|
|
|
299
|
-
export declare namespace
|
|
795
|
+
export declare namespace ResolvedOpenAPIV3 {
|
|
300
796
|
export interface Document<T extends {} = EmptyObject> {
|
|
301
|
-
'
|
|
797
|
+
'Resolvedopenapi': string;
|
|
302
798
|
'info': InfoObject;
|
|
303
799
|
'servers'?: ServerObject[];
|
|
304
800
|
'paths': PathsObject<T>;
|
|
@@ -615,55 +1111,55 @@ export declare namespace OpenAPIV3 {
|
|
|
615
1111
|
}
|
|
616
1112
|
}
|
|
617
1113
|
|
|
618
|
-
export declare namespace
|
|
1114
|
+
export declare namespace ResolvedOpenAPIV3_1 {
|
|
619
1115
|
export type Modify<T, R> = Omit<T, keyof R> & R;
|
|
620
1116
|
export type PathsWebhooksComponents<T extends {} = EmptyObject> = {
|
|
621
1117
|
paths: PathsObject<T>;
|
|
622
1118
|
webhooks: Record<string, PathItemObject>;
|
|
623
1119
|
components: ComponentsObject;
|
|
624
1120
|
};
|
|
625
|
-
export type Document<T extends {} = EmptyObject> = Modify<Omit<
|
|
1121
|
+
export type Document<T extends {} = EmptyObject> = Modify<Omit<ResolvedOpenAPIV3.Document<T>, 'paths' | 'components'>, {
|
|
626
1122
|
info: InfoObject;
|
|
627
1123
|
jsonSchemaDialect?: string;
|
|
628
1124
|
servers?: ServerObject[];
|
|
629
1125
|
} & ((Pick<PathsWebhooksComponents<T>, 'paths'> & Omit<Partial<PathsWebhooksComponents<T>>, 'paths'>) | (Pick<PathsWebhooksComponents<T>, 'webhooks'> & Omit<Partial<PathsWebhooksComponents<T>>, 'webhooks'>) | (Pick<PathsWebhooksComponents<T>, 'components'> & Omit<Partial<PathsWebhooksComponents<T>>, 'components'>))>;
|
|
630
|
-
export type InfoObject = Modify<
|
|
1126
|
+
export type InfoObject = Modify<ResolvedOpenAPIV3.InfoObject, {
|
|
631
1127
|
summary?: string;
|
|
632
1128
|
license?: LicenseObject;
|
|
633
1129
|
}>;
|
|
634
|
-
export type ContactObject =
|
|
635
|
-
export type LicenseObject = Modify<
|
|
1130
|
+
export type ContactObject = ResolvedOpenAPIV3.ContactObject;
|
|
1131
|
+
export type LicenseObject = Modify<ResolvedOpenAPIV3.LicenseObject, {
|
|
636
1132
|
identifier?: string;
|
|
637
1133
|
}>;
|
|
638
|
-
export type ServerObject = Modify<
|
|
1134
|
+
export type ServerObject = Modify<ResolvedOpenAPIV3.ServerObject, {
|
|
639
1135
|
url: string;
|
|
640
1136
|
description?: string;
|
|
641
1137
|
variables?: Record<string, ServerVariableObject>;
|
|
642
1138
|
}>;
|
|
643
|
-
export type ServerVariableObject = Modify<
|
|
1139
|
+
export type ServerVariableObject = Modify<ResolvedOpenAPIV3.ServerVariableObject, {
|
|
644
1140
|
enum?: [string, ...string[]];
|
|
645
1141
|
}>;
|
|
646
1142
|
export type PathsObject<T extends {} = EmptyObject, P extends {} = EmptyObject> = Record<string, (PathItemObject<T> & P) | undefined>;
|
|
647
|
-
export type HttpMethods =
|
|
648
|
-
export type PathItemObject<T extends {} = EmptyObject> = Modify<
|
|
1143
|
+
export type HttpMethods = ResolvedOpenAPIV3.HttpMethods;
|
|
1144
|
+
export type PathItemObject<T extends {} = EmptyObject> = Modify<ResolvedOpenAPIV3.PathItemObject<T>, {
|
|
649
1145
|
servers?: ServerObject[];
|
|
650
1146
|
parameters?: ParameterObject[];
|
|
651
1147
|
}> & {
|
|
652
1148
|
[method in HttpMethods]?: OperationObject<T>;
|
|
653
1149
|
};
|
|
654
|
-
export type OperationObject<T extends {} = EmptyObject> = Modify<
|
|
1150
|
+
export type OperationObject<T extends {} = EmptyObject> = Modify<ResolvedOpenAPIV3.OperationObject<T>, {
|
|
655
1151
|
parameters?: ParameterObject[];
|
|
656
1152
|
requestBody?: RequestBodyObject;
|
|
657
1153
|
responses?: ResponsesObject;
|
|
658
1154
|
callbacks?: Record<string, CallbackObject>;
|
|
659
1155
|
servers?: ServerObject[];
|
|
660
1156
|
}> & T;
|
|
661
|
-
export type ExternalDocumentationObject =
|
|
662
|
-
export type ParameterObject =
|
|
663
|
-
export type HeaderObject =
|
|
664
|
-
export type ParameterBaseObject =
|
|
665
|
-
export type NonArraySchemaObjectType =
|
|
666
|
-
export type ArraySchemaObjectType =
|
|
1157
|
+
export type ExternalDocumentationObject = ResolvedOpenAPIV3.ExternalDocumentationObject;
|
|
1158
|
+
export type ParameterObject = ResolvedOpenAPIV3.ParameterObject;
|
|
1159
|
+
export type HeaderObject = ResolvedOpenAPIV3.HeaderObject;
|
|
1160
|
+
export type ParameterBaseObject = ResolvedOpenAPIV3.ParameterBaseObject;
|
|
1161
|
+
export type NonArraySchemaObjectType = ResolvedOpenAPIV3.NonArraySchemaObjectType | 'null';
|
|
1162
|
+
export type ArraySchemaObjectType = ResolvedOpenAPIV3.ArraySchemaObjectType;
|
|
667
1163
|
/**
|
|
668
1164
|
* There is no way to tell typescript to require items when type is either 'array' or array containing 'array' type
|
|
669
1165
|
* 'items' will be always visible as optional
|
|
@@ -681,8 +1177,8 @@ export declare namespace OpenAPIV3_1 {
|
|
|
681
1177
|
type?: (ArraySchemaObjectType | NonArraySchemaObjectType)[];
|
|
682
1178
|
items?: SchemaObject;
|
|
683
1179
|
}
|
|
684
|
-
export type BaseSchemaObject = Modify<Omit<
|
|
685
|
-
examples?:
|
|
1180
|
+
export type BaseSchemaObject = Modify<Omit<ResolvedOpenAPIV3.BaseSchemaObject, 'nullable'>, {
|
|
1181
|
+
examples?: ResolvedOpenAPIV3.BaseSchemaObject['example'][];
|
|
686
1182
|
exclusiveMinimum?: boolean | number;
|
|
687
1183
|
exclusiveMaximum?: boolean | number;
|
|
688
1184
|
contentMediaType?: string;
|
|
@@ -700,21 +1196,21 @@ export declare namespace OpenAPIV3_1 {
|
|
|
700
1196
|
xml?: XMLObject;
|
|
701
1197
|
const?: any;
|
|
702
1198
|
}>;
|
|
703
|
-
export type DiscriminatorObject =
|
|
704
|
-
export type XMLObject =
|
|
705
|
-
export type ExampleObject =
|
|
706
|
-
export type MediaTypeObject = Modify<
|
|
1199
|
+
export type DiscriminatorObject = ResolvedOpenAPIV3.DiscriminatorObject;
|
|
1200
|
+
export type XMLObject = ResolvedOpenAPIV3.XMLObject;
|
|
1201
|
+
export type ExampleObject = ResolvedOpenAPIV3.ExampleObject;
|
|
1202
|
+
export type MediaTypeObject = Modify<ResolvedOpenAPIV3.MediaTypeObject, {
|
|
707
1203
|
schema?: SchemaObject;
|
|
708
1204
|
examples?: Record<string, ExampleObject>;
|
|
709
1205
|
}>;
|
|
710
|
-
export type EncodingObject =
|
|
711
|
-
export type RequestBodyObject = Modify<
|
|
1206
|
+
export type EncodingObject = ResolvedOpenAPIV3.EncodingObject;
|
|
1207
|
+
export type RequestBodyObject = Modify<ResolvedOpenAPIV3.RequestBodyObject, {
|
|
712
1208
|
content: {
|
|
713
1209
|
[media: string]: MediaTypeObject;
|
|
714
1210
|
};
|
|
715
1211
|
}>;
|
|
716
1212
|
export type ResponsesObject = Record<string, ResponseObject>;
|
|
717
|
-
export type ResponseObject = Modify<
|
|
1213
|
+
export type ResponseObject = Modify<ResolvedOpenAPIV3.ResponseObject, {
|
|
718
1214
|
headers?: {
|
|
719
1215
|
[header: string]: HeaderObject;
|
|
720
1216
|
};
|
|
@@ -725,12 +1221,12 @@ export declare namespace OpenAPIV3_1 {
|
|
|
725
1221
|
[link: string]: LinkObject;
|
|
726
1222
|
};
|
|
727
1223
|
}>;
|
|
728
|
-
export type LinkObject = Modify<
|
|
1224
|
+
export type LinkObject = Modify<ResolvedOpenAPIV3.LinkObject, {
|
|
729
1225
|
server?: ServerObject;
|
|
730
1226
|
}>;
|
|
731
1227
|
export type CallbackObject = Record<string, PathItemObject>;
|
|
732
|
-
export type SecurityRequirementObject =
|
|
733
|
-
export type ComponentsObject = Modify<
|
|
1228
|
+
export type SecurityRequirementObject = ResolvedOpenAPIV3.SecurityRequirementObject;
|
|
1229
|
+
export type ComponentsObject = Modify<ResolvedOpenAPIV3.ComponentsObject, {
|
|
734
1230
|
schemas?: Record<string, SchemaObject>;
|
|
735
1231
|
responses?: Record<string, ResponseObject>;
|
|
736
1232
|
parameters?: Record<string, ParameterObject>;
|
|
@@ -742,66 +1238,89 @@ export declare namespace OpenAPIV3_1 {
|
|
|
742
1238
|
callbacks?: Record<string, CallbackObject>;
|
|
743
1239
|
pathItems?: Record<string, PathItemObject>;
|
|
744
1240
|
}>;
|
|
745
|
-
export type SecuritySchemeObject =
|
|
746
|
-
export type HttpSecurityScheme =
|
|
747
|
-
export type ApiKeySecurityScheme =
|
|
748
|
-
export type OAuth2SecurityScheme =
|
|
749
|
-
export type OpenIdSecurityScheme =
|
|
750
|
-
export type TagObject =
|
|
1241
|
+
export type SecuritySchemeObject = ResolvedOpenAPIV3.SecuritySchemeObject;
|
|
1242
|
+
export type HttpSecurityScheme = ResolvedOpenAPIV3.HttpSecurityScheme;
|
|
1243
|
+
export type ApiKeySecurityScheme = ResolvedOpenAPIV3.ApiKeySecurityScheme;
|
|
1244
|
+
export type OAuth2SecurityScheme = ResolvedOpenAPIV3.OAuth2SecurityScheme;
|
|
1245
|
+
export type OpenIdSecurityScheme = ResolvedOpenAPIV3.OpenIdSecurityScheme;
|
|
1246
|
+
export type TagObject = ResolvedOpenAPIV3.TagObject;
|
|
751
1247
|
}
|
|
752
1248
|
|
|
753
|
-
|
|
754
|
-
* Validates an OpenAPI schema and resolves all references.
|
|
755
|
-
*/
|
|
756
|
-
export declare function parse(value: string): Promise<ParseResult>;
|
|
757
|
-
|
|
758
|
-
export declare type ParseResult = {
|
|
1249
|
+
export declare type ResolveResult = {
|
|
759
1250
|
valid: boolean;
|
|
760
1251
|
version: string | undefined;
|
|
761
|
-
|
|
1252
|
+
specification?: OpenAPI.Document;
|
|
1253
|
+
schema?: ResolvedOpenAPI.Document;
|
|
762
1254
|
errors?: ErrorObject[];
|
|
763
1255
|
};
|
|
764
1256
|
|
|
765
|
-
|
|
766
|
-
$id?: string;
|
|
767
|
-
};
|
|
1257
|
+
declare type SupportedVersion = (typeof supportedVersions)[number];
|
|
768
1258
|
|
|
769
1259
|
/**
|
|
770
|
-
*
|
|
1260
|
+
* A list of the supported OpenAPI versions
|
|
771
1261
|
*/
|
|
772
|
-
|
|
1262
|
+
declare const supportedVersions: readonly ["2.0", "3.0", "3.1"];
|
|
773
1263
|
|
|
774
|
-
export declare
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
1264
|
+
export declare const toJson: (value: AnyObject) => string;
|
|
1265
|
+
|
|
1266
|
+
export declare const toYaml: (value: AnyObject) => string;
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Recursively traverses the specification and applies the transform function to each node.
|
|
1270
|
+
*/
|
|
1271
|
+
export declare function traverse(specification: AnyObject, transform: (specification: AnyObject) => AnyObject): AnyObject;
|
|
1272
|
+
|
|
1273
|
+
/**
|
|
1274
|
+
* Upgrade specification to OpenAPI 3.1.0
|
|
1275
|
+
*/
|
|
1276
|
+
export declare function upgrade(specification: AnyObject): AnyObject;
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* Upgrade from OpenAPI 3.0.x to 3.1.0
|
|
1280
|
+
*
|
|
1281
|
+
* https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0
|
|
1282
|
+
*/
|
|
1283
|
+
export declare function upgradeFromThreeToThreeOne(specification: AnyObject): AnyObject;
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* Upgrade Swagger 2.0 to OpenAPI 3.0
|
|
1287
|
+
*
|
|
1288
|
+
* https://swagger.io/blog/news/whats-new-in-openapi-3-0/
|
|
1289
|
+
*/
|
|
1290
|
+
export declare function upgradeFromTwoToThree(specification: AnyObject): AnyObject;
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* Validates an OpenAPI schema.
|
|
1294
|
+
*/
|
|
1295
|
+
export declare function validate(value: string | AnyObject | Filesystem): Promise<ValidateResult>;
|
|
778
1296
|
|
|
779
1297
|
export declare type ValidateResult = {
|
|
780
1298
|
valid: boolean;
|
|
1299
|
+
specification?: OpenAPI.Document;
|
|
1300
|
+
version?: string;
|
|
781
1301
|
errors?: ErrorObject[];
|
|
782
1302
|
};
|
|
783
1303
|
|
|
784
1304
|
export declare class Validator {
|
|
785
|
-
|
|
786
|
-
|
|
1305
|
+
version: string;
|
|
1306
|
+
static supportedVersions: readonly ["2.0", "3.0", "3.1"];
|
|
1307
|
+
protected ajvValidators: Record<string, ((specification: AnyObject) => boolean) & {
|
|
787
1308
|
errors: string;
|
|
788
1309
|
}>;
|
|
789
|
-
protected externalRefs: Record<string,
|
|
790
|
-
protected specification: Specification;
|
|
791
|
-
version: string;
|
|
1310
|
+
protected externalRefs: Record<string, AnyObject>;
|
|
792
1311
|
protected errors: string;
|
|
793
1312
|
protected specificationVersion: string;
|
|
794
1313
|
protected specificationType: string;
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
1314
|
+
specification: AnyObject;
|
|
1315
|
+
resolveReferences(filesystem?: Filesystem): ResolvedOpenAPI.Document<EmptyObject>;
|
|
1316
|
+
/**
|
|
1317
|
+
* Checks whether a specification is valid and all references can be resolved.
|
|
1318
|
+
*/
|
|
1319
|
+
validate(filesystem: Filesystem): Promise<ValidateResult>;
|
|
1320
|
+
/**
|
|
1321
|
+
* Ajv JSON schema validator
|
|
1322
|
+
*/
|
|
1323
|
+
getAjvValidator(version: SupportedVersion): Promise<any>;
|
|
805
1324
|
}
|
|
806
1325
|
|
|
807
1326
|
export { }
|