@@ -367,6 +367,25 @@ func createMockLowBaseSchemaForNumberArray() *lowbase.Schema {
367367 return itemsSchema
368368}
369369
370+ func TestIncorrectQueryParamArrayInteger (t * testing.T ) {
371+ // Create mock parameter and schemas
372+ param := createMockParameterForNumberArray ()
373+ baseSchema := createMockLowBaseSchemaForNumberArray ()
374+ s := base .NewSchema (baseSchema )
375+ itemsSchema := base .NewSchema (baseSchema .Items .Value .A .Schema ())
376+
377+ // Call the function with an invalid number value in the array
378+ err := IncorrectQueryParamArrayInteger (param , "notNumber" , s , itemsSchema )
379+
380+ // Validate the error
381+ require .NotNil (t , err )
382+ require .Equal (t , helpers .ParameterValidation , err .ValidationType )
383+ require .Equal (t , helpers .ParameterValidationQuery , err .ValidationSubType )
384+ require .Contains (t , err .Message , "Query array parameter 'testQueryParam' is not a valid integer" )
385+ require .Contains (t , err .Reason , "the value 'notNumber' is not a valid integer" )
386+ require .Contains (t , err .HowToFix , "notNumber" )
387+ }
388+
370389func TestIncorrectQueryParamArrayNumber (t * testing.T ) {
371390 // Create mock parameter and schemas
372391 param := createMockParameterForNumberArray ()
@@ -568,6 +587,22 @@ func TestInvalidQueryParamNumber(t *testing.T) {
568587 require .Contains (t , err .HowToFix , "notNumber" )
569588}
570589
590+ func TestInvalidQueryParamInteger (t * testing.T ) {
591+ param := createMockParameter ()
592+ baseSchema := createMockLowBaseSchema ()
593+
594+ // Call the function with an invalid number value
595+ err := InvalidQueryParamInteger (param , "notNumber" , base .NewSchema (baseSchema ))
596+
597+ // Validate the error
598+ require .NotNil (t , err )
599+ require .Equal (t , helpers .ParameterValidation , err .ValidationType )
600+ require .Equal (t , helpers .ParameterValidationQuery , err .ValidationSubType )
601+ require .Contains (t , err .Message , "Query parameter 'testQueryParam' is not a valid integer" )
602+ require .Contains (t , err .Reason , "the value 'notNumber' is not a valid integer" )
603+ require .Contains (t , err .HowToFix , "notNumber" )
604+ }
605+
571606func TestIncorrectQueryParamEnum (t * testing.T ) {
572607 enum := `enum: [fish, crab, lobster]`
573608 var n yaml.Node
@@ -645,6 +680,29 @@ func TestIncorrectReservedValues(t *testing.T) {
645680 require .Contains (t , err .HowToFix , "borked%3A%3A%3F%5E%26%2A" )
646681}
647682
683+ func TestInvalidHeaderParamInteger (t * testing.T ) {
684+ enum := `name: blip`
685+ var n yaml.Node
686+ _ = yaml .Unmarshal ([]byte (enum ), & n )
687+
688+ schemaProxy := & lowbase.SchemaProxy {}
689+ require .NoError (t , schemaProxy .Build (context .Background (), n .Content [0 ], n .Content [0 ], nil ))
690+
691+ highSchema := base .NewSchema (schemaProxy .Schema ())
692+ param := createMockParameter ()
693+ param .Name = "bunny"
694+
695+ err := InvalidHeaderParamInteger (param , "bunmy" , highSchema )
696+
697+ // Validate the error
698+ require .NotNil (t , err )
699+ require .Equal (t , helpers .ParameterValidation , err .ValidationType )
700+ require .Equal (t , helpers .ParameterValidationHeader , err .ValidationSubType )
701+ require .Contains (t , err .Message , "Header parameter 'bunny' is not a valid integer" )
702+ require .Contains (t , err .Reason , "The header parameter 'bunny' is defined as being an integer" )
703+ require .Contains (t , err .HowToFix , "bunmy" )
704+ }
705+
648706func TestInvalidHeaderParamNumber (t * testing.T ) {
649707 enum := `name: blip`
650708 var n yaml.Node
@@ -691,6 +749,29 @@ func TestInvalidCookieParamNumber(t *testing.T) {
691749 require .Contains (t , err .HowToFix , "milky" )
692750}
693751
752+ func TestInvalidCookieParamInteger (t * testing.T ) {
753+ enum := `name: blip`
754+ var n yaml.Node
755+ _ = yaml .Unmarshal ([]byte (enum ), & n )
756+
757+ schemaProxy := & lowbase.SchemaProxy {}
758+ require .NoError (t , schemaProxy .Build (context .Background (), n .Content [0 ], n .Content [0 ], nil ))
759+
760+ highSchema := base .NewSchema (schemaProxy .Schema ())
761+ param := createMockParameter ()
762+ param .Name = "cookies"
763+
764+ err := InvalidCookieParamInteger (param , "milky" , highSchema )
765+
766+ // Validate the error
767+ require .NotNil (t , err )
768+ require .Equal (t , helpers .ParameterValidation , err .ValidationType )
769+ require .Equal (t , helpers .ParameterValidationCookie , err .ValidationSubType )
770+ require .Contains (t , err .Message , "Cookie parameter 'cookies' is not a valid integer" )
771+ require .Contains (t , err .Reason , "The cookie parameter 'cookies' is defined as being an integer" )
772+ require .Contains (t , err .HowToFix , "milky" )
773+ }
774+
694775func TestIncorrectHeaderParamBool (t * testing.T ) {
695776 enum := `name: blip`
696777 var n yaml.Node
@@ -900,6 +981,31 @@ func TestIncorrectPathParamNumber(t *testing.T) {
900981 require .Contains (t , err .HowToFix , "milky" )
901982}
902983
984+ func TestIncorrectPathParamInteger (t * testing.T ) {
985+ items := `items:
986+ type: integer`
987+ var n yaml.Node
988+ _ = yaml .Unmarshal ([]byte (items ), & n )
989+
990+ schemaProxy := & lowbase.SchemaProxy {}
991+ require .NoError (t , schemaProxy .Build (context .Background (), n .Content [0 ], n .Content [0 ], nil ))
992+
993+ highSchema := base .NewSchema (schemaProxy .Schema ())
994+ param := createMockParameter ()
995+ param .Schema = base .CreateSchemaProxy (highSchema )
996+ param .GoLow ().Schema .KeyNode = & yaml.Node {}
997+
998+ err := IncorrectPathParamInteger (param , "milky" , highSchema )
999+
1000+ // Validate the error
1001+ require .NotNil (t , err )
1002+ require .Equal (t , helpers .ParameterValidation , err .ValidationType )
1003+ require .Equal (t , helpers .ParameterValidationPath , err .ValidationSubType )
1004+ require .Contains (t , err .Message , "Path parameter 'testQueryParam' is not a valid integer" )
1005+ require .Contains (t , err .Reason , "The path parameter 'testQueryParam' is defined as being an integer" )
1006+ require .Contains (t , err .HowToFix , "milky" )
1007+ }
1008+
9031009func TestIncorrectPathParamArrayNumber (t * testing.T ) {
9041010 items := `items:
9051011 type: number`
@@ -926,6 +1032,32 @@ func TestIncorrectPathParamArrayNumber(t *testing.T) {
9261032 require .Contains (t , err .HowToFix , "milky" )
9271033}
9281034
1035+ func TestIncorrectPathParamArrayInteger (t * testing.T ) {
1036+ items := `items:
1037+ type: integer`
1038+ var n yaml.Node
1039+ _ = yaml .Unmarshal ([]byte (items ), & n )
1040+
1041+ schemaProxy := & lowbase.SchemaProxy {}
1042+ require .NoError (t , schemaProxy .Build (context .Background (), n .Content [0 ], n .Content [0 ], nil ))
1043+
1044+ highSchema := base .NewSchema (schemaProxy .Schema ())
1045+ highSchema .GoLow ().Items .Value .A .Schema ()
1046+
1047+ param := createMockParameter ()
1048+ param .Name = "bubbles"
1049+
1050+ err := IncorrectPathParamArrayInteger (param , "milky" , highSchema , nil )
1051+
1052+ // Validate the error
1053+ require .NotNil (t , err )
1054+ require .Equal (t , helpers .ParameterValidation , err .ValidationType )
1055+ require .Equal (t , helpers .ParameterValidationPath , err .ValidationSubType )
1056+ require .Contains (t , err .Message , "Path array parameter 'bubbles' is not a valid integer" )
1057+ require .Contains (t , err .Reason , "The path parameter (which is an array) 'bubbles' is defined as being an integer" )
1058+ require .Contains (t , err .HowToFix , "milky" )
1059+ }
1060+
9291061func TestIncorrectPathParamArrayBoolean (t * testing.T ) {
9301062 items := `items:
9311063 type: number`
0 commit comments