@@ -111,9 +111,9 @@ describe("Schema Object", () => {
111
111
} ) ;
112
112
113
113
test ( "tuple array" , ( ) => {
114
- const schema : SchemaObject = { type : "array" , items : [ { type : "string" } , { " type" : "number" } ] , minItems :2 , maxItems :2 } ;
114
+ const schema : SchemaObject = { type : "array" , items : [ { type : "string" } , { type : "number" } ] , minItems : 2 , maxItems : 2 } ;
115
115
const generated = transformSchemaObject ( schema , options ) ;
116
- expect ( generated ) . toBe ( "[string,number]" ) ;
116
+ expect ( generated ) . toBe ( "[string, number]" ) ;
117
117
} ) ;
118
118
119
119
test ( "ref" , ( ) => {
@@ -279,10 +279,7 @@ describe("Schema Object", () => {
279
279
} ) ;
280
280
281
281
test ( "enum + polymorphism + nullable" , ( ) => {
282
- const generated = transformSchemaObject (
283
- { type : [ "string" , "null" ] , enum : [ "" , "false positive" , "won't fix" , "used in tests" ] } ,
284
- options
285
- ) ;
282
+ const generated = transformSchemaObject ( { type : [ "string" , "null" ] , enum : [ "" , "false positive" , "won't fix" , "used in tests" ] } , options ) ;
286
283
expect ( generated ) . toBe ( `"" | "false positive" | "won't fix" | "used in tests" | null` ) ;
287
284
} ) ;
288
285
} ) ;
@@ -341,10 +338,7 @@ describe("Schema Object", () => {
341
338
test ( "discriminator" , ( ) => {
342
339
const schema : SchemaObject = {
343
340
type : "object" ,
344
- allOf : [
345
- { $ref : 'components["schemas"]["parent"]' } ,
346
- { type : "object" , properties : { string : { type : "string" } } } ,
347
- ] ,
341
+ allOf : [ { $ref : 'components["schemas"]["parent"]' } , { type : "object" , properties : { string : { type : "string" } } } ] ,
348
342
} ;
349
343
const generated = transformSchemaObject ( schema , {
350
344
path : options . path ,
@@ -370,10 +364,7 @@ describe("Schema Object", () => {
370
364
test ( "discriminator escape" , ( ) => {
371
365
const schema : SchemaObject = {
372
366
type : "object" ,
373
- allOf : [
374
- { $ref : 'components["schemas"]["parent"]' } ,
375
- { type : "object" , properties : { string : { type : "string" } } } ,
376
- ] ,
367
+ allOf : [ { $ref : 'components["schemas"]["parent"]' } , { type : "object" , properties : { string : { type : "string" } } } ] ,
377
368
} ;
378
369
const generated = transformSchemaObject ( schema , {
379
370
path : options . path ,
@@ -532,20 +523,22 @@ describe("Schema Object", () => {
532
523
} ) ;
533
524
} ) ;
534
525
535
- describe ( "supportArrayLength" , ( ) => {
536
- test ( "true" , ( ) => {
537
- const opts = { ...options , ctx : { ...options . ctx , supportArrayLength : true } } ;
538
- expect ( transformSchemaObject ( { type : "array" , items : { type : "string" } } , options ) ) . toBe ( `(string)[]` ) ;
539
- expect ( transformSchemaObject ( { type : "array" , items : { type : "string" } , minItems : 1 } , opts ) ) . toBe (
540
- `[string, ...(string)[]]`
541
- ) ;
542
- expect ( transformSchemaObject ( { type : "array" , items : { type : "string" } , maxItems : 2 } , opts ) ) . toBe (
543
- `[] | [string] | [string, string]`
544
- ) ;
545
- expect ( transformSchemaObject ( { type : "array" , items : { type : "string" } , maxItems : 20 } , opts ) ) . toBe (
546
- `(string)[]`
547
- ) ;
548
- } ) ;
526
+ test ( "supportArrayLength" , ( ) => {
527
+ const opts = { ...options , ctx : { ...options . ctx , supportArrayLength : true } } ;
528
+ expect ( transformSchemaObject ( { type : "array" , items : { type : "string" } } , options ) ) . toBe ( `(string)[]` ) ;
529
+ expect ( transformSchemaObject ( { type : "array" , items : { type : "string" } , minItems : 1 } , opts ) ) . toBe ( `[string, ...(string)[]]` ) ;
530
+ expect ( transformSchemaObject ( { type : "array" , items : { type : "string" } , maxItems : 2 } , opts ) ) . toBe ( `[] | [string] | [string, string]` ) ;
531
+ expect ( transformSchemaObject ( { type : "array" , items : { type : "string" } , maxItems : 20 } , opts ) ) . toBe ( `(string)[]` ) ;
532
+ } ) ;
533
+
534
+ test ( "prefixItems" , ( ) => {
535
+ const schema : SchemaObject = {
536
+ type : "array" ,
537
+ items : { type : "number" } ,
538
+ prefixItems : [ { type : "number" } , { type : "number" } , { type : "number" } ] ,
539
+ } ;
540
+ const generated = transformSchemaObject ( schema , options ) ;
541
+ expect ( generated ) . toBe ( `[number, number, number]` ) ;
549
542
} ) ;
550
543
551
544
describe ( "immutableTypes" , ( ) => {
0 commit comments