@typia/interface 12.0.0-dev.20260315 → 12.0.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.
@@ -1,663 +1,663 @@
1
- import { IJsonSchemaAttribute } from "../schema/IJsonSchemaAttribute";
2
- import * as tags from "../tags";
3
-
4
- /**
5
- * OpenAPI v3.0 specification types.
6
- *
7
- * `OpenApiV3` contains TypeScript type definitions for OpenAPI v3.0 documents.
8
- * Used for parsing and generating OpenAPI v3.0 specifications. For a normalized
9
- * format that unifies all OpenAPI versions, use {@link OpenApi} instead.
10
- *
11
- * Key differences from v3.1:
12
- *
13
- * - Uses `nullable: true` instead of `type: ["string", "null"]`
14
- * - No `const` keyword support
15
- * - No `prefixItems` for tuples
16
- *
17
- * @author Jeongho Nam - https://github.com/samchon
18
- */
19
- export namespace OpenApiV3 {
20
- /** HTTP method of the operation. */
21
- export type Method =
22
- | "get"
23
- | "post"
24
- | "put"
25
- | "delete"
26
- | "options"
27
- | "head"
28
- | "patch"
29
- | "trace";
30
-
31
- /* -----------------------------------------------------------
32
- DOCUMENTS
33
- ----------------------------------------------------------- */
34
- /** OpenAPI document structure. */
35
- export interface IDocument {
36
- /** OpenAPI version. */
37
- openapi: "3.0" | `3.0.${number}`;
38
-
39
- /** List of servers. */
40
- servers?: IServer[];
41
-
42
- /** API metadata. */
43
- info?: IDocument.IInfo;
44
-
45
- /** Reusable components. */
46
- components?: IComponents;
47
-
48
- /** API paths and operations. */
49
- paths?: Record<string, IPath>;
50
-
51
- /** Global security requirements. */
52
- security?: Record<string, string[]>[];
53
-
54
- /** Tag definitions. */
55
- tags?: IDocument.ITag[];
56
- }
57
- export namespace IDocument {
58
- /** API metadata. */
59
- export interface IInfo {
60
- /** API title. */
61
- title: string;
62
-
63
- /** API description. */
64
- description?: string;
65
-
66
- /** Terms of service URL. */
67
- termsOfService?: string;
68
-
69
- /** Contact information. */
70
- contact?: IContact;
71
-
72
- /** License information. */
73
- license?: ILicense;
74
-
75
- /** API version. */
76
- version: string;
77
- }
78
-
79
- /** Tag for grouping operations. */
80
- export interface ITag {
81
- /** Tag name. */
82
- name: string;
83
-
84
- /** Tag description. */
85
- description?: string;
86
- }
87
-
88
- /** Contact information. */
89
- export interface IContact {
90
- /** Contact name. */
91
- name?: string;
92
-
93
- /** Contact URL. */
94
- url?: string;
95
-
96
- /** Contact email. */
97
- email?: string & tags.Format<"email">;
98
- }
99
-
100
- /** License information. */
101
- export interface ILicense {
102
- /** License name. */
103
- name: string;
104
-
105
- /** License URL. */
106
- url?: string;
107
- }
108
- }
109
-
110
- /** Server providing the API. */
111
- export interface IServer {
112
- /** Server URL. */
113
- url: string;
114
-
115
- /** Server description. */
116
- description?: string;
117
-
118
- /** URL template variables. */
119
- variables?: Record<string, IServer.IVariable>;
120
- }
121
- export namespace IServer {
122
- /** URL template variable. */
123
- export interface IVariable {
124
- /** Default value. */
125
- default: string;
126
-
127
- /** Allowed values. */
128
- enum?: string[];
129
-
130
- /** Variable description. */
131
- description?: string;
132
- }
133
- }
134
-
135
- /* -----------------------------------------------------------
136
- PATH ITEMS
137
- ----------------------------------------------------------- */
138
- /** Path item containing operations by HTTP method. */
139
- export interface IPath extends Partial<
140
- Record<Method, IOperation | undefined>
141
- > {
142
- /** Path-level parameters. */
143
- parameters?: Array<
144
- | IOperation.IParameter
145
- | IJsonSchema.IReference<`#/components/headers/${string}`>
146
- | IJsonSchema.IReference<`#/components/parameters/${string}`>
147
- >;
148
-
149
- /** Path-level servers. */
150
- servers?: IServer[];
151
-
152
- /** Path summary. */
153
- summary?: string;
154
-
155
- /** Path description. */
156
- description?: string;
157
-
158
- /**
159
- * Non-standard HTTP method operations (extension).
160
- *
161
- * Used when downgrading from OpenAPI v3.2 to preserve
162
- * non-standard methods like `query` or custom methods.
163
- */
164
- "x-additionalOperations"?: Record<string, IOperation>;
165
- }
166
-
167
- /** API operation metadata. */
168
- export interface IOperation {
169
- /** Unique operation identifier. */
170
- operationId?: string;
171
-
172
- /** Operation parameters. */
173
- parameters?: Array<
174
- | IOperation.IParameter
175
- | IJsonSchema.IReference<`#/components/headers/${string}`>
176
- | IJsonSchema.IReference<`#/components/parameters/${string}`>
177
- >;
178
-
179
- /** Request body. */
180
- requestBody?:
181
- | IOperation.IRequestBody
182
- | IJsonSchema.IReference<`#/components/requestBodies/${string}`>;
183
-
184
- /** Response definitions by status code. */
185
- responses?: Record<
186
- string,
187
- | IOperation.IResponse
188
- | IJsonSchema.IReference<`#/components/responses/${string}`>
189
- >;
190
-
191
- /** Operation-level servers. */
192
- servers?: IServer[];
193
-
194
- /** Short summary. */
195
- summary?: string;
196
-
197
- /** Full description. */
198
- description?: string;
199
-
200
- /** Security requirements. */
201
- security?: Record<string, string[]>[];
202
-
203
- /** Operation tags. */
204
- tags?: string[];
205
-
206
- /** Whether deprecated. */
207
- deprecated?: boolean;
208
- }
209
- export namespace IOperation {
210
- /** Operation parameter. */
211
- export interface IParameter {
212
- /** Parameter name. */
213
- name?: string;
214
-
215
- /** Parameter location. */
216
- in: "path" | "query" | "header" | "cookie";
217
-
218
- /** Parameter schema. */
219
- schema: IJsonSchema;
220
-
221
- /** Whether required. */
222
- required?: boolean;
223
-
224
- /** Parameter description. */
225
- description?: string;
226
-
227
- /** Example value. */
228
- example?: any;
229
-
230
- /** Named examples. */
231
- examples?: Record<
232
- string,
233
- IExample | IJsonSchema.IReference<`#/components/examples/${string}`>
234
- >;
235
- }
236
-
237
- /** Request body. */
238
- export interface IRequestBody {
239
- /** Body description. */
240
- description?: string;
241
-
242
- /** Whether required. */
243
- required?: boolean;
244
-
245
- /** Body content by media type. */
246
- content?: Record<string, IMediaType>;
247
- }
248
-
249
- /** Response definition. */
250
- export interface IResponse {
251
- /** Response content by media type. */
252
- content?: Record<string, IMediaType>;
253
-
254
- /** Response headers. */
255
- headers?: Record<
256
- string,
257
- | Omit<IOperation.IParameter, "in">
258
- | IJsonSchema.IReference<`#/components/headers/${string}`>
259
- >;
260
-
261
- /** Response description. */
262
- description?: string;
263
- }
264
-
265
- /** Media type definition. */
266
- export interface IMediaType {
267
- /** Content schema. */
268
- schema?: IJsonSchema;
269
-
270
- /** Example value. */
271
- example?: any;
272
-
273
- /** Named examples. */
274
- examples?: Record<
275
- string,
276
- IExample | IJsonSchema.IReference<`#/components/examples/${string}`>
277
- >;
278
- }
279
- }
280
-
281
- /** Example value definition. */
282
- export interface IExample {
283
- /** Example summary. */
284
- summary?: string;
285
-
286
- /** Example description. */
287
- description?: string;
288
-
289
- /** Example value. */
290
- value?: any;
291
-
292
- /** External value URL. */
293
- externalValue?: string;
294
- }
295
-
296
- /* -----------------------------------------------------------
297
- SCHEMA DEFINITIONS
298
- ----------------------------------------------------------- */
299
- /** Reusable components storage. */
300
- export interface IComponents {
301
- /** Named schemas. */
302
- schemas?: Record<string, IJsonSchema>;
303
-
304
- /** Named responses. */
305
- responses?: Record<string, IOperation.IResponse>;
306
-
307
- /** Named parameters. */
308
- parameters?: Record<string, IOperation.IParameter>;
309
-
310
- /** Named request bodies. */
311
- requestBodies?: Record<string, IOperation.IRequestBody>;
312
-
313
- /** Named security schemes. */
314
- securitySchemes?: Record<string, ISecurityScheme>;
315
-
316
- /** Named headers. */
317
- headers?: Record<string, Omit<IOperation.IParameter, "in">>;
318
-
319
- /** Named examples. */
320
- examples?: Record<string, IExample>;
321
- }
322
-
323
- /** JSON Schema type for OpenAPI v3.0. */
324
- export type IJsonSchema =
325
- | IJsonSchema.IBoolean
326
- | IJsonSchema.IInteger
327
- | IJsonSchema.INumber
328
- | IJsonSchema.IString
329
- | IJsonSchema.IArray
330
- | IJsonSchema.IObject
331
- | IJsonSchema.IReference
332
- | IJsonSchema.IAllOf
333
- | IJsonSchema.IAnyOf
334
- | IJsonSchema.IOneOf
335
- | IJsonSchema.INullOnly
336
- | IJsonSchema.IUnknown;
337
- export namespace IJsonSchema {
338
- /** Boolean type. */
339
- export interface IBoolean
340
- extends Omit<IJsonSchemaAttribute.IBoolean, "examples">, __IAttribute {
341
- /** Whether nullable. */
342
- nullable?: boolean;
343
-
344
- /** Default value. */
345
- default?: boolean | null;
346
-
347
- /** Allowed values. */
348
- enum?: Array<boolean | null>;
349
- }
350
-
351
- /** Integer type. */
352
- export interface IInteger
353
- extends Omit<IJsonSchemaAttribute.IInteger, "examples">, __IAttribute {
354
- /** Whether nullable. */
355
- nullable?: boolean;
356
-
357
- /** Default value. */
358
- default?: (number & tags.Type<"int64">) | null;
359
-
360
- /** Allowed values. */
361
- enum?: Array<(number & tags.Type<"int64">) | null>;
362
-
363
- /** Minimum value. */
364
- minimum?: number & tags.Type<"int64">;
365
-
366
- /** Maximum value. */
367
- maximum?: number & tags.Type<"int64">;
368
-
369
- /** Exclusive minimum. */
370
- exclusiveMinimum?: number | boolean;
371
-
372
- /** Exclusive maximum. */
373
- exclusiveMaximum?: number | boolean;
374
-
375
- /** Multiple of constraint. */
376
- multipleOf?: number & tags.ExclusiveMinimum<0>;
377
- }
378
-
379
- /** Number (double) type. */
380
- export interface INumber
381
- extends Omit<IJsonSchemaAttribute.INumber, "examples">, __IAttribute {
382
- /** Whether nullable. */
383
- nullable?: boolean;
384
-
385
- /** Default value. */
386
- default?: number | null;
387
-
388
- /** Allowed values. */
389
- enum?: Array<number | null>;
390
-
391
- /** Minimum value. */
392
- minimum?: number;
393
-
394
- /** Maximum value. */
395
- maximum?: number;
396
-
397
- /** Exclusive minimum. */
398
- exclusiveMinimum?: number | boolean;
399
-
400
- /** Exclusive maximum. */
401
- exclusiveMaximum?: number | boolean;
402
-
403
- /** Multiple of constraint. */
404
- multipleOf?: number & tags.ExclusiveMinimum<0>;
405
- }
406
-
407
- /** String type. */
408
- export interface IString
409
- extends Omit<IJsonSchemaAttribute.IString, "examples">, __IAttribute {
410
- /** Whether nullable. */
411
- nullable?: boolean;
412
-
413
- /** Default value. */
414
- default?: string | null;
415
-
416
- /** Allowed values. */
417
- enum?: Array<string | null>;
418
-
419
- /** String format. */
420
- format?:
421
- | "binary"
422
- | "byte"
423
- | "password"
424
- | "regex"
425
- | "uuid"
426
- | "email"
427
- | "hostname"
428
- | "idn-email"
429
- | "idn-hostname"
430
- | "iri"
431
- | "iri-reference"
432
- | "ipv4"
433
- | "ipv6"
434
- | "uri"
435
- | "uri-reference"
436
- | "uri-template"
437
- | "url"
438
- | "date-time"
439
- | "date"
440
- | "time"
441
- | "duration"
442
- | "json-pointer"
443
- | "relative-json-pointer"
444
- | (string & {});
445
-
446
- /** Regex pattern. */
447
- pattern?: string;
448
-
449
- /** Minimum length. */
450
- minLength?: number & tags.Type<"uint64">;
451
-
452
- /** Maximum length. */
453
- maxLength?: number & tags.Type<"uint64">;
454
- }
455
-
456
- /** Array type. */
457
- export interface IArray
458
- extends Omit<IJsonSchemaAttribute.IArray, "examples">, __IAttribute {
459
- /** Whether nullable. */
460
- nullable?: boolean;
461
-
462
- /** Element type. */
463
- items: IJsonSchema;
464
-
465
- /** Whether elements must be unique. */
466
- uniqueItems?: boolean;
467
-
468
- /** Minimum items. */
469
- minItems?: number & tags.Type<"uint64">;
470
-
471
- /** Maximum items. */
472
- maxItems?: number & tags.Type<"uint64">;
473
- }
474
-
475
- /** Object type. */
476
- export interface IObject
477
- extends Omit<IJsonSchemaAttribute.IObject, "examples">, __IAttribute {
478
- /** Whether nullable. */
479
- nullable?: boolean;
480
-
481
- /** Property schemas. */
482
- properties?: Record<string, IJsonSchema>;
483
-
484
- /** Required property names. */
485
- required?: string[];
486
-
487
- /** Additional properties schema. */
488
- additionalProperties?: boolean | IJsonSchema;
489
-
490
- /** Maximum properties. */
491
- maxProperties?: number;
492
-
493
- /** Minimum properties. */
494
- minProperties?: number;
495
- }
496
-
497
- /** Reference to a named schema. */
498
- export interface IReference<Key = string> extends __IAttribute {
499
- /** Reference path. */
500
- $ref: Key;
501
- }
502
-
503
- /** All-of combination. */
504
- export interface IAllOf extends __IAttribute {
505
- /** Schemas to combine. */
506
- allOf: IJsonSchema[];
507
- }
508
-
509
- /** Any-of union. */
510
- export interface IAnyOf extends __IAttribute {
511
- /** Union member schemas. */
512
- anyOf: IJsonSchema[];
513
- }
514
-
515
- /** One-of union. */
516
- export interface IOneOf extends __IAttribute {
517
- /** Union member schemas. */
518
- oneOf: IJsonSchema[];
519
-
520
- /** Discriminator for tagged unions. */
521
- discriminator?: IOneOf.IDiscriminator;
522
- }
523
- export namespace IOneOf {
524
- /** Discriminator for tagged unions. */
525
- export interface IDiscriminator {
526
- /** Discriminator property name. */
527
- propertyName: string;
528
-
529
- /** Value to schema mapping. */
530
- mapping?: Record<string, string>;
531
- }
532
- }
533
-
534
- /** Null type. */
535
- export interface INullOnly
536
- extends Omit<IJsonSchemaAttribute.INull, "examples">, __IAttribute {
537
- /** Default value. */
538
- default?: null;
539
- }
540
-
541
- /** Unknown type. */
542
- export interface IUnknown
543
- extends Omit<IJsonSchemaAttribute.IUnknown, "examples">, __IAttribute {
544
- /** Default value. */
545
- default?: any;
546
- }
547
-
548
- /** @internal Base attribute interface. */
549
- export interface __IAttribute extends Omit<
550
- IJsonSchemaAttribute,
551
- "examples"
552
- > {
553
- /** Example values. */
554
- examples?: any[] | Record<string, any>;
555
- }
556
- }
557
-
558
- /** Security scheme types. */
559
- export type ISecurityScheme =
560
- | ISecurityScheme.IApiKey
561
- | ISecurityScheme.IHttpBasic
562
- | ISecurityScheme.IHttpBearer
563
- | ISecurityScheme.IOAuth2
564
- | ISecurityScheme.IOpenId;
565
- export namespace ISecurityScheme {
566
- /** API key authentication. */
567
- export interface IApiKey {
568
- /** Scheme type. */
569
- type: "apiKey";
570
-
571
- /** Key location. */
572
- in?: "header" | "query" | "cookie";
573
-
574
- /** Key name. */
575
- name?: string;
576
-
577
- /** Scheme description. */
578
- description?: string;
579
- }
580
-
581
- /** HTTP basic authentication. */
582
- export interface IHttpBasic {
583
- /** Scheme type. */
584
- type: "http";
585
-
586
- /** Authentication scheme. */
587
- scheme: "basic";
588
-
589
- /** Scheme description. */
590
- description?: string;
591
- }
592
-
593
- /** HTTP bearer authentication. */
594
- export interface IHttpBearer {
595
- /** Scheme type. */
596
- type: "http";
597
-
598
- /** Authentication scheme. */
599
- scheme: "bearer";
600
-
601
- /** Bearer token format hint. */
602
- bearerFormat?: string;
603
-
604
- /** Scheme description. */
605
- description?: string;
606
- }
607
-
608
- /** OAuth2 authentication. */
609
- export interface IOAuth2 {
610
- /** Scheme type. */
611
- type: "oauth2";
612
-
613
- /** OAuth2 flows. */
614
- flows: IOAuth2.IFlowSet;
615
-
616
- /** Scheme description. */
617
- description?: string;
618
- }
619
-
620
- /** OpenID Connect authentication. */
621
- export interface IOpenId {
622
- /** Scheme type. */
623
- type: "openIdConnect";
624
-
625
- /** OpenID Connect discovery URL. */
626
- openIdConnectUrl: string;
627
-
628
- /** Scheme description. */
629
- description?: string;
630
- }
631
- export namespace IOAuth2 {
632
- /** OAuth2 flow configurations. */
633
- export interface IFlowSet {
634
- /** Authorization code flow. */
635
- authorizationCode?: IFlow;
636
-
637
- /** Implicit flow. */
638
- implicit?: Omit<IFlow, "tokenUrl">;
639
-
640
- /** Password flow. */
641
- password?: Omit<IFlow, "authorizationUrl">;
642
-
643
- /** Client credentials flow. */
644
- clientCredentials?: Omit<IFlow, "authorizationUrl">;
645
- }
646
-
647
- /** OAuth2 flow configuration. */
648
- export interface IFlow {
649
- /** Authorization URL. */
650
- authorizationUrl?: string;
651
-
652
- /** Token URL. */
653
- tokenUrl?: string;
654
-
655
- /** Refresh URL. */
656
- refreshUrl?: string;
657
-
658
- /** Available scopes. */
659
- scopes?: Record<string, string>;
660
- }
661
- }
662
- }
663
- }
1
+ import { IJsonSchemaAttribute } from "../schema/IJsonSchemaAttribute";
2
+ import * as tags from "../tags";
3
+
4
+ /**
5
+ * OpenAPI v3.0 specification types.
6
+ *
7
+ * `OpenApiV3` contains TypeScript type definitions for OpenAPI v3.0 documents.
8
+ * Used for parsing and generating OpenAPI v3.0 specifications. For a normalized
9
+ * format that unifies all OpenAPI versions, use {@link OpenApi} instead.
10
+ *
11
+ * Key differences from v3.1:
12
+ *
13
+ * - Uses `nullable: true` instead of `type: ["string", "null"]`
14
+ * - No `const` keyword support
15
+ * - No `prefixItems` for tuples
16
+ *
17
+ * @author Jeongho Nam - https://github.com/samchon
18
+ */
19
+ export namespace OpenApiV3 {
20
+ /** HTTP method of the operation. */
21
+ export type Method =
22
+ | "get"
23
+ | "post"
24
+ | "put"
25
+ | "delete"
26
+ | "options"
27
+ | "head"
28
+ | "patch"
29
+ | "trace";
30
+
31
+ /* -----------------------------------------------------------
32
+ DOCUMENTS
33
+ ----------------------------------------------------------- */
34
+ /** OpenAPI document structure. */
35
+ export interface IDocument {
36
+ /** OpenAPI version. */
37
+ openapi: "3.0" | `3.0.${number}`;
38
+
39
+ /** List of servers. */
40
+ servers?: IServer[];
41
+
42
+ /** API metadata. */
43
+ info?: IDocument.IInfo;
44
+
45
+ /** Reusable components. */
46
+ components?: IComponents;
47
+
48
+ /** API paths and operations. */
49
+ paths?: Record<string, IPath>;
50
+
51
+ /** Global security requirements. */
52
+ security?: Record<string, string[]>[];
53
+
54
+ /** Tag definitions. */
55
+ tags?: IDocument.ITag[];
56
+ }
57
+ export namespace IDocument {
58
+ /** API metadata. */
59
+ export interface IInfo {
60
+ /** API title. */
61
+ title: string;
62
+
63
+ /** API description. */
64
+ description?: string;
65
+
66
+ /** Terms of service URL. */
67
+ termsOfService?: string;
68
+
69
+ /** Contact information. */
70
+ contact?: IContact;
71
+
72
+ /** License information. */
73
+ license?: ILicense;
74
+
75
+ /** API version. */
76
+ version: string;
77
+ }
78
+
79
+ /** Tag for grouping operations. */
80
+ export interface ITag {
81
+ /** Tag name. */
82
+ name: string;
83
+
84
+ /** Tag description. */
85
+ description?: string;
86
+ }
87
+
88
+ /** Contact information. */
89
+ export interface IContact {
90
+ /** Contact name. */
91
+ name?: string;
92
+
93
+ /** Contact URL. */
94
+ url?: string;
95
+
96
+ /** Contact email. */
97
+ email?: string & tags.Format<"email">;
98
+ }
99
+
100
+ /** License information. */
101
+ export interface ILicense {
102
+ /** License name. */
103
+ name: string;
104
+
105
+ /** License URL. */
106
+ url?: string;
107
+ }
108
+ }
109
+
110
+ /** Server providing the API. */
111
+ export interface IServer {
112
+ /** Server URL. */
113
+ url: string;
114
+
115
+ /** Server description. */
116
+ description?: string;
117
+
118
+ /** URL template variables. */
119
+ variables?: Record<string, IServer.IVariable>;
120
+ }
121
+ export namespace IServer {
122
+ /** URL template variable. */
123
+ export interface IVariable {
124
+ /** Default value. */
125
+ default: string;
126
+
127
+ /** Allowed values. */
128
+ enum?: string[];
129
+
130
+ /** Variable description. */
131
+ description?: string;
132
+ }
133
+ }
134
+
135
+ /* -----------------------------------------------------------
136
+ PATH ITEMS
137
+ ----------------------------------------------------------- */
138
+ /** Path item containing operations by HTTP method. */
139
+ export interface IPath extends Partial<
140
+ Record<Method, IOperation | undefined>
141
+ > {
142
+ /** Path-level parameters. */
143
+ parameters?: Array<
144
+ | IOperation.IParameter
145
+ | IJsonSchema.IReference<`#/components/headers/${string}`>
146
+ | IJsonSchema.IReference<`#/components/parameters/${string}`>
147
+ >;
148
+
149
+ /** Path-level servers. */
150
+ servers?: IServer[];
151
+
152
+ /** Path summary. */
153
+ summary?: string;
154
+
155
+ /** Path description. */
156
+ description?: string;
157
+
158
+ /**
159
+ * Non-standard HTTP method operations (extension).
160
+ *
161
+ * Used when downgrading from OpenAPI v3.2 to preserve
162
+ * non-standard methods like `query` or custom methods.
163
+ */
164
+ "x-additionalOperations"?: Record<string, IOperation>;
165
+ }
166
+
167
+ /** API operation metadata. */
168
+ export interface IOperation {
169
+ /** Unique operation identifier. */
170
+ operationId?: string;
171
+
172
+ /** Operation parameters. */
173
+ parameters?: Array<
174
+ | IOperation.IParameter
175
+ | IJsonSchema.IReference<`#/components/headers/${string}`>
176
+ | IJsonSchema.IReference<`#/components/parameters/${string}`>
177
+ >;
178
+
179
+ /** Request body. */
180
+ requestBody?:
181
+ | IOperation.IRequestBody
182
+ | IJsonSchema.IReference<`#/components/requestBodies/${string}`>;
183
+
184
+ /** Response definitions by status code. */
185
+ responses?: Record<
186
+ string,
187
+ | IOperation.IResponse
188
+ | IJsonSchema.IReference<`#/components/responses/${string}`>
189
+ >;
190
+
191
+ /** Operation-level servers. */
192
+ servers?: IServer[];
193
+
194
+ /** Short summary. */
195
+ summary?: string;
196
+
197
+ /** Full description. */
198
+ description?: string;
199
+
200
+ /** Security requirements. */
201
+ security?: Record<string, string[]>[];
202
+
203
+ /** Operation tags. */
204
+ tags?: string[];
205
+
206
+ /** Whether deprecated. */
207
+ deprecated?: boolean;
208
+ }
209
+ export namespace IOperation {
210
+ /** Operation parameter. */
211
+ export interface IParameter {
212
+ /** Parameter name. */
213
+ name?: string;
214
+
215
+ /** Parameter location. */
216
+ in: "path" | "query" | "header" | "cookie";
217
+
218
+ /** Parameter schema. */
219
+ schema: IJsonSchema;
220
+
221
+ /** Whether required. */
222
+ required?: boolean;
223
+
224
+ /** Parameter description. */
225
+ description?: string;
226
+
227
+ /** Example value. */
228
+ example?: any;
229
+
230
+ /** Named examples. */
231
+ examples?: Record<
232
+ string,
233
+ IExample | IJsonSchema.IReference<`#/components/examples/${string}`>
234
+ >;
235
+ }
236
+
237
+ /** Request body. */
238
+ export interface IRequestBody {
239
+ /** Body description. */
240
+ description?: string;
241
+
242
+ /** Whether required. */
243
+ required?: boolean;
244
+
245
+ /** Body content by media type. */
246
+ content?: Record<string, IMediaType>;
247
+ }
248
+
249
+ /** Response definition. */
250
+ export interface IResponse {
251
+ /** Response content by media type. */
252
+ content?: Record<string, IMediaType>;
253
+
254
+ /** Response headers. */
255
+ headers?: Record<
256
+ string,
257
+ | Omit<IOperation.IParameter, "in">
258
+ | IJsonSchema.IReference<`#/components/headers/${string}`>
259
+ >;
260
+
261
+ /** Response description. */
262
+ description?: string;
263
+ }
264
+
265
+ /** Media type definition. */
266
+ export interface IMediaType {
267
+ /** Content schema. */
268
+ schema?: IJsonSchema;
269
+
270
+ /** Example value. */
271
+ example?: any;
272
+
273
+ /** Named examples. */
274
+ examples?: Record<
275
+ string,
276
+ IExample | IJsonSchema.IReference<`#/components/examples/${string}`>
277
+ >;
278
+ }
279
+ }
280
+
281
+ /** Example value definition. */
282
+ export interface IExample {
283
+ /** Example summary. */
284
+ summary?: string;
285
+
286
+ /** Example description. */
287
+ description?: string;
288
+
289
+ /** Example value. */
290
+ value?: any;
291
+
292
+ /** External value URL. */
293
+ externalValue?: string;
294
+ }
295
+
296
+ /* -----------------------------------------------------------
297
+ SCHEMA DEFINITIONS
298
+ ----------------------------------------------------------- */
299
+ /** Reusable components storage. */
300
+ export interface IComponents {
301
+ /** Named schemas. */
302
+ schemas?: Record<string, IJsonSchema>;
303
+
304
+ /** Named responses. */
305
+ responses?: Record<string, IOperation.IResponse>;
306
+
307
+ /** Named parameters. */
308
+ parameters?: Record<string, IOperation.IParameter>;
309
+
310
+ /** Named request bodies. */
311
+ requestBodies?: Record<string, IOperation.IRequestBody>;
312
+
313
+ /** Named security schemes. */
314
+ securitySchemes?: Record<string, ISecurityScheme>;
315
+
316
+ /** Named headers. */
317
+ headers?: Record<string, Omit<IOperation.IParameter, "in">>;
318
+
319
+ /** Named examples. */
320
+ examples?: Record<string, IExample>;
321
+ }
322
+
323
+ /** JSON Schema type for OpenAPI v3.0. */
324
+ export type IJsonSchema =
325
+ | IJsonSchema.IBoolean
326
+ | IJsonSchema.IInteger
327
+ | IJsonSchema.INumber
328
+ | IJsonSchema.IString
329
+ | IJsonSchema.IArray
330
+ | IJsonSchema.IObject
331
+ | IJsonSchema.IReference
332
+ | IJsonSchema.IAllOf
333
+ | IJsonSchema.IAnyOf
334
+ | IJsonSchema.IOneOf
335
+ | IJsonSchema.INullOnly
336
+ | IJsonSchema.IUnknown;
337
+ export namespace IJsonSchema {
338
+ /** Boolean type. */
339
+ export interface IBoolean
340
+ extends Omit<IJsonSchemaAttribute.IBoolean, "examples">, __IAttribute {
341
+ /** Whether nullable. */
342
+ nullable?: boolean;
343
+
344
+ /** Default value. */
345
+ default?: boolean | null;
346
+
347
+ /** Allowed values. */
348
+ enum?: Array<boolean | null>;
349
+ }
350
+
351
+ /** Integer type. */
352
+ export interface IInteger
353
+ extends Omit<IJsonSchemaAttribute.IInteger, "examples">, __IAttribute {
354
+ /** Whether nullable. */
355
+ nullable?: boolean;
356
+
357
+ /** Default value. */
358
+ default?: (number & tags.Type<"int64">) | null;
359
+
360
+ /** Allowed values. */
361
+ enum?: Array<(number & tags.Type<"int64">) | null>;
362
+
363
+ /** Minimum value. */
364
+ minimum?: number & tags.Type<"int64">;
365
+
366
+ /** Maximum value. */
367
+ maximum?: number & tags.Type<"int64">;
368
+
369
+ /** Exclusive minimum. */
370
+ exclusiveMinimum?: number | boolean;
371
+
372
+ /** Exclusive maximum. */
373
+ exclusiveMaximum?: number | boolean;
374
+
375
+ /** Multiple of constraint. */
376
+ multipleOf?: number & tags.ExclusiveMinimum<0>;
377
+ }
378
+
379
+ /** Number (double) type. */
380
+ export interface INumber
381
+ extends Omit<IJsonSchemaAttribute.INumber, "examples">, __IAttribute {
382
+ /** Whether nullable. */
383
+ nullable?: boolean;
384
+
385
+ /** Default value. */
386
+ default?: number | null;
387
+
388
+ /** Allowed values. */
389
+ enum?: Array<number | null>;
390
+
391
+ /** Minimum value. */
392
+ minimum?: number;
393
+
394
+ /** Maximum value. */
395
+ maximum?: number;
396
+
397
+ /** Exclusive minimum. */
398
+ exclusiveMinimum?: number | boolean;
399
+
400
+ /** Exclusive maximum. */
401
+ exclusiveMaximum?: number | boolean;
402
+
403
+ /** Multiple of constraint. */
404
+ multipleOf?: number & tags.ExclusiveMinimum<0>;
405
+ }
406
+
407
+ /** String type. */
408
+ export interface IString
409
+ extends Omit<IJsonSchemaAttribute.IString, "examples">, __IAttribute {
410
+ /** Whether nullable. */
411
+ nullable?: boolean;
412
+
413
+ /** Default value. */
414
+ default?: string | null;
415
+
416
+ /** Allowed values. */
417
+ enum?: Array<string | null>;
418
+
419
+ /** String format. */
420
+ format?:
421
+ | "binary"
422
+ | "byte"
423
+ | "password"
424
+ | "regex"
425
+ | "uuid"
426
+ | "email"
427
+ | "hostname"
428
+ | "idn-email"
429
+ | "idn-hostname"
430
+ | "iri"
431
+ | "iri-reference"
432
+ | "ipv4"
433
+ | "ipv6"
434
+ | "uri"
435
+ | "uri-reference"
436
+ | "uri-template"
437
+ | "url"
438
+ | "date-time"
439
+ | "date"
440
+ | "time"
441
+ | "duration"
442
+ | "json-pointer"
443
+ | "relative-json-pointer"
444
+ | (string & {});
445
+
446
+ /** Regex pattern. */
447
+ pattern?: string;
448
+
449
+ /** Minimum length. */
450
+ minLength?: number & tags.Type<"uint64">;
451
+
452
+ /** Maximum length. */
453
+ maxLength?: number & tags.Type<"uint64">;
454
+ }
455
+
456
+ /** Array type. */
457
+ export interface IArray
458
+ extends Omit<IJsonSchemaAttribute.IArray, "examples">, __IAttribute {
459
+ /** Whether nullable. */
460
+ nullable?: boolean;
461
+
462
+ /** Element type. */
463
+ items: IJsonSchema;
464
+
465
+ /** Whether elements must be unique. */
466
+ uniqueItems?: boolean;
467
+
468
+ /** Minimum items. */
469
+ minItems?: number & tags.Type<"uint64">;
470
+
471
+ /** Maximum items. */
472
+ maxItems?: number & tags.Type<"uint64">;
473
+ }
474
+
475
+ /** Object type. */
476
+ export interface IObject
477
+ extends Omit<IJsonSchemaAttribute.IObject, "examples">, __IAttribute {
478
+ /** Whether nullable. */
479
+ nullable?: boolean;
480
+
481
+ /** Property schemas. */
482
+ properties?: Record<string, IJsonSchema>;
483
+
484
+ /** Required property names. */
485
+ required?: string[];
486
+
487
+ /** Additional properties schema. */
488
+ additionalProperties?: boolean | IJsonSchema;
489
+
490
+ /** Maximum properties. */
491
+ maxProperties?: number;
492
+
493
+ /** Minimum properties. */
494
+ minProperties?: number;
495
+ }
496
+
497
+ /** Reference to a named schema. */
498
+ export interface IReference<Key = string> extends __IAttribute {
499
+ /** Reference path. */
500
+ $ref: Key;
501
+ }
502
+
503
+ /** All-of combination. */
504
+ export interface IAllOf extends __IAttribute {
505
+ /** Schemas to combine. */
506
+ allOf: IJsonSchema[];
507
+ }
508
+
509
+ /** Any-of union. */
510
+ export interface IAnyOf extends __IAttribute {
511
+ /** Union member schemas. */
512
+ anyOf: IJsonSchema[];
513
+ }
514
+
515
+ /** One-of union. */
516
+ export interface IOneOf extends __IAttribute {
517
+ /** Union member schemas. */
518
+ oneOf: IJsonSchema[];
519
+
520
+ /** Discriminator for tagged unions. */
521
+ discriminator?: IOneOf.IDiscriminator;
522
+ }
523
+ export namespace IOneOf {
524
+ /** Discriminator for tagged unions. */
525
+ export interface IDiscriminator {
526
+ /** Discriminator property name. */
527
+ propertyName: string;
528
+
529
+ /** Value to schema mapping. */
530
+ mapping?: Record<string, string>;
531
+ }
532
+ }
533
+
534
+ /** Null type. */
535
+ export interface INullOnly
536
+ extends Omit<IJsonSchemaAttribute.INull, "examples">, __IAttribute {
537
+ /** Default value. */
538
+ default?: null;
539
+ }
540
+
541
+ /** Unknown type. */
542
+ export interface IUnknown
543
+ extends Omit<IJsonSchemaAttribute.IUnknown, "examples">, __IAttribute {
544
+ /** Default value. */
545
+ default?: any;
546
+ }
547
+
548
+ /** @internal Base attribute interface. */
549
+ export interface __IAttribute extends Omit<
550
+ IJsonSchemaAttribute,
551
+ "examples"
552
+ > {
553
+ /** Example values. */
554
+ examples?: any[] | Record<string, any>;
555
+ }
556
+ }
557
+
558
+ /** Security scheme types. */
559
+ export type ISecurityScheme =
560
+ | ISecurityScheme.IApiKey
561
+ | ISecurityScheme.IHttpBasic
562
+ | ISecurityScheme.IHttpBearer
563
+ | ISecurityScheme.IOAuth2
564
+ | ISecurityScheme.IOpenId;
565
+ export namespace ISecurityScheme {
566
+ /** API key authentication. */
567
+ export interface IApiKey {
568
+ /** Scheme type. */
569
+ type: "apiKey";
570
+
571
+ /** Key location. */
572
+ in?: "header" | "query" | "cookie";
573
+
574
+ /** Key name. */
575
+ name?: string;
576
+
577
+ /** Scheme description. */
578
+ description?: string;
579
+ }
580
+
581
+ /** HTTP basic authentication. */
582
+ export interface IHttpBasic {
583
+ /** Scheme type. */
584
+ type: "http";
585
+
586
+ /** Authentication scheme. */
587
+ scheme: "basic";
588
+
589
+ /** Scheme description. */
590
+ description?: string;
591
+ }
592
+
593
+ /** HTTP bearer authentication. */
594
+ export interface IHttpBearer {
595
+ /** Scheme type. */
596
+ type: "http";
597
+
598
+ /** Authentication scheme. */
599
+ scheme: "bearer";
600
+
601
+ /** Bearer token format hint. */
602
+ bearerFormat?: string;
603
+
604
+ /** Scheme description. */
605
+ description?: string;
606
+ }
607
+
608
+ /** OAuth2 authentication. */
609
+ export interface IOAuth2 {
610
+ /** Scheme type. */
611
+ type: "oauth2";
612
+
613
+ /** OAuth2 flows. */
614
+ flows: IOAuth2.IFlowSet;
615
+
616
+ /** Scheme description. */
617
+ description?: string;
618
+ }
619
+
620
+ /** OpenID Connect authentication. */
621
+ export interface IOpenId {
622
+ /** Scheme type. */
623
+ type: "openIdConnect";
624
+
625
+ /** OpenID Connect discovery URL. */
626
+ openIdConnectUrl: string;
627
+
628
+ /** Scheme description. */
629
+ description?: string;
630
+ }
631
+ export namespace IOAuth2 {
632
+ /** OAuth2 flow configurations. */
633
+ export interface IFlowSet {
634
+ /** Authorization code flow. */
635
+ authorizationCode?: IFlow;
636
+
637
+ /** Implicit flow. */
638
+ implicit?: Omit<IFlow, "tokenUrl">;
639
+
640
+ /** Password flow. */
641
+ password?: Omit<IFlow, "authorizationUrl">;
642
+
643
+ /** Client credentials flow. */
644
+ clientCredentials?: Omit<IFlow, "authorizationUrl">;
645
+ }
646
+
647
+ /** OAuth2 flow configuration. */
648
+ export interface IFlow {
649
+ /** Authorization URL. */
650
+ authorizationUrl?: string;
651
+
652
+ /** Token URL. */
653
+ tokenUrl?: string;
654
+
655
+ /** Refresh URL. */
656
+ refreshUrl?: string;
657
+
658
+ /** Available scopes. */
659
+ scopes?: Record<string, string>;
660
+ }
661
+ }
662
+ }
663
+ }