@@ -157,6 +157,23 @@ export class TestParamsService {
157
157
) : string {
158
158
return `limit:${ limit } |prefix:${ prefix } |expand:${ expand } ` ;
159
159
}
160
+ @GET
161
+ @Path ( 'boolean-casing' )
162
+ public testBooleanCasing (
163
+ @QueryParam ( 'True' ) True ?: boolean ,
164
+ @QueryParam ( 'TRUE' ) TRUE ?: boolean ,
165
+ @QueryParam ( 'False' ) False ?: boolean ,
166
+ @QueryParam ( 'FALSE' ) FALSE ?: boolean
167
+ ) : string {
168
+ return `True:${ True } |TRUE:${ TRUE } |False:${ False } |FALSE:${ FALSE } ` ;
169
+ }
170
+
171
+ @POST
172
+ @Path ( 'boolean-as-body-param' )
173
+ @BodyOptions ( { strict : false } )
174
+ public testBooleanAsBodyParam ( expand : boolean ) : string {
175
+ return `expand:${ expand } ` ;
176
+ }
160
177
161
178
@POST
162
179
@Path ( 'upload' )
@@ -478,6 +495,44 @@ describe('Data Types Tests', () => {
478
495
}
479
496
) ;
480
497
} ) ;
498
+
499
+ it ( 'should handle boolean parameters with different casings' , ( done ) => {
500
+ request (
501
+ {
502
+ url : 'http://localhost:5674/testparams/boolean-casing?True=True&TRUE=TRUE&False=False&FALSE=FALSE'
503
+ } ,
504
+ ( error , response , body ) => {
505
+ expect ( body ) . toEqual ( 'True:true|TRUE:true|False:false|FALSE:false' ) ;
506
+ done ( ) ;
507
+ }
508
+ ) ;
509
+ } ) ;
510
+
511
+ it ( 'should handle boolean parameters as undefined' , ( done ) => {
512
+ request (
513
+ {
514
+ url : 'http://localhost:5674/testparams/boolean-casing?True='
515
+ } ,
516
+ ( error , response , body ) => {
517
+ expect ( body ) . toEqual ( 'True:false|TRUE:undefined|False:undefined|FALSE:undefined' ) ;
518
+ done ( ) ;
519
+ }
520
+ ) ;
521
+ } ) ;
522
+
523
+ it ( 'should handle boolean parameters as param in body' , ( done ) => {
524
+ request . post (
525
+ {
526
+ url : 'http://localhost:5674/testparams/boolean-as-body-param' ,
527
+ headers : { 'Content-Type' : 'application/json' } ,
528
+ body : JSON . stringify ( true )
529
+ } ,
530
+ ( error , response , body ) => {
531
+ expect ( body ) . toEqual ( 'expand:true' ) ;
532
+ done ( ) ;
533
+ }
534
+ ) ;
535
+ } ) ;
481
536
} ) ;
482
537
describe ( 'Download Service' , ( ) => {
483
538
it ( 'should return a file' , ( done ) => {
0 commit comments