@@ -367,6 +367,25 @@ func createMockLowBaseSchemaForNumberArray() *lowbase.Schema {
367
367
return itemsSchema
368
368
}
369
369
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
+
370
389
func TestIncorrectQueryParamArrayNumber (t * testing.T ) {
371
390
// Create mock parameter and schemas
372
391
param := createMockParameterForNumberArray ()
@@ -568,6 +587,22 @@ func TestInvalidQueryParamNumber(t *testing.T) {
568
587
require .Contains (t , err .HowToFix , "notNumber" )
569
588
}
570
589
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
+
571
606
func TestIncorrectQueryParamEnum (t * testing.T ) {
572
607
enum := `enum: [fish, crab, lobster]`
573
608
var n yaml.Node
@@ -645,6 +680,29 @@ func TestIncorrectReservedValues(t *testing.T) {
645
680
require .Contains (t , err .HowToFix , "borked%3A%3A%3F%5E%26%2A" )
646
681
}
647
682
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
+
648
706
func TestInvalidHeaderParamNumber (t * testing.T ) {
649
707
enum := `name: blip`
650
708
var n yaml.Node
@@ -691,6 +749,29 @@ func TestInvalidCookieParamNumber(t *testing.T) {
691
749
require .Contains (t , err .HowToFix , "milky" )
692
750
}
693
751
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
+
694
775
func TestIncorrectHeaderParamBool (t * testing.T ) {
695
776
enum := `name: blip`
696
777
var n yaml.Node
@@ -900,6 +981,31 @@ func TestIncorrectPathParamNumber(t *testing.T) {
900
981
require .Contains (t , err .HowToFix , "milky" )
901
982
}
902
983
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
+
903
1009
func TestIncorrectPathParamArrayNumber (t * testing.T ) {
904
1010
items := `items:
905
1011
type: number`
@@ -926,6 +1032,32 @@ func TestIncorrectPathParamArrayNumber(t *testing.T) {
926
1032
require .Contains (t , err .HowToFix , "milky" )
927
1033
}
928
1034
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
+
929
1061
func TestIncorrectPathParamArrayBoolean (t * testing.T ) {
930
1062
items := `items:
931
1063
type: number`
0 commit comments