@scalar/openapi-parser 0.0.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 +13 -0
- package/README.md +21 -11
- package/dist/index.d.ts +1326 -0
- package/dist/index.js +9379 -5476
- package/package.json +10 -11
- /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
ADDED
|
@@ -0,0 +1,1326 @@
|
|
|
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
|
+
|
|
6
|
+
export declare type AjvOptions = {
|
|
7
|
+
strict?: boolean | 'log';
|
|
8
|
+
};
|
|
9
|
+
|
|
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>;
|
|
22
|
+
|
|
23
|
+
export declare type ErrorObject = {
|
|
24
|
+
start: {
|
|
25
|
+
line: number;
|
|
26
|
+
column: number;
|
|
27
|
+
offset: number;
|
|
28
|
+
};
|
|
29
|
+
error: string;
|
|
30
|
+
path: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
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 {
|
|
63
|
+
id?: string;
|
|
64
|
+
$schema?: string;
|
|
65
|
+
title?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
multipleOf?: number;
|
|
68
|
+
maximum?: number;
|
|
69
|
+
exclusiveMaximum?: boolean;
|
|
70
|
+
minimum?: number;
|
|
71
|
+
exclusiveMinimum?: boolean;
|
|
72
|
+
maxLength?: number;
|
|
73
|
+
minLength?: number;
|
|
74
|
+
pattern?: string;
|
|
75
|
+
additionalItems?: boolean | IJsonSchema;
|
|
76
|
+
items?: IJsonSchema | IJsonSchema[];
|
|
77
|
+
maxItems?: number;
|
|
78
|
+
minItems?: number;
|
|
79
|
+
uniqueItems?: boolean;
|
|
80
|
+
maxProperties?: number;
|
|
81
|
+
minProperties?: number;
|
|
82
|
+
required?: string[];
|
|
83
|
+
additionalProperties?: boolean | IJsonSchema;
|
|
84
|
+
definitions?: {
|
|
85
|
+
[name: string]: IJsonSchema;
|
|
86
|
+
};
|
|
87
|
+
properties?: {
|
|
88
|
+
[name: string]: IJsonSchema;
|
|
89
|
+
};
|
|
90
|
+
patternProperties?: {
|
|
91
|
+
[name: string]: IJsonSchema;
|
|
92
|
+
};
|
|
93
|
+
dependencies?: {
|
|
94
|
+
[name: string]: IJsonSchema | string[];
|
|
95
|
+
};
|
|
96
|
+
enum?: any[];
|
|
97
|
+
type?: string | string[];
|
|
98
|
+
allOf?: IJsonSchema[];
|
|
99
|
+
anyOf?: IJsonSchema[];
|
|
100
|
+
oneOf?: IJsonSchema[];
|
|
101
|
+
not?: IJsonSchema;
|
|
102
|
+
$ref?: string;
|
|
103
|
+
}
|
|
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
|
+
|
|
554
|
+
/**
|
|
555
|
+
* These types are copied from 'openapi-types', but the `ReferenceObject` type is removed.
|
|
556
|
+
* After an ResolvedOpenAPI schema is parsed, all references are resolved and replaced with the actual object.
|
|
557
|
+
*/
|
|
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[];
|
|
563
|
+
export interface Request {
|
|
564
|
+
body?: any;
|
|
565
|
+
headers?: object;
|
|
566
|
+
params?: object;
|
|
567
|
+
query?: object;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
export declare namespace ResolvedOpenAPIV2 {
|
|
572
|
+
export interface Document<T extends {} = EmptyObject> {
|
|
573
|
+
'basePath'?: string;
|
|
574
|
+
'consumes'?: MimeTypes;
|
|
575
|
+
'definitions'?: DefinitionsObject;
|
|
576
|
+
'externalDocs'?: ExternalDocumentationObject;
|
|
577
|
+
'host'?: string;
|
|
578
|
+
'info': InfoObject;
|
|
579
|
+
'parameters'?: ParametersDefinitionsObject;
|
|
580
|
+
'paths': PathsObject<T>;
|
|
581
|
+
'produces'?: MimeTypes;
|
|
582
|
+
'responses'?: ResponsesDefinitionsObject;
|
|
583
|
+
'schemes'?: string[];
|
|
584
|
+
'security'?: SecurityRequirementObject[];
|
|
585
|
+
'securityDefinitions'?: SecurityDefinitionsObject;
|
|
586
|
+
'swagger': string;
|
|
587
|
+
'tags'?: TagObject[];
|
|
588
|
+
'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
|
|
589
|
+
'x-express-openapi-validation-strict'?: boolean;
|
|
590
|
+
'components': undefined;
|
|
591
|
+
}
|
|
592
|
+
export interface TagObject {
|
|
593
|
+
name: string;
|
|
594
|
+
description?: string;
|
|
595
|
+
externalDocs?: ExternalDocumentationObject;
|
|
596
|
+
}
|
|
597
|
+
export interface SecuritySchemeObjectBase {
|
|
598
|
+
type: 'basic' | 'apiKey' | 'oauth2';
|
|
599
|
+
description?: string;
|
|
600
|
+
}
|
|
601
|
+
export interface SecuritySchemeBasic extends SecuritySchemeObjectBase {
|
|
602
|
+
type: 'basic';
|
|
603
|
+
}
|
|
604
|
+
export interface SecuritySchemeApiKey extends SecuritySchemeObjectBase {
|
|
605
|
+
type: 'apiKey';
|
|
606
|
+
name: string;
|
|
607
|
+
in: string;
|
|
608
|
+
}
|
|
609
|
+
export type SecuritySchemeOauth2 = SecuritySchemeOauth2Implicit | SecuritySchemeOauth2AccessCode | SecuritySchemeOauth2Password | SecuritySchemeOauth2Application;
|
|
610
|
+
export interface ScopesObject {
|
|
611
|
+
[index: string]: any;
|
|
612
|
+
}
|
|
613
|
+
export interface SecuritySchemeOauth2Base extends SecuritySchemeObjectBase {
|
|
614
|
+
type: 'oauth2';
|
|
615
|
+
flow: 'implicit' | 'password' | 'application' | 'accessCode';
|
|
616
|
+
scopes: ScopesObject;
|
|
617
|
+
}
|
|
618
|
+
export interface SecuritySchemeOauth2Implicit extends SecuritySchemeOauth2Base {
|
|
619
|
+
flow: 'implicit';
|
|
620
|
+
authorizationUrl: string;
|
|
621
|
+
}
|
|
622
|
+
export interface SecuritySchemeOauth2AccessCode extends SecuritySchemeOauth2Base {
|
|
623
|
+
flow: 'accessCode';
|
|
624
|
+
authorizationUrl: string;
|
|
625
|
+
tokenUrl: string;
|
|
626
|
+
}
|
|
627
|
+
export interface SecuritySchemeOauth2Password extends SecuritySchemeOauth2Base {
|
|
628
|
+
flow: 'password';
|
|
629
|
+
tokenUrl: string;
|
|
630
|
+
}
|
|
631
|
+
export interface SecuritySchemeOauth2Application extends SecuritySchemeOauth2Base {
|
|
632
|
+
flow: 'application';
|
|
633
|
+
tokenUrl: string;
|
|
634
|
+
}
|
|
635
|
+
export type SecuritySchemeObject = SecuritySchemeBasic | SecuritySchemeApiKey | SecuritySchemeOauth2;
|
|
636
|
+
export interface SecurityDefinitionsObject {
|
|
637
|
+
[index: string]: SecuritySchemeObject;
|
|
638
|
+
}
|
|
639
|
+
export interface SecurityRequirementObject {
|
|
640
|
+
[index: string]: string[];
|
|
641
|
+
}
|
|
642
|
+
export interface ReferenceObject {
|
|
643
|
+
$ref: string;
|
|
644
|
+
}
|
|
645
|
+
export type Response = ResponseObject;
|
|
646
|
+
export interface ResponsesDefinitionsObject {
|
|
647
|
+
[index: string]: ResponseObject;
|
|
648
|
+
}
|
|
649
|
+
export type Schema = SchemaObject;
|
|
650
|
+
export interface ResponseObject {
|
|
651
|
+
description: string;
|
|
652
|
+
schema?: Schema;
|
|
653
|
+
headers?: HeadersObject;
|
|
654
|
+
examples?: ExampleObject;
|
|
655
|
+
content: undefined;
|
|
656
|
+
}
|
|
657
|
+
export interface HeadersObject {
|
|
658
|
+
[index: string]: HeaderObject;
|
|
659
|
+
}
|
|
660
|
+
export interface HeaderObject extends ItemsObject {
|
|
661
|
+
description?: string;
|
|
662
|
+
}
|
|
663
|
+
export interface ExampleObject {
|
|
664
|
+
[index: string]: any;
|
|
665
|
+
}
|
|
666
|
+
export interface ResponseObject {
|
|
667
|
+
description: string;
|
|
668
|
+
schema?: Schema;
|
|
669
|
+
headers?: HeadersObject;
|
|
670
|
+
examples?: ExampleObject;
|
|
671
|
+
}
|
|
672
|
+
export type OperationObject<T extends {} = EmptyObject> = {
|
|
673
|
+
tags?: string[];
|
|
674
|
+
summary?: string;
|
|
675
|
+
description?: string;
|
|
676
|
+
externalDocs?: ExternalDocumentationObject;
|
|
677
|
+
operationId?: string;
|
|
678
|
+
consumes?: MimeTypes;
|
|
679
|
+
produces?: MimeTypes;
|
|
680
|
+
parameters?: Parameters;
|
|
681
|
+
responses: ResponsesObject;
|
|
682
|
+
schemes?: string[];
|
|
683
|
+
deprecated?: boolean;
|
|
684
|
+
security?: SecurityRequirementObject[];
|
|
685
|
+
} & T;
|
|
686
|
+
export interface ResponsesObject {
|
|
687
|
+
[index: string]: Response | undefined;
|
|
688
|
+
default?: Response;
|
|
689
|
+
}
|
|
690
|
+
export type Parameters = (ReferenceObject | Parameter)[];
|
|
691
|
+
export type Parameter = InBodyParameterObject | GeneralParameterObject;
|
|
692
|
+
export interface InBodyParameterObject extends ParameterObject {
|
|
693
|
+
schema: Schema;
|
|
694
|
+
}
|
|
695
|
+
export interface GeneralParameterObject extends ParameterObject, ItemsObject {
|
|
696
|
+
allowEmptyValue?: boolean;
|
|
697
|
+
}
|
|
698
|
+
export enum HttpMethods {
|
|
699
|
+
GET = "get",
|
|
700
|
+
PUT = "put",
|
|
701
|
+
POST = "post",
|
|
702
|
+
DELETE = "delete",
|
|
703
|
+
OPTIONS = "options",
|
|
704
|
+
HEAD = "head",
|
|
705
|
+
PATCH = "patch"
|
|
706
|
+
}
|
|
707
|
+
export type PathItemObject<T extends {} = EmptyObject> = {
|
|
708
|
+
$ref?: string;
|
|
709
|
+
parameters?: Parameters;
|
|
710
|
+
} & {
|
|
711
|
+
[method in HttpMethods]?: OperationObject<T>;
|
|
712
|
+
};
|
|
713
|
+
export interface PathsObject<T extends {} = EmptyObject> {
|
|
714
|
+
[index: string]: PathItemObject<T>;
|
|
715
|
+
}
|
|
716
|
+
export interface ParametersDefinitionsObject {
|
|
717
|
+
[index: string]: ParameterObject;
|
|
718
|
+
}
|
|
719
|
+
export interface ParameterObject {
|
|
720
|
+
name: string;
|
|
721
|
+
in: string;
|
|
722
|
+
description?: string;
|
|
723
|
+
required?: boolean;
|
|
724
|
+
[index: string]: any;
|
|
725
|
+
}
|
|
726
|
+
export type MimeTypes = string[];
|
|
727
|
+
export interface DefinitionsObject {
|
|
728
|
+
[index: string]: SchemaObject;
|
|
729
|
+
}
|
|
730
|
+
export interface SchemaObject extends IJsonSchema {
|
|
731
|
+
[index: string]: any;
|
|
732
|
+
discriminator?: string;
|
|
733
|
+
readOnly?: boolean;
|
|
734
|
+
xml?: XMLObject;
|
|
735
|
+
externalDocs?: ExternalDocumentationObject;
|
|
736
|
+
example?: any;
|
|
737
|
+
default?: any;
|
|
738
|
+
items?: ItemsObject;
|
|
739
|
+
properties?: {
|
|
740
|
+
[name: string]: SchemaObject;
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
export interface ExternalDocumentationObject {
|
|
744
|
+
[index: string]: any;
|
|
745
|
+
description?: string;
|
|
746
|
+
url: string;
|
|
747
|
+
}
|
|
748
|
+
export interface ItemsObject {
|
|
749
|
+
type: string;
|
|
750
|
+
format?: string;
|
|
751
|
+
items?: ItemsObject;
|
|
752
|
+
collectionFormat?: string;
|
|
753
|
+
default?: any;
|
|
754
|
+
maximum?: number;
|
|
755
|
+
exclusiveMaximum?: boolean;
|
|
756
|
+
minimum?: number;
|
|
757
|
+
exclusiveMinimum?: boolean;
|
|
758
|
+
maxLength?: number;
|
|
759
|
+
minLength?: number;
|
|
760
|
+
pattern?: string;
|
|
761
|
+
maxItems?: number;
|
|
762
|
+
minItems?: number;
|
|
763
|
+
uniqueItems?: boolean;
|
|
764
|
+
enum?: any[];
|
|
765
|
+
multipleOf?: number;
|
|
766
|
+
$ref?: string;
|
|
767
|
+
}
|
|
768
|
+
export interface XMLObject {
|
|
769
|
+
[index: string]: any;
|
|
770
|
+
name?: string;
|
|
771
|
+
namespace?: string;
|
|
772
|
+
prefix?: string;
|
|
773
|
+
attribute?: boolean;
|
|
774
|
+
wrapped?: boolean;
|
|
775
|
+
}
|
|
776
|
+
export interface InfoObject {
|
|
777
|
+
title: string;
|
|
778
|
+
description?: string;
|
|
779
|
+
termsOfService?: string;
|
|
780
|
+
contact?: ContactObject;
|
|
781
|
+
license?: LicenseObject;
|
|
782
|
+
version: string;
|
|
783
|
+
}
|
|
784
|
+
export interface ContactObject {
|
|
785
|
+
name?: string;
|
|
786
|
+
url?: string;
|
|
787
|
+
email?: string;
|
|
788
|
+
}
|
|
789
|
+
export interface LicenseObject {
|
|
790
|
+
name: string;
|
|
791
|
+
url?: string;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
export declare namespace ResolvedOpenAPIV3 {
|
|
796
|
+
export interface Document<T extends {} = EmptyObject> {
|
|
797
|
+
'Resolvedopenapi': string;
|
|
798
|
+
'info': InfoObject;
|
|
799
|
+
'servers'?: ServerObject[];
|
|
800
|
+
'paths': PathsObject<T>;
|
|
801
|
+
'components'?: ComponentsObject;
|
|
802
|
+
'security'?: SecurityRequirementObject[];
|
|
803
|
+
'tags'?: TagObject[];
|
|
804
|
+
'externalDocs'?: ExternalDocumentationObject;
|
|
805
|
+
'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
|
|
806
|
+
'x-express-openapi-validation-strict'?: boolean;
|
|
807
|
+
}
|
|
808
|
+
export interface InfoObject {
|
|
809
|
+
title: string;
|
|
810
|
+
description?: string;
|
|
811
|
+
termsOfService?: string;
|
|
812
|
+
contact?: ContactObject;
|
|
813
|
+
license?: LicenseObject;
|
|
814
|
+
version: string;
|
|
815
|
+
}
|
|
816
|
+
export interface ContactObject {
|
|
817
|
+
name?: string;
|
|
818
|
+
url?: string;
|
|
819
|
+
email?: string;
|
|
820
|
+
}
|
|
821
|
+
export interface LicenseObject {
|
|
822
|
+
name: string;
|
|
823
|
+
url?: string;
|
|
824
|
+
}
|
|
825
|
+
export interface ServerObject {
|
|
826
|
+
url: string;
|
|
827
|
+
description?: string;
|
|
828
|
+
variables?: {
|
|
829
|
+
[variable: string]: ServerVariableObject;
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
export interface ServerVariableObject {
|
|
833
|
+
enum?: string[];
|
|
834
|
+
default: string;
|
|
835
|
+
description?: string;
|
|
836
|
+
}
|
|
837
|
+
export interface PathsObject<T extends {} = EmptyObject, P extends {} = EmptyObject> {
|
|
838
|
+
[pattern: string]: (PathItemObject<T> & P) | undefined;
|
|
839
|
+
}
|
|
840
|
+
export enum HttpMethods {
|
|
841
|
+
GET = "get",
|
|
842
|
+
PUT = "put",
|
|
843
|
+
POST = "post",
|
|
844
|
+
DELETE = "delete",
|
|
845
|
+
OPTIONS = "options",
|
|
846
|
+
HEAD = "head",
|
|
847
|
+
PATCH = "patch",
|
|
848
|
+
TRACE = "trace"
|
|
849
|
+
}
|
|
850
|
+
export type PathItemObject<T extends {} = EmptyObject> = {
|
|
851
|
+
$ref?: string;
|
|
852
|
+
summary?: string;
|
|
853
|
+
description?: string;
|
|
854
|
+
servers?: ServerObject[];
|
|
855
|
+
parameters?: ParameterObject[];
|
|
856
|
+
} & {
|
|
857
|
+
[method in HttpMethods]?: OperationObject<T>;
|
|
858
|
+
};
|
|
859
|
+
export type OperationObject<T extends {} = EmptyObject> = {
|
|
860
|
+
tags?: string[];
|
|
861
|
+
summary?: string;
|
|
862
|
+
description?: string;
|
|
863
|
+
externalDocs?: ExternalDocumentationObject;
|
|
864
|
+
operationId?: string;
|
|
865
|
+
parameters?: ParameterObject[];
|
|
866
|
+
requestBody?: RequestBodyObject;
|
|
867
|
+
responses: ResponsesObject;
|
|
868
|
+
callbacks?: {
|
|
869
|
+
[callback: string]: CallbackObject;
|
|
870
|
+
};
|
|
871
|
+
deprecated?: boolean;
|
|
872
|
+
security?: SecurityRequirementObject[];
|
|
873
|
+
servers?: ServerObject[];
|
|
874
|
+
} & T;
|
|
875
|
+
export interface ExternalDocumentationObject {
|
|
876
|
+
description?: string;
|
|
877
|
+
url: string;
|
|
878
|
+
}
|
|
879
|
+
export interface ParameterObject extends ParameterBaseObject {
|
|
880
|
+
name: string;
|
|
881
|
+
in: string;
|
|
882
|
+
}
|
|
883
|
+
export interface HeaderObject extends ParameterBaseObject {
|
|
884
|
+
}
|
|
885
|
+
export interface ParameterBaseObject {
|
|
886
|
+
description?: string;
|
|
887
|
+
required?: boolean;
|
|
888
|
+
deprecated?: boolean;
|
|
889
|
+
allowEmptyValue?: boolean;
|
|
890
|
+
style?: string;
|
|
891
|
+
explode?: boolean;
|
|
892
|
+
allowReserved?: boolean;
|
|
893
|
+
schema?: SchemaObject;
|
|
894
|
+
example?: any;
|
|
895
|
+
examples?: {
|
|
896
|
+
[media: string]: ExampleObject;
|
|
897
|
+
};
|
|
898
|
+
content?: {
|
|
899
|
+
[media: string]: MediaTypeObject;
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
export type NonArraySchemaObjectType = 'boolean' | 'object' | 'number' | 'string' | 'integer';
|
|
903
|
+
export type ArraySchemaObjectType = 'array';
|
|
904
|
+
export type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
|
|
905
|
+
export interface ArraySchemaObject extends BaseSchemaObject {
|
|
906
|
+
type: ArraySchemaObjectType;
|
|
907
|
+
items: SchemaObject;
|
|
908
|
+
}
|
|
909
|
+
export interface NonArraySchemaObject extends BaseSchemaObject {
|
|
910
|
+
type?: NonArraySchemaObjectType;
|
|
911
|
+
}
|
|
912
|
+
export interface BaseSchemaObject {
|
|
913
|
+
title?: string;
|
|
914
|
+
description?: string;
|
|
915
|
+
format?: string;
|
|
916
|
+
default?: any;
|
|
917
|
+
multipleOf?: number;
|
|
918
|
+
maximum?: number;
|
|
919
|
+
exclusiveMaximum?: boolean;
|
|
920
|
+
minimum?: number;
|
|
921
|
+
exclusiveMinimum?: boolean;
|
|
922
|
+
maxLength?: number;
|
|
923
|
+
minLength?: number;
|
|
924
|
+
pattern?: string;
|
|
925
|
+
additionalProperties?: boolean | SchemaObject;
|
|
926
|
+
maxItems?: number;
|
|
927
|
+
minItems?: number;
|
|
928
|
+
uniqueItems?: boolean;
|
|
929
|
+
maxProperties?: number;
|
|
930
|
+
minProperties?: number;
|
|
931
|
+
required?: string[];
|
|
932
|
+
enum?: any[];
|
|
933
|
+
properties?: {
|
|
934
|
+
[name: string]: SchemaObject;
|
|
935
|
+
};
|
|
936
|
+
allOf?: SchemaObject[];
|
|
937
|
+
oneOf?: SchemaObject[];
|
|
938
|
+
anyOf?: SchemaObject[];
|
|
939
|
+
not?: SchemaObject;
|
|
940
|
+
nullable?: boolean;
|
|
941
|
+
discriminator?: DiscriminatorObject;
|
|
942
|
+
readOnly?: boolean;
|
|
943
|
+
writeOnly?: boolean;
|
|
944
|
+
xml?: XMLObject;
|
|
945
|
+
externalDocs?: ExternalDocumentationObject;
|
|
946
|
+
example?: any;
|
|
947
|
+
deprecated?: boolean;
|
|
948
|
+
}
|
|
949
|
+
export interface DiscriminatorObject {
|
|
950
|
+
propertyName: string;
|
|
951
|
+
mapping?: {
|
|
952
|
+
[value: string]: string;
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
export interface XMLObject {
|
|
956
|
+
name?: string;
|
|
957
|
+
namespace?: string;
|
|
958
|
+
prefix?: string;
|
|
959
|
+
attribute?: boolean;
|
|
960
|
+
wrapped?: boolean;
|
|
961
|
+
}
|
|
962
|
+
export interface ExampleObject {
|
|
963
|
+
summary?: string;
|
|
964
|
+
description?: string;
|
|
965
|
+
value?: any;
|
|
966
|
+
externalValue?: string;
|
|
967
|
+
}
|
|
968
|
+
export interface MediaTypeObject {
|
|
969
|
+
schema?: SchemaObject;
|
|
970
|
+
example?: any;
|
|
971
|
+
examples?: {
|
|
972
|
+
[media: string]: ExampleObject;
|
|
973
|
+
};
|
|
974
|
+
encoding?: {
|
|
975
|
+
[media: string]: EncodingObject;
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
export interface EncodingObject {
|
|
979
|
+
contentType?: string;
|
|
980
|
+
headers?: {
|
|
981
|
+
[header: string]: HeaderObject;
|
|
982
|
+
};
|
|
983
|
+
style?: string;
|
|
984
|
+
explode?: boolean;
|
|
985
|
+
allowReserved?: boolean;
|
|
986
|
+
}
|
|
987
|
+
export interface RequestBodyObject {
|
|
988
|
+
description?: string;
|
|
989
|
+
content: {
|
|
990
|
+
[media: string]: MediaTypeObject;
|
|
991
|
+
};
|
|
992
|
+
required?: boolean;
|
|
993
|
+
}
|
|
994
|
+
export interface ResponsesObject {
|
|
995
|
+
[code: string]: ResponseObject;
|
|
996
|
+
}
|
|
997
|
+
export interface ResponseObject {
|
|
998
|
+
description: string;
|
|
999
|
+
headers?: {
|
|
1000
|
+
[header: string]: HeaderObject;
|
|
1001
|
+
};
|
|
1002
|
+
content?: {
|
|
1003
|
+
[media: string]: MediaTypeObject;
|
|
1004
|
+
};
|
|
1005
|
+
links?: {
|
|
1006
|
+
[link: string]: LinkObject;
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
export interface LinkObject {
|
|
1010
|
+
operationRef?: string;
|
|
1011
|
+
operationId?: string;
|
|
1012
|
+
parameters?: {
|
|
1013
|
+
[parameter: string]: any;
|
|
1014
|
+
};
|
|
1015
|
+
requestBody?: any;
|
|
1016
|
+
description?: string;
|
|
1017
|
+
server?: ServerObject;
|
|
1018
|
+
}
|
|
1019
|
+
export interface CallbackObject {
|
|
1020
|
+
[url: string]: PathItemObject;
|
|
1021
|
+
}
|
|
1022
|
+
export interface SecurityRequirementObject {
|
|
1023
|
+
[name: string]: string[];
|
|
1024
|
+
}
|
|
1025
|
+
export interface ComponentsObject {
|
|
1026
|
+
schemas?: {
|
|
1027
|
+
[key: string]: SchemaObject;
|
|
1028
|
+
};
|
|
1029
|
+
responses?: {
|
|
1030
|
+
[key: string]: ResponseObject;
|
|
1031
|
+
};
|
|
1032
|
+
parameters?: {
|
|
1033
|
+
[key: string]: ParameterObject;
|
|
1034
|
+
};
|
|
1035
|
+
examples?: {
|
|
1036
|
+
[key: string]: ExampleObject;
|
|
1037
|
+
};
|
|
1038
|
+
requestBodies?: {
|
|
1039
|
+
[key: string]: RequestBodyObject;
|
|
1040
|
+
};
|
|
1041
|
+
headers?: {
|
|
1042
|
+
[key: string]: HeaderObject;
|
|
1043
|
+
};
|
|
1044
|
+
securitySchemes?: {
|
|
1045
|
+
[key: string]: SecuritySchemeObject;
|
|
1046
|
+
};
|
|
1047
|
+
links?: {
|
|
1048
|
+
[key: string]: LinkObject;
|
|
1049
|
+
};
|
|
1050
|
+
callbacks?: {
|
|
1051
|
+
[key: string]: CallbackObject;
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
export type SecuritySchemeObject = HttpSecurityScheme | ApiKeySecurityScheme | OAuth2SecurityScheme | OpenIdSecurityScheme;
|
|
1055
|
+
export interface HttpSecurityScheme {
|
|
1056
|
+
type: 'http';
|
|
1057
|
+
description?: string;
|
|
1058
|
+
scheme: string;
|
|
1059
|
+
bearerFormat?: string;
|
|
1060
|
+
}
|
|
1061
|
+
export interface ApiKeySecurityScheme {
|
|
1062
|
+
type: 'apiKey';
|
|
1063
|
+
description?: string;
|
|
1064
|
+
name: string;
|
|
1065
|
+
in: string;
|
|
1066
|
+
}
|
|
1067
|
+
export interface OAuth2SecurityScheme {
|
|
1068
|
+
type: 'oauth2';
|
|
1069
|
+
description?: string;
|
|
1070
|
+
flows: {
|
|
1071
|
+
implicit?: {
|
|
1072
|
+
authorizationUrl: string;
|
|
1073
|
+
refreshUrl?: string;
|
|
1074
|
+
scopes: {
|
|
1075
|
+
[scope: string]: string;
|
|
1076
|
+
};
|
|
1077
|
+
};
|
|
1078
|
+
password?: {
|
|
1079
|
+
tokenUrl: string;
|
|
1080
|
+
refreshUrl?: string;
|
|
1081
|
+
scopes: {
|
|
1082
|
+
[scope: string]: string;
|
|
1083
|
+
};
|
|
1084
|
+
};
|
|
1085
|
+
clientCredentials?: {
|
|
1086
|
+
tokenUrl: string;
|
|
1087
|
+
refreshUrl?: string;
|
|
1088
|
+
scopes: {
|
|
1089
|
+
[scope: string]: string;
|
|
1090
|
+
};
|
|
1091
|
+
};
|
|
1092
|
+
authorizationCode?: {
|
|
1093
|
+
authorizationUrl: string;
|
|
1094
|
+
tokenUrl: string;
|
|
1095
|
+
refreshUrl?: string;
|
|
1096
|
+
scopes: {
|
|
1097
|
+
[scope: string]: string;
|
|
1098
|
+
};
|
|
1099
|
+
};
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
export interface OpenIdSecurityScheme {
|
|
1103
|
+
type: 'openIdConnect';
|
|
1104
|
+
description?: string;
|
|
1105
|
+
openIdConnectUrl: string;
|
|
1106
|
+
}
|
|
1107
|
+
export interface TagObject {
|
|
1108
|
+
name: string;
|
|
1109
|
+
description?: string;
|
|
1110
|
+
externalDocs?: ExternalDocumentationObject;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
export declare namespace ResolvedOpenAPIV3_1 {
|
|
1115
|
+
export type Modify<T, R> = Omit<T, keyof R> & R;
|
|
1116
|
+
export type PathsWebhooksComponents<T extends {} = EmptyObject> = {
|
|
1117
|
+
paths: PathsObject<T>;
|
|
1118
|
+
webhooks: Record<string, PathItemObject>;
|
|
1119
|
+
components: ComponentsObject;
|
|
1120
|
+
};
|
|
1121
|
+
export type Document<T extends {} = EmptyObject> = Modify<Omit<ResolvedOpenAPIV3.Document<T>, 'paths' | 'components'>, {
|
|
1122
|
+
info: InfoObject;
|
|
1123
|
+
jsonSchemaDialect?: string;
|
|
1124
|
+
servers?: ServerObject[];
|
|
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'>))>;
|
|
1126
|
+
export type InfoObject = Modify<ResolvedOpenAPIV3.InfoObject, {
|
|
1127
|
+
summary?: string;
|
|
1128
|
+
license?: LicenseObject;
|
|
1129
|
+
}>;
|
|
1130
|
+
export type ContactObject = ResolvedOpenAPIV3.ContactObject;
|
|
1131
|
+
export type LicenseObject = Modify<ResolvedOpenAPIV3.LicenseObject, {
|
|
1132
|
+
identifier?: string;
|
|
1133
|
+
}>;
|
|
1134
|
+
export type ServerObject = Modify<ResolvedOpenAPIV3.ServerObject, {
|
|
1135
|
+
url: string;
|
|
1136
|
+
description?: string;
|
|
1137
|
+
variables?: Record<string, ServerVariableObject>;
|
|
1138
|
+
}>;
|
|
1139
|
+
export type ServerVariableObject = Modify<ResolvedOpenAPIV3.ServerVariableObject, {
|
|
1140
|
+
enum?: [string, ...string[]];
|
|
1141
|
+
}>;
|
|
1142
|
+
export type PathsObject<T extends {} = EmptyObject, P extends {} = EmptyObject> = Record<string, (PathItemObject<T> & P) | undefined>;
|
|
1143
|
+
export type HttpMethods = ResolvedOpenAPIV3.HttpMethods;
|
|
1144
|
+
export type PathItemObject<T extends {} = EmptyObject> = Modify<ResolvedOpenAPIV3.PathItemObject<T>, {
|
|
1145
|
+
servers?: ServerObject[];
|
|
1146
|
+
parameters?: ParameterObject[];
|
|
1147
|
+
}> & {
|
|
1148
|
+
[method in HttpMethods]?: OperationObject<T>;
|
|
1149
|
+
};
|
|
1150
|
+
export type OperationObject<T extends {} = EmptyObject> = Modify<ResolvedOpenAPIV3.OperationObject<T>, {
|
|
1151
|
+
parameters?: ParameterObject[];
|
|
1152
|
+
requestBody?: RequestBodyObject;
|
|
1153
|
+
responses?: ResponsesObject;
|
|
1154
|
+
callbacks?: Record<string, CallbackObject>;
|
|
1155
|
+
servers?: ServerObject[];
|
|
1156
|
+
}> & T;
|
|
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;
|
|
1163
|
+
/**
|
|
1164
|
+
* There is no way to tell typescript to require items when type is either 'array' or array containing 'array' type
|
|
1165
|
+
* 'items' will be always visible as optional
|
|
1166
|
+
* Casting schema object to ArraySchemaObject or NonArraySchemaObject will work fine
|
|
1167
|
+
*/
|
|
1168
|
+
export type SchemaObject = ArraySchemaObject | NonArraySchemaObject | MixedSchemaObject;
|
|
1169
|
+
export interface ArraySchemaObject extends BaseSchemaObject {
|
|
1170
|
+
type: ArraySchemaObjectType;
|
|
1171
|
+
items: SchemaObject;
|
|
1172
|
+
}
|
|
1173
|
+
export interface NonArraySchemaObject extends BaseSchemaObject {
|
|
1174
|
+
type?: NonArraySchemaObjectType;
|
|
1175
|
+
}
|
|
1176
|
+
export interface MixedSchemaObject extends BaseSchemaObject {
|
|
1177
|
+
type?: (ArraySchemaObjectType | NonArraySchemaObjectType)[];
|
|
1178
|
+
items?: SchemaObject;
|
|
1179
|
+
}
|
|
1180
|
+
export type BaseSchemaObject = Modify<Omit<ResolvedOpenAPIV3.BaseSchemaObject, 'nullable'>, {
|
|
1181
|
+
examples?: ResolvedOpenAPIV3.BaseSchemaObject['example'][];
|
|
1182
|
+
exclusiveMinimum?: boolean | number;
|
|
1183
|
+
exclusiveMaximum?: boolean | number;
|
|
1184
|
+
contentMediaType?: string;
|
|
1185
|
+
$schema?: string;
|
|
1186
|
+
additionalProperties?: boolean | SchemaObject;
|
|
1187
|
+
properties?: {
|
|
1188
|
+
[name: string]: SchemaObject;
|
|
1189
|
+
};
|
|
1190
|
+
allOf?: SchemaObject[];
|
|
1191
|
+
oneOf?: SchemaObject[];
|
|
1192
|
+
anyOf?: SchemaObject[];
|
|
1193
|
+
not?: SchemaObject;
|
|
1194
|
+
discriminator?: DiscriminatorObject;
|
|
1195
|
+
externalDocs?: ExternalDocumentationObject;
|
|
1196
|
+
xml?: XMLObject;
|
|
1197
|
+
const?: any;
|
|
1198
|
+
}>;
|
|
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, {
|
|
1203
|
+
schema?: SchemaObject;
|
|
1204
|
+
examples?: Record<string, ExampleObject>;
|
|
1205
|
+
}>;
|
|
1206
|
+
export type EncodingObject = ResolvedOpenAPIV3.EncodingObject;
|
|
1207
|
+
export type RequestBodyObject = Modify<ResolvedOpenAPIV3.RequestBodyObject, {
|
|
1208
|
+
content: {
|
|
1209
|
+
[media: string]: MediaTypeObject;
|
|
1210
|
+
};
|
|
1211
|
+
}>;
|
|
1212
|
+
export type ResponsesObject = Record<string, ResponseObject>;
|
|
1213
|
+
export type ResponseObject = Modify<ResolvedOpenAPIV3.ResponseObject, {
|
|
1214
|
+
headers?: {
|
|
1215
|
+
[header: string]: HeaderObject;
|
|
1216
|
+
};
|
|
1217
|
+
content?: {
|
|
1218
|
+
[media: string]: MediaTypeObject;
|
|
1219
|
+
};
|
|
1220
|
+
links?: {
|
|
1221
|
+
[link: string]: LinkObject;
|
|
1222
|
+
};
|
|
1223
|
+
}>;
|
|
1224
|
+
export type LinkObject = Modify<ResolvedOpenAPIV3.LinkObject, {
|
|
1225
|
+
server?: ServerObject;
|
|
1226
|
+
}>;
|
|
1227
|
+
export type CallbackObject = Record<string, PathItemObject>;
|
|
1228
|
+
export type SecurityRequirementObject = ResolvedOpenAPIV3.SecurityRequirementObject;
|
|
1229
|
+
export type ComponentsObject = Modify<ResolvedOpenAPIV3.ComponentsObject, {
|
|
1230
|
+
schemas?: Record<string, SchemaObject>;
|
|
1231
|
+
responses?: Record<string, ResponseObject>;
|
|
1232
|
+
parameters?: Record<string, ParameterObject>;
|
|
1233
|
+
examples?: Record<string, ExampleObject>;
|
|
1234
|
+
requestBodies?: Record<string, RequestBodyObject>;
|
|
1235
|
+
headers?: Record<string, HeaderObject>;
|
|
1236
|
+
securitySchemes?: Record<string, SecuritySchemeObject>;
|
|
1237
|
+
links?: Record<string, LinkObject>;
|
|
1238
|
+
callbacks?: Record<string, CallbackObject>;
|
|
1239
|
+
pathItems?: Record<string, PathItemObject>;
|
|
1240
|
+
}>;
|
|
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;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
export declare type ResolveResult = {
|
|
1250
|
+
valid: boolean;
|
|
1251
|
+
version: string | undefined;
|
|
1252
|
+
specification?: OpenAPI.Document;
|
|
1253
|
+
schema?: ResolvedOpenAPI.Document;
|
|
1254
|
+
errors?: ErrorObject[];
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
declare type SupportedVersion = (typeof supportedVersions)[number];
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* A list of the supported OpenAPI versions
|
|
1261
|
+
*/
|
|
1262
|
+
declare const supportedVersions: readonly ["2.0", "3.0", "3.1"];
|
|
1263
|
+
|
|
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>;
|
|
1296
|
+
|
|
1297
|
+
export declare type ValidateResult = {
|
|
1298
|
+
valid: boolean;
|
|
1299
|
+
specification?: OpenAPI.Document;
|
|
1300
|
+
version?: string;
|
|
1301
|
+
errors?: ErrorObject[];
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1304
|
+
export declare class Validator {
|
|
1305
|
+
version: string;
|
|
1306
|
+
static supportedVersions: readonly ["2.0", "3.0", "3.1"];
|
|
1307
|
+
protected ajvValidators: Record<string, ((specification: AnyObject) => boolean) & {
|
|
1308
|
+
errors: string;
|
|
1309
|
+
}>;
|
|
1310
|
+
protected externalRefs: Record<string, AnyObject>;
|
|
1311
|
+
protected errors: string;
|
|
1312
|
+
protected specificationVersion: string;
|
|
1313
|
+
protected specificationType: string;
|
|
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>;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
export { }
|