File tree 3 files changed +56
-0
lines changed
3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,8 @@ export function tsTupleOf(types: string[]): string {
180
180
export function tsIntersectionOf ( types : string [ ] ) : string {
181
181
const typesWithValues = types . filter ( Boolean ) ;
182
182
183
+ if ( ! typesWithValues . length ) return "undefined" ; // usually allOf/anyOf with empty input - so it's undefined
184
+
183
185
if ( typesWithValues . length === 1 ) return typesWithValues [ 0 ] ; // don’t add parentheses around one thing
184
186
return `(${ typesWithValues . join ( ") & (" ) } )` ;
185
187
}
@@ -195,6 +197,8 @@ export function tsReadonly(immutable: boolean): string {
195
197
196
198
/** Convert [X, Y, Z] into X | Y | Z */
197
199
export function tsUnionOf ( types : Array < string | number | boolean > ) : string {
200
+ if ( ! types . length ) return "undefined" ; // usually oneOf with empty input - so it's undefined
201
+
198
202
if ( types . length === 1 ) return `${ types [ 0 ] } ` ; // don’t add parentheses around one thing
199
203
return `(${ types . join ( ") | (" ) } )` ;
200
204
}
Original file line number Diff line number Diff line change
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+
6
+ export interface paths {
7
+ "/test" : {
8
+ get : {
9
+ responses : {
10
+ /** A list of types. */
11
+ 200 : unknown ;
12
+ } ;
13
+ } ;
14
+ } ;
15
+ }
16
+
17
+ export interface components {
18
+ schemas : {
19
+ /** @description Enum with null and nullable */
20
+ Example : {
21
+ emptyAllOf ?: undefined ;
22
+ emptyOneOf ?: undefined ;
23
+ emptyAnyOf ?: undefined ;
24
+ } ;
25
+ } ;
26
+ }
27
+
28
+ export interface operations { }
29
+
30
+ export interface external { }
Original file line number Diff line number Diff line change
1
+ openapi : 3.0
2
+ paths :
3
+ /test :
4
+ get :
5
+ tags :
6
+ - test
7
+ summary : " Just a test path"
8
+ responses :
9
+ 200 :
10
+ description : A list of types.
11
+ components :
12
+ schemas :
13
+ Example :
14
+ description : Enum with null and nullable
15
+ type : object
16
+ properties :
17
+ emptyAllOf :
18
+ allOf : []
19
+ emptyOneOf :
20
+ oneOf : []
21
+ emptyAnyOf :
22
+ anyOf : []
You can’t perform that action at this time.
0 commit comments