@trapi/swagger 1.2.3 → 2.0.0-beta.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.
Files changed (118) hide show
  1. package/README.MD +146 -6
  2. package/dist/index.d.mts +812 -0
  3. package/dist/index.d.mts.map +1 -0
  4. package/dist/index.mjs +1306 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/package.json +22 -16
  7. package/dist/config/index.d.ts +0 -3
  8. package/dist/config/index.d.ts.map +0 -1
  9. package/dist/config/index.js +0 -25
  10. package/dist/config/index.js.map +0 -1
  11. package/dist/config/type.d.ts +0 -83
  12. package/dist/config/type.d.ts.map +0 -1
  13. package/dist/config/type.js +0 -9
  14. package/dist/config/type.js.map +0 -1
  15. package/dist/config/utils.d.ts +0 -3
  16. package/dist/config/utils.d.ts.map +0 -1
  17. package/dist/config/utils.js +0 -54
  18. package/dist/config/utils.js.map +0 -1
  19. package/dist/constants.d.ts +0 -15
  20. package/dist/constants.d.ts.map +0 -1
  21. package/dist/constants.js +0 -27
  22. package/dist/constants.js.map +0 -1
  23. package/dist/generator/abstract.d.ts +0 -35
  24. package/dist/generator/abstract.d.ts.map +0 -1
  25. package/dist/generator/abstract.js +0 -252
  26. package/dist/generator/abstract.js.map +0 -1
  27. package/dist/generator/index.d.ts +0 -5
  28. package/dist/generator/index.d.ts.map +0 -1
  29. package/dist/generator/index.js +0 -27
  30. package/dist/generator/index.js.map +0 -1
  31. package/dist/generator/module.d.ts +0 -14
  32. package/dist/generator/module.d.ts.map +0 -1
  33. package/dist/generator/module.js +0 -35
  34. package/dist/generator/module.js.map +0 -1
  35. package/dist/generator/v2/index.d.ts +0 -2
  36. package/dist/generator/v2/index.d.ts.map +0 -1
  37. package/dist/generator/v2/index.js +0 -24
  38. package/dist/generator/v2/index.js.map +0 -1
  39. package/dist/generator/v2/module.d.ts +0 -25
  40. package/dist/generator/v2/module.d.ts.map +0 -1
  41. package/dist/generator/v2/module.js +0 -517
  42. package/dist/generator/v2/module.js.map +0 -1
  43. package/dist/generator/v3/index.d.ts +0 -2
  44. package/dist/generator/v3/index.d.ts.map +0 -1
  45. package/dist/generator/v3/index.js +0 -24
  46. package/dist/generator/v3/index.js.map +0 -1
  47. package/dist/generator/v3/module.d.ts +0 -30
  48. package/dist/generator/v3/module.d.ts.map +0 -1
  49. package/dist/generator/v3/module.js +0 -500
  50. package/dist/generator/v3/module.js.map +0 -1
  51. package/dist/index.d.ts +0 -8
  52. package/dist/index.d.ts.map +0 -1
  53. package/dist/index.js +0 -30
  54. package/dist/index.js.map +0 -1
  55. package/dist/metadata.d.ts +0 -4
  56. package/dist/metadata.d.ts.map +0 -1
  57. package/dist/metadata.js +0 -14
  58. package/dist/metadata.js.map +0 -1
  59. package/dist/schema/constants.d.ts +0 -28
  60. package/dist/schema/constants.d.ts.map +0 -1
  61. package/dist/schema/constants.js +0 -40
  62. package/dist/schema/constants.js.map +0 -1
  63. package/dist/schema/index.d.ts +0 -5
  64. package/dist/schema/index.d.ts.map +0 -1
  65. package/dist/schema/index.js +0 -27
  66. package/dist/schema/index.js.map +0 -1
  67. package/dist/schema/type.d.ts +0 -139
  68. package/dist/schema/type.d.ts.map +0 -1
  69. package/dist/schema/type.js +0 -9
  70. package/dist/schema/type.js.map +0 -1
  71. package/dist/schema/v2/constants.d.ts +0 -8
  72. package/dist/schema/v2/constants.d.ts.map +0 -1
  73. package/dist/schema/v2/constants.js +0 -18
  74. package/dist/schema/v2/constants.js.map +0 -1
  75. package/dist/schema/v2/index.d.ts +0 -3
  76. package/dist/schema/v2/index.d.ts.map +0 -1
  77. package/dist/schema/v2/index.js +0 -25
  78. package/dist/schema/v2/index.js.map +0 -1
  79. package/dist/schema/v2/type.d.ts +0 -116
  80. package/dist/schema/v2/type.d.ts.map +0 -1
  81. package/dist/schema/v2/type.js +0 -9
  82. package/dist/schema/v2/type.js.map +0 -1
  83. package/dist/schema/v3/constants.d.ts +0 -7
  84. package/dist/schema/v3/constants.d.ts.map +0 -1
  85. package/dist/schema/v3/constants.js +0 -17
  86. package/dist/schema/v3/constants.js.map +0 -1
  87. package/dist/schema/v3/index.d.ts +0 -3
  88. package/dist/schema/v3/index.d.ts.map +0 -1
  89. package/dist/schema/v3/index.js +0 -25
  90. package/dist/schema/v3/index.js.map +0 -1
  91. package/dist/schema/v3/type.d.ts +0 -159
  92. package/dist/schema/v3/type.d.ts.map +0 -1
  93. package/dist/schema/v3/type.js +0 -9
  94. package/dist/schema/v3/type.js.map +0 -1
  95. package/dist/type.d.ts +0 -49
  96. package/dist/type.d.ts.map +0 -1
  97. package/dist/type.js +0 -9
  98. package/dist/type.js.map +0 -1
  99. package/dist/utils/character.d.ts +0 -3
  100. package/dist/utils/character.d.ts.map +0 -1
  101. package/dist/utils/character.js +0 -21
  102. package/dist/utils/character.js.map +0 -1
  103. package/dist/utils/index.d.ts +0 -5
  104. package/dist/utils/index.d.ts.map +0 -1
  105. package/dist/utils/index.js +0 -27
  106. package/dist/utils/index.js.map +0 -1
  107. package/dist/utils/object.d.ts +0 -2
  108. package/dist/utils/object.d.ts.map +0 -1
  109. package/dist/utils/object.js +0 -15
  110. package/dist/utils/object.js.map +0 -1
  111. package/dist/utils/path.d.ts +0 -2
  112. package/dist/utils/path.d.ts.map +0 -1
  113. package/dist/utils/path.js +0 -21
  114. package/dist/utils/path.js.map +0 -1
  115. package/dist/utils/value.d.ts +0 -2
  116. package/dist/utils/value.d.ts.map +0 -1
  117. package/dist/utils/value.js +0 -26
  118. package/dist/utils/value.js.map +0 -1
