File tree Expand file tree Collapse file tree 2 files changed +43
-3
lines changed
packages/openapi-typescript
test/transform/schema-object Expand file tree Collapse file tree 2 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -302,7 +302,11 @@ function transformSchemaObjectCore(
302
302
}
303
303
// standard array type
304
304
else if ( schemaObject . items ) {
305
- itemType = transformSchemaObject ( schemaObject . items , options ) ;
305
+ if ( "type" in schemaObject . items && schemaObject . items . type === 'array' ) {
306
+ itemType = ts . factory . createArrayTypeNode ( transformSchemaObject ( schemaObject . items , options ) ) ;
307
+ } else {
308
+ itemType = transformSchemaObject ( schemaObject . items , options ) ;
309
+ }
306
310
}
307
311
308
312
const min : number =
@@ -350,9 +354,9 @@ function transformSchemaObjectCore(
350
354
}
351
355
}
352
356
353
- return ts . isTupleTypeNode ( itemType )
357
+ return ts . isTupleTypeNode ( itemType ) || ts . isArrayTypeNode ( itemType )
354
358
? itemType
355
- : ts . factory . createArrayTypeNode ( itemType ) ; // wrap itemType in array type, but only if not a tuple already
359
+ : ts . factory . createArrayTypeNode ( itemType ) ; // wrap itemType in array type, but only if not a tuple or array already
356
360
}
357
361
358
362
// polymorphic, or 3.1 nullable
Original file line number Diff line number Diff line change @@ -337,6 +337,42 @@ describe("transformSchemaObject > object", () => {
337
337
} ,
338
338
} ,
339
339
] ,
340
+ [
341
+ "options > two-dimensional array" ,
342
+ {
343
+ given : {
344
+ type : "object" ,
345
+ properties : {
346
+ array : {
347
+ "type" : "array" ,
348
+ "items" : {
349
+ "items" : [
350
+ {
351
+ "type" : "string"
352
+ } ,
353
+ {
354
+ "type" : "boolean"
355
+ }
356
+ ] ,
357
+ "type" : "array" ,
358
+ "maxItems" : 2 ,
359
+ "minItems" : 2
360
+ }
361
+ } ,
362
+ } ,
363
+ } ,
364
+ want : `{
365
+ array?: [
366
+ string,
367
+ boolean
368
+ ][];
369
+ }` ,
370
+ options : {
371
+ ...DEFAULT_OPTIONS ,
372
+ ctx : { ...DEFAULT_OPTIONS . ctx } ,
373
+ } ,
374
+ } ,
375
+ ] ,
340
376
] ;
341
377
342
378
for ( const [
You can’t perform that action at this time.
0 commit comments