forked from microsoft/typespec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
1125 lines (947 loc) · 45.2 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { Diagnostic, Service } from "@typespec/compiler";
import { Contact, ExtensionKey, License } from "@typespec/openapi";
export type CommonOpenAPI3Schema = OpenAPI3Schema & OpenAPISchema3_1;
export type SupportedOpenAPIDocuments = OpenAPI3Document | OpenAPIDocument3_1;
export type Extensions = {
[key in ExtensionKey]?: any;
};
export interface OpenAPI3Document extends Extensions {
openapi: "3.0.0";
/**
* Provides metadata about the API. The metadata can be used by the clients if needed.
*/
info: OpenAPI3Info;
/** Additional external documentation. */
externalDocs?: OpenAPI3ExternalDocs;
/** The available paths and operations for the API */
paths: Record<string, OpenAPI3PathItem>;
/**
* An array of Server Objects, which provide connectivity information to a target server.
* If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url value of /.
*/
servers?: OpenAPI3Server[];
/**
* A list of tags used by the specification with additional metadata.
* The order of the tags can be used to reflect on their order by the parsing tools.
* Not all tags that are used by the Operation Object must be declared.
* The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique.
*/
tags?: OpenAPI3Tag[];
/** An element to hold various schemas for the specification. */
components?: OpenAPI3Components;
/** A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. */
security?: Record<string, string[]>[];
}
/**
* A record containing the the OpenAPI 3 documents corresponding to
* a particular service definition.
*/
export type OpenAPI3ServiceRecord =
| OpenAPI3UnversionedServiceRecord
| OpenAPI3VersionedServiceRecord;
export interface OpenAPI3UnversionedServiceRecord {
/** The service that generated this OpenAPI document */
readonly service: Service;
/** Whether the service is versioned */
readonly versioned: false;
/** The OpenAPI 3 document */
readonly document: SupportedOpenAPIDocuments;
/** The diagnostics created for this document */
readonly diagnostics: readonly Diagnostic[];
}
export interface OpenAPI3VersionedServiceRecord {
/** The service that generated this OpenAPI document */
readonly service: Service;
/** Whether the service is versioned */
readonly versioned: true;
/** The OpenAPI 3 document records for each version of this service */
readonly versions: OpenAPI3VersionedDocumentRecord[];
}
/**
* A record containing an unversioned OpenAPI document and associated metadata.
*/
export interface OpenAPI3VersionedDocumentRecord {
/** The OpenAPI document*/
readonly document: SupportedOpenAPIDocuments;
/** The service that generated this OpenAPI document. */
readonly service: Service;
/** The version of the service. Absent if the service is unversioned. */
readonly version: string;
/** The diagnostics created for this version. */
readonly diagnostics: readonly Diagnostic[];
}
export interface OpenAPI3Info extends Extensions {
title: string;
description?: string;
termsOfService?: string;
version: string;
contact?: Contact;
license?: License;
summary?: string;
}
export interface OpenAPI3Server {
url: string;
description?: string;
variables?: Record<string, OpenAPI3ServerVariable>;
}
export interface OpenAPI3ServerVariable {
enum?: string[];
default: string;
description?: string;
}
export interface OpenAPI3ExternalDocs {
url: string;
description?: string;
}
export interface OpenAPI3Tag extends Extensions {
name: string;
description?: string;
externalDocs?: OpenAPI3ExternalDocs;
}
export type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
/**
* Describes the operations available on a single path. A Path Item may be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available.
*
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#pathItemObject
*/
export type OpenAPI3PathItem = {
[method in HttpMethod]?: OpenAPI3Operation;
} & { parameters?: OpenAPI3Parameter[] } & Extensions;
export interface OpenAPI3Components extends Extensions {
schemas?: Record<string, OpenAPI3Schema>;
headers?: Record<string, OpenAPI3Header>;
responses?: Record<string, OpenAPI3Response>;
parameters?: Record<string, OpenAPI3Parameter>;
examples?: Record<string, OpenAPI3Example>;
requestBodies?: Record<string, OpenAPI3RequestBody>;
securitySchemes?: Record<string, OpenAPI3SecurityScheme>;
links?: Record<string, OpenAPI3Link>;
}
export type OpenAPI3StatusCode = string | "default" | "1XX" | "2XX" | "3XX" | "4XX" | "5XX";
export type OpenAPI3Responses = {
[status: OpenAPI3StatusCode]: Refable<OpenAPI3Response>;
} & Extensions;
export type OpenAPI3Response = Extensions & {
/** A short description of the response. CommonMark syntax MAY be used for rich text representation. */
description: string;
/** Maps a header name to its definition. RFC7230 states header names are case insensitive. If a response header is defined with the name "Content-Type", it SHALL be ignored. */
headers?: Record<string, Refable<OpenAPI3Header>>;
/** A map containing descriptions of potential response payloads. The key is a media type or media type range and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* */
content?: Record<string, OpenAPI3MediaType>;
/** A map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for Component Objects. */
links?: Record<string, Refable<OpenAPI3Link>>;
};
/**
* Each Media Type Object provides schema and examples for the media type identified by its key.
*
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#mediaTypeObject
*/
export type OpenAPI3MediaType = Extensions & {
/** The schema defining the content of the request, response, or parameter. */
schema?: Refable<OpenAPI3Schema>;
/** A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property. The encoding object SHALL only apply to requestBody objects when the media type is multipart or application/x-www-form-urlencoded. */
encoding?: Record<string, OpenAPI3Encoding>;
/** Example */
example?: unknown;
/** Examples with title */
examples?: Record<string, OpenAPI3Example>;
};
/**
* A single encoding definition applied to a single schema property.
*
* see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#encodingObject
*/
export type OpenAPI3Encoding = Extensions & {
/** the Content-Type for encoding a specific property. Default value depends on the property type: for string with format being binary – application/octet-stream; for other primitive types – text/plain; for object - application/json; for array – the default is defined based on the inner type. The value can be a specific media type (e.g. application/json), a wildcard media type (e.g. image/*), or a comma-separated list of the two types. */
contentType?: string;
/** A map allowing additional information to be provided as headers, for example Content-Disposition. Content-Type is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a multipart. */
headers?: Record<string, Refable<OpenAPI3Header>>;
/** Describes how a specific property value will be serialized depending on its type. See Parameter Object for details on the style property. The behavior follows the same values as query parameters, including default values. This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded. */
style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject";
/** When this is true, property values of type array or object generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When style is form, the default value is true. For all other styles, the default value is false. This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded. */
explode?: boolean;
/** Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC3986 :/?#[]@!$&'()*+,;= to be included without percent-encoding. The default value is false. This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded */
allowReserved?: boolean;
};
/**
* Describes a single request body.
*
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#request-body-object
*/
export type OpenAPI3RequestBody = Extensions & {
/** A brief description of the request body. This could contain examples of use. CommonMark syntax MAY be used for rich text representation. */
description?: string;
/** The content of the request body. The key is a media type or media type range and the value describes it. For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/* */
content: Record<string, OpenAPI3MediaType>;
/** Determines if the request body is required in the request. Defaults to false. */
required?: boolean;
};
export type OpenAPI3SecurityScheme =
| OpenAPI3ApiKeySecurityScheme
| OpenAPI3OAuth2SecurityScheme
| OpenAPI3OpenIdConnectSecurityScheme
| OpenAPI3HttpSecurityScheme;
/**
* defines a security scheme that can be used by the operations. Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), OAuth2's common flows (implicit, password, application and access code) as defined in RFC6749, and OpenID Connect Discovery.
*
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#security-scheme-object
*/
export interface OpenAPI3SecuritySchemeBase extends Extensions {
/** A short description for security scheme. CommonMark syntax MAY be used for rich text representation. */
description?: string;
}
/**
* defines an ApiKey security scheme that can be used by the operations
*/
export interface OpenAPI3ApiKeySecurityScheme extends OpenAPI3SecuritySchemeBase {
/** ApiKey */
type: "apiKey";
/** The name of the header, query or cookie parameter to be used. */
name: string;
/** The location of the API key. */
in: "cookie" | "header" | "query";
}
/**
* defines an Http security scheme that can be used by the operations
*/
export interface OpenAPI3HttpSecurityScheme extends OpenAPI3SecuritySchemeBase {
/** HTTP */
type: "http";
/** he name of the HTTP Authorization scheme to be used in the Authorization header as defined in RFC7235. */
scheme: string;
/** A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes. */
bearerFormat?: string;
}
/**
* defines an OAuth2 security scheme that can be used by the operations
*/
export interface OpenAPI3OAuth2SecurityScheme extends OpenAPI3SecuritySchemeBase {
/* OAuth2 */
type: "oauth2";
/** An object containing configuration information for the flow types supported. */
flows: OpenAPI3OAuthFlows;
}
/**
* Allows configuration of the supported OAuth Flows.
*
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#oauthFlowsObject
*/
export interface OpenAPI3OAuthFlows extends Extensions {
/** Configuration for the OAuth Implicit flow */
implicit?: OpenAPI3ImplicitOAuthFlow;
/** Configuration for the OAuth Resource Owner Password flow */
password?: OpenAPI3PasswordOAuthFlow;
/** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */
clientCredentials?: OpenAPI3ClientCredentialsFlow;
/** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0. */
authorizationCode?: OpenAPI3AuthorizationCodeOAuthFlow;
}
/** Common definition for the OAuth flows */
export interface OpenAPI3OAuth2Flow extends Extensions {
/** The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. */
refreshUrl?: string;
/** The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. */
scopes: Record<string, string>;
}
/** Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0. */
export interface OpenAPI3ClientCredentialsFlow extends OpenAPI3OAuth2Flow {
/** The token URL to be used for this flow. This MUST be in the form of a URL. */
tokenUrl: string;
}
/** Configuration for the OAuth Resource Owner Password flow */
export interface OpenAPI3PasswordOAuthFlow extends OpenAPI3OAuth2Flow {
/** The token URL to be used for this flow. This MUST be in the form of a URL. */
tokenUrl: string;
}
/** Configuration for the OAuth Implicit flow */
export interface OpenAPI3ImplicitOAuthFlow extends OpenAPI3OAuth2Flow {
/** The authorization URL to be used for this flow. This MUST be in the form of a URL. */
authorizationUrl: string;
}
/** Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0. */
export interface OpenAPI3AuthorizationCodeOAuthFlow extends OpenAPI3OAuth2Flow {
/** The authorization URL to be used for this flow. This MUST be in the form of a URL. */
authorizationUrl: string;
/** The token URL to be used for this flow. This MUST be in the form of a URL. */
tokenUrl: string;
}
/** OpenIdConnect SecurityScheme */
export interface OpenAPI3OpenIdConnectSecurityScheme extends OpenAPI3SecuritySchemeBase {
/** OpenID Connect */
type: "openIdConnect";
/** OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of a URL. */
openIdConnectUrl: string;
}
export type OpenAPI3Link =
| {
/** A relative or absolute reference to an OAS operation. This field is mutually exclusive of the operationId field, and MUST point to an Operation Object. Relative operationRef values MAY be used to locate an existing Operation Object in the OpenAPI definition. */
operationRef: Ref<unknown>;
}
| {
/** the name of an existing, resolvable OAS operation, as defined with a unique operationId. This field is mutually exclusive of the operationRef field. */
operationId: string;
};
/**
* Allows sharing examples for operation responses.
*
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#exampleObject
*/
export interface OpenAPI3Example {
summary?: string;
description?: string;
value?: unknown;
externalValue?: string;
}
export interface OpenAPI3Discriminator extends Extensions {
propertyName: string;
mapping?: Record<string, string>;
}
export type JsonType = "array" | "boolean" | "integer" | "number" | "object" | "string";
/**
* Autorest allows a few properties to be next to $ref of a property.
*/
export type OpenAPI3SchemaProperty = Ref<OpenAPI3Schema> | OpenAPI3Schema;
export type OpenAPI3XmlSchema = Extensions & {
name?: string;
namespace?: string;
prefix?: string;
attribute?: boolean;
wrapped?: boolean;
};
export type OpenAPI3Schema = Extensions & {
/**
* This attribute is a string that provides a short description of the instance property.
*
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2
*/
title?: string;
/**
* Must be strictly greater than 0.
* A numeric instance is valid only if division by this keyword's value results in an integer.
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.1
*/
multipleOf?: number;
/**
* Representing an inclusive upper limit for a numeric instance.
* This keyword validates only if the instance is less than or exactly equal to "maximum".
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.2
*/
maximum?: number;
/**
* Representing an exclusive upper limit for a numeric instance.
* This keyword validates only if the instance is strictly less than (not equal to) to "exclusiveMaximum".
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.3
*/
exclusiveMaximum?: boolean;
/**
* Representing an inclusive lower limit for a numeric instance.
* This keyword validates only if the instance is greater than or exactly equal to "minimum".
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.4
*/
minimum?: number;
/**
* Representing an exclusive lower limit for a numeric instance.
* This keyword validates only if the instance is strictly greater than (not equal to) to "exclusiveMinimum".
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.5
*/
exclusiveMinimum?: boolean;
/**
* Must be a non-negative integer.
* A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.6
*/
maxLength?: number;
/**
* Must be a non-negative integer.
* A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
* Omitting this keyword has the same behavior as a value of 0.
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.7
*/
minLength?: number;
/**
* Should be a valid regular expression, according to the ECMA 262 regular expression dialect.
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.8
*/
pattern?: string;
/**
* Must be a non-negative integer.
* An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword.
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.11
*/
maxItems?: number;
/**
* Must be a non-negative integer.
* An array instance is valid against "maxItems" if its size is greater than, or equal to, the value of this keyword.
* Omitting this keyword has the same behavior as a value of 0.
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.12
*/
minItems?: number;
/**
* If this keyword has boolean value false, the instance validates successfully.
* If it has boolean value true, the instance validates successfully if all of its elements are unique.
* Omitting this keyword has the same behavior as a value of false.
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.13
*/
uniqueItems?: boolean;
/**
* Must be a non-negative integer.
* An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.15
*/
maxProperties?: number;
/**
* Must be a non-negative integer.
* An object instance is valid against "maxProperties" if its number of properties is greater than,
* or equal to, the value of this keyword.
* Omitting this keyword has the same behavior as a value of 0.
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.16
*/
minProperties?: number;
/**
* Elements of this array must be unique.
* An object instance is valid against this keyword if every item in the array is the name of a property in the instance.
* Omitting this keyword has the same behavior as an empty array.
*
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.17
*/
required?: Array<string>;
/**
* This provides an enumeration of all possible values that are valid
* for the instance property. This MUST be an array, and each item in
* the array represents a possible value for the instance value. If
* this attribute is defined, the instance value MUST be one of the
* values in the array in order for the schema to be valid.
*
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.23
*/
enum?: (string | number | boolean)[];
/** the JSON type for the schema */
type?: JsonType;
/** The extending format for the previously mentioned type. */
format?: string;
/** This attribute is a string that provides a full description of the schema */
description?: string;
/**
* A collection of schemas that this schema also must conform to.
*
* An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value.
*
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.26
*/
allOf?: Refable<OpenAPI3Schema>[];
/**
* A collection of schemas that this schema may conform to one or more of.
*
* An instance validates successfully against this keyword if it validates successfully against at least one schema defined by this keyword's value.
*
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.27
*/
anyOf?: Refable<OpenAPI3Schema>[];
/**
* A collection of schemas that this schema may conform to only one of.
*
* An instance validates successfully against this keyword if it validates successfully against exactly one schema defined by this keyword's value.
*
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.28
*/
oneOf?: Refable<OpenAPI3Schema>[];
/**
* An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword.
* @see https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.29
*/
not?: Refable<OpenAPI3Schema>;
/** This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself. */
items?: Refable<OpenAPI3Schema>;
/**
* This attribute is an object with property definitions that define the
* valid values of instance object property values. When the instance
* value is an object, the property values of the instance object MUST
* conform to the property definitions in this object. In this object,
* each property definition's value MUST be a schema, and the property's
* name MUST be the name of the instance property that it defines. The
* instance property value MUST be valid according to the schema from
* the property definition. Properties are considered unordered, the
* order of the instance properties MAY be in any order.
*
*/
properties?: Record<string, OpenAPI3SchemaProperty>;
/** indicates that additional unlisted properties can exist in this schema */
additionalProperties?: boolean | Refable<OpenAPI3Schema>;
/**
* Declares the value of the property that the server will use if none is provided,
* for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request.
*
* @note "default" has no meaning for required parameters.) See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2. Unlike JSON Schema this value MUST conform to the defined type for this parameter.
*/
default?: string | boolean | number | Record<string, any>;
/** Allows sending a null value for the defined schema. Default value is false. */
nullable?: boolean;
/**
* Property is readonly.
*/
readOnly?: boolean;
/** Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description */
discriminator?: OpenAPI3Discriminator;
/** Additional external documentation for this schema. */
externalDocs?: OpenAPI3ExternalDocs;
/** A free-form property to include an example of an instance for this schema. To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary. */
example?: any;
/** Specifies that a schema is deprecated and SHOULD be transitioned out of usage.Default value is false. */
deprecated?: boolean;
/** This MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property. */
xml?: OpenAPI3XmlSchema;
};
export type OpenAPI3ParameterBase = Extensions & {
/**A brief description of the parameter. This could contain examples of use. CommonMark syntax MAY be used for rich text representation. */
description?: string;
/**Determines whether this parameter is mandatory. If the parameter location is "path", this property is REQUIRED and its value MUST be true. Otherwise, the property MAY be included and its default value is false. */
required?: boolean;
/** Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is false. */
deprecated?: boolean;
/** When this is true, parameter values of type array or object generate separate parameters for each value of the array or key-value pair of the map. For other types of parameters this property has no effect. When style is form, the default value is true. For all other styles, the default value is false. */
explode?: boolean;
schema: OpenAPI3Schema;
};
export type OpenAPI3QueryParameter = OpenAPI3ParameterBase & {
/** Name of the parameter. */
name: string;
in: "query";
/**
* Describes how the parameter value will be serialized depending on the type of the parameter value.
*
* Default value for query parameters is form.
* @see https://github.com/OAI/OpenAPI-Specification/blob/3.0.3/versions/3.0.2.md#style-values
*/
style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject";
};
export type OpenAPI3PathParameter = OpenAPI3ParameterBase & {
/** Name of the parameter. */
name: string;
in: "path";
/**
* Describes how the parameter value will be serialized depending on the type of the parameter value.
*
* Default value for path parameters is simple.
* @see https://github.com/OAI/OpenAPI-Specification/blob/3.0.3/versions/3.0.2.md#style-values
*/
style?: "simple" | "label" | "matrix";
};
export type OpenAPI3HeaderParameter = OpenAPI3ParameterBase & {
/** Name of the parameter. */
name: string;
in: "header";
/**
* Describes how the parameter value will be serialized depending on the type of the parameter value.
*
* Default value for header parameters is simple.
* @see https://github.com/OAI/OpenAPI-Specification/blob/3.0.3/versions/3.0.2.md#style-values
*/
style?: "simple";
};
export type OpenAPI3Parameter =
| OpenAPI3HeaderParameter
| OpenAPI3QueryParameter
| OpenAPI3PathParameter;
export type OpenAPI3ParameterType = OpenAPI3Parameter["in"];
/**
* The Header Object follows the structure of the Parameter Object with the following changes:
*
* name MUST NOT be specified, it is given in the corresponding headers map.
* in MUST NOT be specified, it is implicitly in header.
* All traits that are affected by the location MUST be applicable to a location of header (for example, style).
*
* @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#header-object
*/
export type OpenAPI3Header = OpenAPI3ParameterBase & {
/** Describes how the parameter value will be serialized depending on the type of the parameter value
*
* simple - Simple style parameters defined by RFC6570. This option replaces collectionFormat with a csv value from OpenAPI 2.0
*/
style?: "simple";
};
export type OpenAPI3Operation = Extensions & {
description?: string;
summary?: string;
responses?: any;
tags?: string[];
operationId?: string;
requestBody?: Refable<OpenAPI3RequestBody>;
parameters: Refable<OpenAPI3Parameter>[];
deprecated?: boolean;
security?: Record<string, string[]>[];
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface Ref<T> {
$ref: string;
description?: string;
summary?: string;
}
export type Refable<T> = Ref<T> | T;
export type JsonSchemaType =
| "array"
| "boolean"
| "integer"
| "null"
| "number"
| "object"
| "string";
export type JsonSchema<AdditionalVocabularies extends {} = {}> = AdditionalVocabularies & {
/**
* The JSON type for the schema.
* If the value is an array, then an instance validates successfully if its type
* matches any of the types indicated by the string in the array.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-type
*/
type?: JsonSchemaType | JsonSchemaType[];
/**
* The extending format for the previously mentioned type.
*/
format?: string;
/**
* This provides an enumeration of all possible values that are valid
* for the instance property. This MUST be an array, and each item in
* the array represents a possible value for the instance value. If
* this attribute is defined, the instance value MUST be one of the
* values in the array in order for the schema to be valid.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-enum
*/
enum?: (string | number | boolean | null)[];
/**
* Functionally equivalent to "enum" with a single value.
* An instance validates successfully if its value is equal to the value of this keyword.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-const
*/
const?: unknown;
/**
* Must be strictly greater than 0.
* A numeric instance is valid only if division by this keyword's value results in an integer.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-multipleof
*/
multipleOf?: number;
/**
* Representing an inclusive upper limit for a numeric instance.
* This keyword validates only if the instance is less than or exactly equal to "maximum".
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maximum
*/
maximum?: number;
/**
* Representing an exclusive upper limit for a numeric instance.
* This keyword validates only if the instance is strictly less than (not equal to) to "exclusiveMaximum".
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-exclusivemaximum
*/
exclusiveMaximum?: number;
/**
* Representing an inclusive lower limit for a numeric instance.
* This keyword validates only if the instance is greater than or exactly equal to "minimum".
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-minimum
*/
minimum?: number;
/**
* Representing an exclusive lower limit for a numeric instance.
* This keyword validates only if the instance is strictly greater than (not equal to) to "exclusiveMinimum".
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-exclusiveminimum
*/
exclusiveMinimum?: number;
/**
* Must be a non-negative integer.
* A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maxlength
*/
maxLength?: number;
/**
* Must be a non-negative integer.
* A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
* Omitting this keyword has the same behavior as a value of 0.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-minlength
*/
minLength?: number;
/**
* Should be a valid regular expression, according to the ECMA 262 regular expression dialect.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-pattern
*/
pattern?: string;
/**
* Must be a non-negative integer.
* An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maxitems
*/
maxItems?: number;
/**
* Must be a non-negative integer.
* An array instance is valid against "maxItems" if its size is greater than, or equal to, the value of this keyword.
* Omitting this keyword has the same behavior as a value of 0.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-minitems
*/
minItems?: number;
/**
* If this keyword has boolean value false, the instance validates successfully.
* If it has boolean value true, the instance validates successfully if all of its elements are unique.
* Omitting this keyword has the same behavior as a value of false.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-uniqueitems
*/
uniqueItems?: boolean;
/**
* Must be a non-negative integer.
* If "contains" is not present within the same schema object, then this has no effect.
* An array instance is valid against "maxContains" if the number of elements that are'
* valid against the schema defined by "contains" is less than, or equal to, the value of this keyword.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maxcontains
*/
maxContains?: number;
/**
* Must be a non-negative integer.
* If "contains" is not present within the same schema object, then this has no effect.
* An array instance is valid against "minContains" if the number of elements that are'
* valid against the schema defined by "contains" is greater than, or equal to, the value of this keyword.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maxcontains
*/
minContains?: number;
/**
* Must be a non-negative integer.
* An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maxproperties
*/
maxProperties?: number;
/**
* Must be a non-negative integer.
* An object instance is valid against "maxProperties" if its number of properties is greater than,
* or equal to, the value of this keyword.
* Omitting this keyword has the same behavior as a value of 0.
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-minproperties
*/
minProperties?: number;
/**
* Elements of this array must be unique.
* An object instance is valid against this keyword if every item in the array is the name of a property in the instance.
* Omitting this keyword has the same behavior as an empty array.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-required
*/
required?: Array<string>;
/**
* Must be a string.
* If the schema instance is a string, this property defines that the string SHOULD be
* interpreted as encoded binary data and decoded using the encoding named by this property.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-contentencoding
*/
contentEncoding?: string;
/**
* If the schema instance is a string and "contentMediaType" is present, this property
* contains a schema which describes the structure of the string.
* This should be ignored if "contentMediaType" is not present.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-contentschema
*/
contentSchema?: Refable<JsonSchema<AdditionalVocabularies>>;
/**
* Must be a string.
* If the schema instance is a string, this property indicates the media type of the contents of the string.
* If "contentEncoding" is present, this property describes the decoded string.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-contentmediatype
*/
contentMediaType?: string;
/**
* This attribute is a string that provides a short description of the instance property.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-title-and-description
*/
title?: string;
/**
* This attribute is a string that provides a full description of the schema
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-title-and-description
*/
description?: string;
/**
* Declares the value of the property that the server will use if none is provided,
* for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-default
*/
default?: string | boolean | number | null | Record<string, any>;
/**
* Specifies that a schema is deprecated and SHOULD be transitioned out of usage.
* Default value is false.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-deprecated
*/
deprecated?: boolean;
/**
* An array of free-form properties to include examples of an instance for this schema.
* To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary.
*
* @see https://json-schema.org/draft/2020-12/json-schema-validation#name-examples
*/
examples?: any[];
/**
* A collection of schemas that this schema also must conform to.
*
* An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value.
*
* @see https://json-schema.org/draft/2020-12/json-schema-core#name-allof
*/
allOf?: Refable<JsonSchema<AdditionalVocabularies>>[];
/**
* A collection of schemas that this schema may conform to one or more of.
*
* An instance validates successfully against this keyword if it validates successfully against at least one schema defined by this keyword's value.
*
* @see https://json-schema.org/draft/2020-12/json-schema-core#name-anyof
*/
anyOf?: Refable<JsonSchema<AdditionalVocabularies>>[];
/**
* A collection of schemas that this schema may conform to only one of.
*
* An instance validates successfully against this keyword if it validates successfully against exactly one schema defined by this keyword's value.
*
* @see https://json-schema.org/draft/2020-12/json-schema-core#name-oneof
*/
oneOf?: Refable<JsonSchema<AdditionalVocabularies>>[];
/**
* An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword.
* @see https://json-schema.org/draft/2020-12/json-schema-core#name-not
*/
not?: Refable<JsonSchema<AdditionalVocabularies>>;
/**
* Validation succeeds if each element of the instance validates against the schema at the same position, if any.
* This keyword does not constrain the length of the array.
* If the array is longer than this keyword's value, this keyword validates only the prefix of matching length.
*
* @see https://json-schema.org/draft/2020-12/json-schema-core#name-prefixitems
*/
prefixItems?: Refable<JsonSchema<AdditionalVocabularies>>[];
/**
* This keyword applies its subschema to all instance elements at indexes greater than the lenfth of the "prefixItems" array.
*
* @see https://json-schema.org/draft/2020-12/json-schema-core#name-items
* */
items?: Refable<JsonSchema<AdditionalVocabularies>>;
/**
* An array instance validates successfully against this keyword if at least one of its elements is valid against the given schema,
* except when `minContains` is present and has a value of 0.
*
* @see https://json-schema.org/draft/2020-12/json-schema-core#name-contains
*/
contains?: Refable<JsonSchema<AdditionalVocabularies>>;
/**
* This attribute is an object with property definitions that define the
* valid values of instance object property values. When the instance
* value is an object, the property values of the instance object MUST
* conform to the property definitions in this object. In this object,
* each property definition's value MUST be a schema, and the property's
* name MUST be the name of the instance property that it defines. The
* instance property value MUST be valid according to the schema from
* the property definition. Properties are considered unordered, the
* order of the instance properties MAY be in any order.
*