@@ -0,0 +1,812 @@
1
+ import { BaseError } from "@ebec/core";
2
+ import { BaseType, CollectionFormat, EnumType, Extension, IntersectionType, Metadata, MetadataGenerateOptions, Method, NestedObjectLiteralType, Parameter, ParameterSource, RefAliasType, RefEnumType, RefObjectType, ReferenceType, ResolverProperty, Response, UnionType, Validators, VariableType } from "@trapi/metadata";
3
+
4
+ //#region src/core/constants.d.ts
5
+ declare const Version: {
6
+ readonly V2: "v2";
7
+ readonly V3: "v3";
8
+ readonly V3_1: "v3.1";
9
+ readonly V3_2: "v3.2";
10
+ };
11
+ type Version = typeof Version[keyof typeof Version];
12
+ declare const DocumentFormat: {
13
+ readonly YAML: "yaml";
14
+ readonly JSON: "json";
15
+ };
16
+ type DocumentFormat = typeof DocumentFormat[keyof typeof DocumentFormat];
17
+ declare const SecurityType: {
18
+ readonly API_KEY: "apiKey";
19
+ readonly BASIC: "basic";
20
+ readonly HTTP: "http";
21
+ readonly OAUTH2: "oauth2";
22
+ };
23
+ type SecurityType = typeof SecurityType[keyof typeof SecurityType];
24
+ //#endregion
25
+ //#region src/core/types.d.ts
26
+ type ValidatorOpenApiMeta = {
27
+ kind: 'keyword';
28
+ key: string;
29
+ } | {
30
+ kind: 'format';
31
+ format: string;
32
+ } | {
33
+ kind: 'ignore';
34
+ };
35
+ declare module '@trapi/metadata' {
36
+ interface ValidatorMeta {
37
+ openApi?: ValidatorOpenApiMeta;
38
+ }
39
+ }
40
+ type DocumentFormatData = {
41
+ path: string;
42
+ name: string;
43
+ content?: string;
44
+ };
45
+ type BaseSecurity = {
46
+ description?: string;
47
+ };
48
+ type ApiKeySecurity = BaseSecurity & {
49
+ type: typeof SecurityType.API_KEY;
50
+ name: string;
51
+ in: 'query' | 'header';
52
+ };
53
+ type BasicSecurity = BaseSecurity & {
54
+ type: typeof SecurityType.HTTP;
55
+ scheme: 'basic';
56
+ };
57
+ type OAuth2Security = BaseSecurity & {
58
+ type: typeof SecurityType.OAUTH2;
59
+ flows: {
60
+ implicit?: OAuth2ImplicitFlow;
61
+ password?: OAuth2PasswordFlow;
62
+ authorizationCode?: OAuth2AuthorizationCodeFlow;
63
+ clientCredentials?: OAuth2ClientCredentialsFlow;
64
+ };
65
+ };
66
+ type Oauth2BaseFlow = {
67
+ scopes?: Record<string, string>;
68
+ refreshUrl?: string;
69
+ };
70
+ type OAuth2ImplicitFlow = Oauth2BaseFlow & {
71
+ authorizationUrl: string;
72
+ };
73
+ type OAuth2PasswordFlow = Oauth2BaseFlow & {
74
+ tokenUrl: string;
75
+ };
76
+ type OAuth2AuthorizationCodeFlow = Oauth2BaseFlow & {
77
+ authorizationUrl: string;
78
+ tokenUrl: string;
79
+ };
80
+ type OAuth2ClientCredentialsFlow = Oauth2BaseFlow & {
81
+ tokenUrl: string;
82
+ };
83
+ type SecurityDefinition = ApiKeySecurity | BasicSecurity | OAuth2Security;
84
+ type SecurityDefinitions = {
85
+ [key: string]: SecurityDefinition;
86
+ };
87
+ //#endregion
88
+ //#region src/core/config/types.d.ts
89
+ type ServerOption = {
90
+ url: string;
91
+ description?: string;
92
+ };
93
+ type SpecGeneratorOptions = {
94
+ /**
95
+ * API host, e.g. localhost:3000 or https://myapi.com
96
+ */
97
+ servers?: ServerOption[];
98
+ /**
99
+ * API version number; defaults to npm package version
100
+ */
101
+ version?: string;
102
+ /**
103
+ * API name; defaults to npm package name
104
+ */
105
+ name?: string;
106
+ /**
107
+ * 'API description; defaults to npm package description
108
+ */
109
+ description?: string;
110
+ /**
111
+ * API license; defaults to npm package license
112
+ */
113
+ license?: string;
114
+ /**
115
+ * Extend generated swagger spec with this object
116
+ * Note that generated properties will always take precedence over what get specified here
117
+ */
118
+ specificationExtra?: Record<string, any>;
119
+ /**
120
+ * Security Definitions Object
121
+ * A declaration of the security schemes available to be used in the
122
+ * specification. This does not enforce the security schemes on the operations
123
+ * and only serves to provide the relevant details for each scheme.
124
+ */
125
+ securityDefinitions?: SecurityDefinitions;
126
+ /**
127
+ * Default consumes property for the entire API
128
+ */
129
+ consumes?: string[];
130
+ /**
131
+ * Default produces property for the entire API
132
+ */
133
+ produces?: string[];
134
+ /**
135
+ * Default collectionFormat property for query parameters of array type.
136
+ * Possible values are `csv`, `ssv`, `tsv`, `pipes`, `multi`. If not specified, Swagger defaults to `csv`.
137
+ */
138
+ collectionFormat?: `${CollectionFormat}`;
139
+ };
140
+ type SpecGeneratorOptionsInput = Omit<Partial<SpecGeneratorOptions>, 'servers'> & {
141
+ servers?: string | string[] | ServerOption | ServerOption[];
142
+ };
143
+ type SwaggerSaveOptions = {
144
+ /**
145
+ * Working directory the output file is written to. Relative paths are resolved against it.
146
+ *
147
+ * default: process.cwd()
148
+ */
149
+ cwd?: string;
150
+ /**
151
+ * File format to emit.
152
+ *
153
+ * default: DocumentFormat.JSON
154
+ */
155
+ format?: `${DocumentFormat}`;
156
+ /**
157
+ * File name, with or without extension. Any `.json` / `.yaml` suffix is stripped
158
+ * and replaced to match `format`.
159
+ *
160
+ * default: 'swagger'
161
+ */
162
+ name?: string;
163
+ };
164
+ type SwaggerGenerateData = {
165
+ /**
166
+ * API name; defaults to npm package name.
167
+ */
168
+ name?: string;
169
+ /**
170
+ * API version; defaults to npm package version.
171
+ */
172
+ version?: string;
173
+ /**
174
+ * API description; defaults to npm package description.
175
+ */
176
+ description?: string;
177
+ /**
178
+ * API license; defaults to npm package license.
179
+ */
180
+ license?: string;
181
+ /**
182
+ * API servers.
183
+ */
184
+ servers?: string | string[] | ServerOption | ServerOption[];
185
+ /**
186
+ * Security scheme definitions.
187
+ */
188
+ securityDefinitions?: SecurityDefinitions;
189
+ /**
190
+ * Default consumes content types.
191
+ */
192
+ consumes?: string[];
193
+ /**
194
+ * Default produces content types.
195
+ */
196
+ produces?: string[];
197
+ /**
198
+ * Default collection format for array query parameters.
199
+ */
200
+ collectionFormat?: `${CollectionFormat}`;
201
+ /**
202
+ * Extra properties to merge into the generated spec.
203
+ */
204
+ extra?: Record<string, any>;
205
+ };
206
+ type SwaggerGenerateOptions = {
207
+ /**
208
+ * Swagger/OpenAPI spec version to generate (e.g. 'v2', 'v3').
209
+ */
210
+ version: `${Version}`;
211
+ /**
212
+ * Pre-built metadata or options to generate metadata from source.
213
+ */
214
+ metadata: MetadataGenerateOptions | Metadata;
215
+ /**
216
+ * Document content (info, servers, security, etc.).
217
+ */
218
+ data?: SwaggerGenerateData;
219
+ };
220
+ //#endregion
221
+ //#region src/core/config/utils.d.ts
222
+ declare function buildSpecGeneratorOptions(input: SpecGeneratorOptionsInput): SpecGeneratorOptions;
223
+ //#endregion
224
+ //#region src/core/error/codes.d.ts
225
+ declare const SwaggerErrorCode: {
226
+ readonly SPEC_NOT_BUILT: "SWAGGER_SPEC_NOT_BUILT";
227
+ readonly ENUM_UNSUPPORTED_TYPE: "SWAGGER_ENUM_UNSUPPORTED_TYPE";
228
+ readonly BODY_PARAMETER_DUPLICATE: "SWAGGER_BODY_PARAMETER_DUPLICATE";
229
+ readonly BODY_FORM_CONFLICT: "SWAGGER_BODY_FORM_CONFLICT";
230
+ readonly PARAMETER_SOURCE_UNSUPPORTED: "SWAGGER_PARAMETER_SOURCE_UNSUPPORTED";
231
+ };
232
+ //#endregion
233
+ //#region src/core/error/module.d.ts
234
+ declare class SwaggerError extends BaseError {}
235
+ //#endregion
236
+ //#region src/core/schema/constants.d.ts
237
+ declare const TransferProtocol: {
238
+ readonly HTTP: "http";
239
+ readonly HTTPS: "https";
240
+ readonly WS: "ws";
241
+ readonly WSS: "wss";
242
+ };
243
+ type TransferProtocol = typeof TransferProtocol[keyof typeof TransferProtocol];
244
+ declare const DataFormatName: {
245
+ readonly INT_32: "int32";
246
+ readonly INT_64: "int64";
247
+ readonly FLOAT: "float";
248
+ readonly DOUBLE: "double";
249
+ readonly BYTE: "byte";
250
+ readonly BINARY: "binary";
251
+ readonly DATE: "date";
252
+ readonly DATE_TIME: "date-time";
253
+ readonly PASSWORD: "password";
254
+ };
255
+ type DataFormatName = typeof DataFormatName[keyof typeof DataFormatName];
256
+ declare const DataTypeName: {
257
+ readonly VOID: "void";
258
+ readonly INTEGER: "integer";
259
+ readonly NUMBER: "number";
260
+ readonly BOOLEAN: "boolean";
261
+ readonly STRING: "string";
262
+ readonly ARRAY: "array";
263
+ readonly OBJECT: "object";
264
+ readonly FILE: "file";
265
+ };
266
+ type DataTypeName = typeof DataTypeName[keyof typeof DataTypeName];
267
+ //#endregion
268
+ //#region src/core/schema/types.d.ts
269
+ type BaseSpec = {
270
+ info: Info;
271
+ tags?: Tag[];
272
+ externalDocs?: ExternalDocs;
273
+ };
274
+ type Info = {
275
+ title: string;
276
+ version: string;
277
+ description?: string;
278
+ termsOfService?: string;
279
+ contact?: Contact;
280
+ license?: License;
281
+ };
282
+ type Contact = {
283
+ name?: string;
284
+ email?: string;
285
+ url?: string;
286
+ };
287
+ type License = {
288
+ name: string;
289
+ url?: string;
290
+ };
291
+ type ExternalDocs = {
292
+ url: string;
293
+ description?: string;
294
+ };
295
+ type Tag = {
296
+ name: string;
297
+ description?: string;
298
+ externalDocs?: ExternalDocs;
299
+ };
300
+ type BaseResponse = {
301
+ description: string;
302
+ };
303
+ type BaseOperation<P, R> = {
304
+ responses: {
305
+ [name: string]: R;
306
+ };
307
+ summary?: string;
308
+ description?: string;
309
+ externalDocs?: ExternalDocs;
310
+ operationId?: string;
311
+ consumes?: string[];
312
+ parameters?: P[];
313
+ schemes?: string[];
314
+ deprecated?: boolean;
315
+ security?: Record<string, string[]>[];
316
+ tags?: string[];
317
+ };
318
+ type Example = {
319
+ value: unknown | unknown[];
320
+ summary?: string;
321
+ description?: string;
322
+ };
323
+ type BaseSchema<T> = {
324
+ type?: `${DataTypeName}` | Array<`${DataTypeName}` | 'null'>;
325
+ format?: `${DataFormatName}`;
326
+ title?: string;
327
+ description?: string;
328
+ default?: string | boolean | number | any;
329
+ multipleOf?: number;
330
+ maximum?: number;
331
+ exclusiveMaximum?: number;
332
+ minimum?: number;
333
+ exclusiveMinimum?: number;
334
+ maxLength?: number;
335
+ minLength?: number;
336
+ pattern?: string;
337
+ maxItems?: number;
338
+ minItems?: number;
339
+ uniqueItems?: boolean;
340
+ maxProperties?: number;
341
+ minProperties?: number;
342
+ enum?: Array<string | number | boolean>;
343
+ 'x-enum-varnames'?: string[];
344
+ items?: T | BaseSchema<T> | any;
345
+ additionalProperties?: boolean | {
346
+ [ref: string]: string;
347
+ } | T;
348
+ properties?: {
349
+ [propertyName: string]: T;
350
+ };
351
+ discriminator?: string;
352
+ readOnly?: boolean;
353
+ xml?: XML;
354
+ externalDocs?: ExternalDocs;
355
+ example?: {
356
+ [exampleName: string]: Example;
357
+ } | unknown;
358
+ required?: string[];
359
+ $ref?: string;
360
+ };
361
+ type XML = {
362
+ type?: string;
363
+ namespace?: string;
364
+ prefix?: string;
365
+ attribute?: string;
366
+ wrapped?: boolean;
367
+ };
368
+ type BaseParameter = {
369
+ name: string;
370
+ in: `${ParameterSourceV2}`;
371
+ required?: boolean;
372
+ description?: string;
373
+ };
374
+ type BodyParameter = BaseParameter & {
375
+ in: typeof ParameterSourceV2.BODY;
376
+ };
377
+ type QueryParameter = BaseParameter & {
378
+ in: typeof ParameterSourceV2.QUERY;
379
+ allowEmptyValue?: boolean;
380
+ collectionFormat?: `${CollectionFormat}`;
381
+ };
382
+ type PathParameter = BaseParameter & {
383
+ in: typeof ParameterSourceV2.PATH;
384
+ };
385
+ type HeaderParameter = BaseParameter & {
386
+ in: typeof ParameterSourceV2.HEADER;
387
+ };
388
+ type FormDataParameter = BaseParameter & {
389
+ in: typeof ParameterSourceV2.FORM_DATA;
390
+ collectionFormat?: `${CollectionFormat}`;
391
+ };
392
+ type Path<Operation, Parameter> = {
393
+ $ref?: string;
394
+ get?: Operation;
395
+ put?: Operation;
396
+ post?: Operation;
397
+ delete?: Operation;
398
+ options?: Operation;
399
+ head?: Operation;
400
+ patch?: Operation;
401
+ parameters?: Parameter[];
402
+ };
403
+ //#endregion
404
+ //#region src/core/schema/v2/types.d.ts
405
+ type SpecV2 = BaseSpec & {
406
+ swagger: '2.0';
407
+ host?: string;
408
+ basePath?: string;
409
+ schemes?: string[];
410
+ consumes?: string[];
411
+ produces?: string[];
412
+ paths: {
413
+ [pathName: string]: Path<OperationV2, ResponseV2>;
414
+ };
415
+ definitions?: {
416
+ [definitionsName: string]: SchemaV2;
417
+ };
418
+ parameters?: {
419
+ [parameterName: string]: ParameterV2;
420
+ };
421
+ responses?: {
422
+ [responseName: string]: ResponseV2;
423
+ };
424
+ security?: SecurityV2[];
425
+ securityDefinitions?: {
426
+ [name: string]: SecurityV2;
427
+ };
428
+ };
429
+ type PatternField = `x-${string}`;
430
+ type BaseParameterV2 = {
431
+ type?: `${DataTypeName}`;
432
+ format?: `${DataFormatName}`;
433
+ allowEmptyValue?: boolean;
434
+ items?: Record<string, any>;
435
+ collectionFormat?: `${CollectionFormat}`;
436
+ default?: any;
437
+ maximum?: number;
438
+ exclusiveMaximum?: number;
439
+ minimum?: number;
440
+ exclusiveMinimum?: number;
441
+ maxLength?: number;
442
+ minLength?: number;
443
+ pattern?: string;
444
+ maxItems?: number;
445
+ minItems?: number;
446
+ uniqueItems?: number;
447
+ enum?: unknown[];
448
+ multipleOf?: number;
449
+ };
450
+ type BodyParameterV2 = BodyParameter & {
451
+ schema: BaseSchema<SchemaV2>;
452
+ };
453
+ type QueryParameterV2 = QueryParameter & BaseParameterV2;
454
+ type PathParameterV2 = PathParameter & BaseParameterV2;
455
+ type HeaderParameterV2 = HeaderParameter & BaseParameterV2;
456
+ type FormDataParameterV2 = FormDataParameter & BaseParameterV2;
457
+ type ParameterV2 = (BodyParameterV2 | QueryParameterV2 | PathParameterV2 | HeaderParameterV2 | FormDataParameterV2) & {
458
+ [key: PatternField]: any | undefined;
459
+ };
460
+ type OperationV2 = BaseOperation<ParameterV2, ResponseV2> & {
461
+ consumes?: string[];
462
+ produces?: string[];
463
+ schemes?: `${TransferProtocol}`[];
464
+ };
465
+ type ResponseV2 = BaseResponse & {
466
+ schema?: SchemaV2;
467
+ headers?: {
468
+ [headerName: string]: HeaderV2;
469
+ };
470
+ examples?: {
471
+ [exampleName: string]: unknown;
472
+ };
473
+ };
474
+ type HeaderV2 = {
475
+ type: 'string' | 'number' | 'integer' | 'boolean' | 'array';
476
+ };
477
+ interface SchemaV2 extends BaseSchema<SchemaV2> {
478
+ ['x-nullable']?: boolean;
479
+ ['x-deprecated']?: boolean;
480
+ }
481
+ type BasicSecurityV2 = BaseSecurity & {
482
+ type: typeof SecurityType.BASIC;
483
+ };
484
+ type BaseOAuthSecurityV2 = BaseSecurity & {
485
+ type: typeof SecurityType.OAUTH2;
486
+ };
487
+ type OAuth2ImplicitSecurityV2 = BaseOAuthSecurityV2 & {
488
+ flow: 'implicit';
489
+ authorizationUrl: string;
490
+ scopes?: Record<string, string>;
491
+ };
492
+ type OAuth2PasswordSecurityV2 = BaseOAuthSecurityV2 & {
493
+ flow: 'password';
494
+ tokenUrl: string;
495
+ scopes?: Record<string, string>;
496
+ };
497
+ type OAuth2ApplicationSecurityV2 = BaseOAuthSecurityV2 & {
498
+ flow: 'application';
499
+ tokenUrl: string;
500
+ scopes?: Record<string, string>;
501
+ };
502
+ type OAuth2AccessCodeSecurityV2 = BaseOAuthSecurityV2 & {
503
+ flow: 'accessCode';
504
+ tokenUrl: string;
505
+ authorizationUrl: string;
506
+ scopes?: Record<string, string>;
507
+ };
508
+ type OAuth2SecurityV2 = OAuth2AccessCodeSecurityV2 | OAuth2ApplicationSecurityV2 | OAuth2ImplicitSecurityV2 | OAuth2PasswordSecurityV2;
509
+ type SecurityV2 = BasicSecurityV2 | OAuth2SecurityV2 | ApiKeySecurity;
510
+ //#endregion
511
+ //#region src/core/schema/v2/constants.d.ts
512
+ declare const ParameterSourceV2: {
513
+ readonly BODY: "body";
514
+ readonly FORM_DATA: "formData";
515
+ readonly HEADER: "header";
516
+ readonly PATH: "path";
517
+ readonly QUERY: "query";
518
+ };
519
+ type ParameterSourceV2 = typeof ParameterSourceV2[keyof typeof ParameterSourceV2];
520
+ //#endregion
521
+ //#region src/core/schema/v3/constants.d.ts
522
+ declare const ParameterSourceV3: {
523
+ readonly COOKIE: "cookie";
524
+ readonly HEADER: "header";
525
+ readonly PATH: "path";
526
+ readonly QUERY: "query";
527
+ };
528
+ type ParameterSourceV3 = typeof ParameterSourceV3[keyof typeof ParameterSourceV3];
529
+ //#endregion
530
+ //#region src/core/schema/v3/types.d.ts
531
+ type SpecV3 = BaseSpec & {
532
+ openapi: string;
533
+ servers: ServerV3[];
534
+ components: ComponentsV3;
535
+ paths: PathsV3;
536
+ };
537
+ type ServerV3 = {
538
+ url: string;
539
+ description?: string;
540
+ variables?: Record<string, VariableV3>;
541
+ };
542
+ type VariableV3 = {
543
+ enum?: string[];
544
+ description?: string;
545
+ default: string;
546
+ };
547
+ type ComponentsV3 = {
548
+ callbacks?: {
549
+ [name: string]: any;
550
+ };
551
+ examples?: {
552
+ [name: string]: Example | string;
553
+ };
554
+ headers?: {
555
+ [name: string]: any;
556
+ };
557
+ links?: {
558
+ [name: string]: any;
559
+ };
560
+ parameters?: {
561
+ [name: string]: ParameterV3;
562
+ };
563
+ requestBodies?: {
564
+ [name: string]: any;
565
+ };
566
+ responses?: {
567
+ [name: string]: ResponseV3;
568
+ };
569
+ schemas?: {
570
+ [name: string]: SchemaV3;
571
+ };
572
+ securitySchemes?: {
573
+ [name: string]: SecurityV3;
574
+ };
575
+ };
576
+ type PathsV3 = {
577
+ [key: string]: Path<OperationV3, ParameterV3>;
578
+ };
579
+ type BaseParameterV3 = {
580
+ /**
581
+ * Default: false
582
+ */
583
+ deprecated?: boolean;
584
+ /**
585
+ * Default: false
586
+ */
587
+ allowEmptyValue?: boolean;
588
+ style?: string;
589
+ explode?: boolean;
590
+ allowReserved?: boolean;
591
+ schema?: SchemaV3;
592
+ example?: unknown;
593
+ examples?: Record<string, Example | string>;
594
+ content?: Record<string, any>;
595
+ };
596
+ type BodyParameterV3 = BodyParameter & BaseParameterV3;
597
+ type CookieParameterV3 = BaseParameterV3 & {
598
+ in: typeof ParameterSourceV3.COOKIE;
599
+ };
600
+ type QueryParameterV3 = QueryParameter & BaseParameterV3;
601
+ type PathParameterV3 = PathParameter & BaseParameterV3;
602
+ type HeaderParameterV3 = HeaderParameter & BaseParameterV3;
603
+ type FormDataParameterV3 = FormDataParameter & BaseParameterV3;
604
+ type PatternFieldV3 = `x-${string}`;
605
+ type ParameterV3 = (BodyParameterV3 | CookieParameterV3 | QueryParameterV3 | PathParameterV3 | HeaderParameterV3 | FormDataParameterV3) & {
606
+ [key: PatternFieldV3]: unknown;
607
+ };
608
+ type OperationV3 = BaseOperation<ParameterV3, ResponseV3> & {
609
+ requestBody?: RequestBodyV3;
610
+ [key: string]: unknown;
611
+ };
612
+ type ResponseV3 = BaseResponse & {
613
+ content?: Record<string, {
614
+ schema: SchemaV3;
615
+ examples?: Record<string, Example>;
616
+ }>;
617
+ headers?: {
618
+ [name: string]: HeaderV3;
619
+ };
620
+ };
621
+ type HeaderV3 = Omit<BaseSchema<SchemaV3>, 'required'> & {
622
+ required?: boolean;
623
+ description?: string;
624
+ example?: unknown;
625
+ examples?: Record<string, Example | string>;
626
+ schema: SchemaV3;
627
+ type?: `${DataTypeName}`;
628
+ format?: `${DataFormatName}`;
629
+ };
630
+ type RequestBodyV3 = {
631
+ content: {
632
+ [name: string]: MediaTypeV3;
633
+ };
634
+ description?: string;
635
+ required?: boolean;
636
+ };
637
+ type MediaTypeV3 = {
638
+ schema?: SchemaV3;
639
+ example?: Example;
640
+ examples?: Record<string, Example | string>;
641
+ encoding?: {
642
+ [name: string]: any;
643
+ };
644
+ };
645
+ interface SchemaV3 extends Omit<BaseSchema<SchemaV3>, 'discriminator'> {
646
+ discriminator?: string | {
647
+ propertyName: string;
648
+ mapping?: Record<string, string>;
649
+ };
650
+ nullable?: boolean;
651
+ anyOf?: SchemaV3[];
652
+ allOf?: SchemaV3[];
653
+ oneOf?: SchemaV3[];
654
+ deprecated?: boolean;
655
+ }
656
+ type BasicSecurityV3 = BaseSecurity & {
657
+ type: typeof SecurityType.HTTP;
658
+ scheme: 'basic';
659
+ };
660
+ type OAuth2SecurityV3 = BaseSecurity & {
661
+ type: typeof SecurityType.OAUTH2;
662
+ flows: {
663
+ implicit?: OAuth2ImplicitFlowV3;
664
+ password?: OAuth2PasswordFlowV3;
665
+ authorizationCode?: OAuth2AuthorizationCodeFlowV3;
666
+ clientCredentials?: OAuth2ClientCredentialsFlowV3;
667
+ };
668
+ };
669
+ type Oauth2BaseFlowV3 = {
670
+ scopes?: Record<string, string>;
671
+ refreshUrl?: string;
672
+ };
673
+ type OAuth2ImplicitFlowV3 = Oauth2BaseFlowV3 & {
674
+ authorizationUrl: string;
675
+ };
676
+ type OAuth2PasswordFlowV3 = Oauth2BaseFlowV3 & {
677
+ tokenUrl: string;
678
+ };
679
+ type OAuth2AuthorizationCodeFlowV3 = Oauth2BaseFlowV3 & {
680
+ authorizationUrl: string;
681
+ tokenUrl: string;
682
+ };
683
+ type OAuth2ClientCredentialsFlowV3 = Oauth2BaseFlowV3 & {
684
+ tokenUrl: string;
685
+ };
686
+ type SecurityV3 = BasicSecurityV3 | OAuth2SecurityV3 | ApiKeySecurity;
687
+ //#endregion
688
+ //#region src/core/utils/character.d.ts
689
+ declare function removeDuplicateSlashes(str: string): string;
690
+ declare function removeFinalCharacter(str: string, character: string): string;
691
+ //#endregion
692
+ //#region src/core/utils/path.d.ts
693
+ declare function normalizePathParameters(str: string): string;
694
+ //#endregion
695
+ //#region src/core/utils/object.d.ts
696
+ declare function hasOwnProperty<X extends object, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
697
+ //#endregion
698
+ //#region src/core/utils/value.d.ts
699
+ declare function transformValueTo(type: 'string' | 'number' | 'integer' | 'boolean' | 'bigint', value: unknown): string | number | boolean | null;
700
+ //#endregion
701
+ //#region src/adapters/generator/abstract.d.ts
702
+ declare abstract class AbstractSpecGenerator<Spec extends SpecV2 | SpecV3, Schema extends SchemaV3 | SchemaV2> {
703
+ protected spec: Spec | undefined;
704
+ protected readonly metadata: Metadata;
705
+ protected readonly config: SpecGeneratorOptions;
706
+ constructor(metadata: Metadata, config: SpecGeneratorOptionsInput);
707
+ abstract build(): Promise<Spec>;
708
+ protected buildInfo(): Info;
709
+ protected buildTags(): ({
710
+ name: string;
711
+ } & Record<string, unknown>)[];
712
+ protected getSchemaForType(type: BaseType): Schema | BaseSchema<Schema>;
713
+ protected abstract getSchemaForIntersectionType(type: IntersectionType): Schema;
714
+ protected getSchemaForEnumType(enumType: EnumType): Schema;
715
+ protected abstract applyNullable(schema: Schema, nullable: boolean): void;
716
+ private getSchemaForPrimitiveType;
717
+ private getSchemaForArrayType;
718
+ private getSchemaForTupleType;
719
+ getSchemaForObjectLiteralType(objectLiteral: NestedObjectLiteralType): BaseSchema<Schema>;
720
+ protected getSchemaForReferenceType(referenceType: ReferenceType): Schema;
721
+ protected abstract getRefPrefix(): string;
722
+ protected abstract getSchemaForUnionType(type: UnionType): Schema;
723
+ protected buildSchemaForRefAlias(referenceType: RefAliasType): Schema;
724
+ protected buildSchemaForRefEnum(referenceType: RefEnumType): Schema;
725
+ protected buildSchemasForReferenceTypes(extendFn?: (output: Schema, input: ReferenceType) => void): Record<string, Schema>;
726
+ protected isUndefinedProperty(input: ResolverProperty): boolean;
727
+ protected buildProperties(properties: ResolverProperty[]): Record<string, Schema>;
728
+ protected abstract markPropertyDeprecated(schema: Schema): void;
729
+ protected shouldStripRefSiblings(): boolean;
730
+ protected assignPropertyDefaults(schema: Schema, property: ResolverProperty): void;
731
+ protected buildSchemaForRefObject(referenceType: RefObjectType): Schema;
732
+ protected abstract resolveAdditionalProperties(type: BaseType): Schema | boolean;
733
+ protected determineTypesUsedInEnum(anEnum: Array<string | number | boolean | null>): VariableType[];
734
+ protected decideEnumType(input: Array<string | number | boolean>): 'string' | 'number' | 'boolean';
735
+ protected getOperationId(name: string): string;
736
+ protected groupParameters(items: Parameter[]): Partial<Record<ParameterSource, Parameter[]>>;
737
+ protected transformExtensions(input?: Extension[]): Record<string, any>;
738
+ protected transformValidators(input?: Validators): Record<string, any>;
739
+ }
740
+ //#endregion
741
+ //#region src/adapters/generator/v2/module.d.ts
742
+ declare class V2Generator extends AbstractSpecGenerator<SpecV2, SchemaV2> {
743
+ build(): Promise<SpecV2>;
744
+ private static translateSecurityDefinitions;
745
+ protected resolveAdditionalProperties(type: BaseType): SchemaV2 | boolean;
746
+ protected markPropertyDeprecated(schema: SchemaV2): void;
747
+ private buildPaths;
748
+ private buildMethod;
749
+ private transformParameterSource;
750
+ protected buildParameter(input: Parameter): ParameterV2;
751
+ private buildMethodConsumes;
752
+ private hasFileParams;
753
+ private hasFormParams;
754
+ private supportsBodyParameters;
755
+ protected applyNullable(schema: SchemaV2, nullable: boolean): void;
756
+ protected getRefPrefix(): string;
757
+ protected getSchemaForIntersectionType(type: IntersectionType): SchemaV2;
758
+ protected getSchemaForUnionType(type: UnionType): SchemaV2;
759
+ private buildOperation;
760
+ }
761
+ //#endregion
762
+ //#region src/adapters/generator/v3/module.d.ts
763
+ declare class V3Generator extends AbstractSpecGenerator<SpecV3, SchemaV3> {
764
+ private readonly openApiVersion;
765
+ constructor(metadata: Metadata, config: SpecGeneratorOptionsInput, version?: `${Version}`);
766
+ build(): Promise<SpecV3>;
767
+ private buildComponents;
768
+ private static translateSecurityDefinitions;
769
+ private buildPaths;
770
+ private buildMethod;
771
+ private buildRequestBodyWithFormData;
772
+ private buildRequestBody;
773
+ private buildMediaType;
774
+ protected buildResponses(input: Response[]): Record<string, ResponseV3>;
775
+ protected buildOperation(controllerName: string, method: Method): OperationV3;
776
+ protected transformParameterSource(source: `${ParameterSource}`): `${ParameterSourceV3}` | undefined;
777
+ protected buildParameter(input: Parameter): ParameterV3;
778
+ private transformParameterExamples;
779
+ private buildServers;
780
+ protected resolveAdditionalProperties(type: BaseType): SchemaV3;
781
+ protected markPropertyDeprecated(schema: SchemaV3): void;
782
+ protected assignPropertyDefaults(schema: SchemaV3, property: ResolverProperty): void;
783
+ protected buildSchemaForRefEnum(referenceType: RefEnumType): SchemaV3;
784
+ private isV31OrLater;
785
+ protected shouldStripRefSiblings(): boolean;
786
+ protected getSchemaForIntersectionType(type: IntersectionType): SchemaV3;
787
+ protected applyNullable(schema: SchemaV3, nullable: boolean): void;
788
+ protected getRefPrefix(): string;
789
+ protected getSchemaForUnionType(type: UnionType): SchemaV3;
790
+ private static isObjectLikeType;
791
+ private applyDiscriminator;
792
+ private detectDiscriminator;
793
+ /**
794
+ * Resolve a union member to its refName and properties for discriminator
795
+ * detection. Accepts both refObject and refAlias members, unwrapping
796
+ * aliases to find the underlying properties while preserving the
797
+ * original refName for $ref mapping.
798
+ */
799
+ private resolveDiscriminatorMember;
800
+ }
801
+ //#endregion
802
+ //#region src/app/module.d.ts
803
+ type OutputSpec<V extends `${Version}`> = V extends typeof Version.V2 ? SpecV2 : SpecV3;
804
+ declare function generateSwagger<V extends `${Version}`>(options: Omit<SwaggerGenerateOptions, 'version'> & {
805
+ version: V;
806
+ }): Promise<OutputSpec<V>>;
807
+ //#endregion
808
+ //#region src/app/save.d.ts
809
+ declare function saveSwagger(spec: SpecV2 | SpecV3, options?: SwaggerSaveOptions): Promise<DocumentFormatData>;
810
+ //#endregion
811
+ export { AbstractSpecGenerator, ApiKeySecurity, BaseOAuthSecurityV2, BaseOperation, BaseParameter, BaseParameterV2, BaseParameterV3, BaseResponse, BaseSchema, BaseSecurity, BaseSpec, BasicSecurity, BasicSecurityV2, BasicSecurityV3, BodyParameter, BodyParameterV2, BodyParameterV3, ComponentsV3, CookieParameterV3, DataFormatName, DataTypeName, DocumentFormat, DocumentFormatData, Example, FormDataParameter, FormDataParameterV2, FormDataParameterV3, HeaderParameter, HeaderParameterV2, HeaderParameterV3, HeaderV2, HeaderV3, Info, MediaTypeV3, OAuth2AccessCodeSecurityV2, OAuth2ApplicationSecurityV2, OAuth2AuthorizationCodeFlow, OAuth2AuthorizationCodeFlowV3, OAuth2ClientCredentialsFlow, OAuth2ClientCredentialsFlowV3, OAuth2ImplicitFlow, OAuth2ImplicitFlowV3, OAuth2ImplicitSecurityV2, OAuth2PasswordFlow, OAuth2PasswordFlowV3, OAuth2PasswordSecurityV2, OAuth2Security, OAuth2SecurityV2, OAuth2SecurityV3, Oauth2BaseFlow, Oauth2BaseFlowV3, OperationV2, OperationV3, ParameterSourceV2, ParameterSourceV3, ParameterV2, ParameterV3, Path, PathParameter, PathParameterV2, PathParameterV3, PathsV3, QueryParameter, QueryParameterV2, QueryParameterV3, RequestBodyV3, ResponseV2, ResponseV3, SchemaV2, SchemaV3, SecurityDefinition, SecurityDefinitions, SecurityType, SecurityV2, SecurityV3, ServerOption, ServerV3, SpecGeneratorOptions, SpecGeneratorOptionsInput, SpecV2, SpecV3, SwaggerError, SwaggerErrorCode, SwaggerGenerateData, SwaggerGenerateOptions, SwaggerSaveOptions, TransferProtocol, V2Generator, V3Generator, ValidatorOpenApiMeta, VariableV3, Version, buildSpecGeneratorOptions, generateSwagger, hasOwnProperty, normalizePathParameters, removeDuplicateSlashes, removeFinalCharacter, saveSwagger, transformValueTo };
812
+ //# sourceMappingURL=index.d.mts.map