@@ -980,6 +980,27 @@ func TestDecodeBody(t *testing.T) {
980
980
})
981
981
require .NoError (t , err )
982
982
983
+ multipartFormExtraPart , multipartFormMimeExtraPart , err := newTestMultipartForm ([]* testFormPart {
984
+ {name : "a" , contentType : "text/plain" , data : strings .NewReader ("a1" )},
985
+ {name : "x" , contentType : "text/plain" , data : strings .NewReader ("x1" )},
986
+ })
987
+ require .NoError (t , err )
988
+
989
+ multipartAnyAdditionalProps , multipartMimeAnyAdditionalProps , err := newTestMultipartForm ([]* testFormPart {
990
+ {name : "a" , contentType : "text/plain" , data : strings .NewReader ("a1" )},
991
+ {name : "x" , contentType : "text/plain" , data : strings .NewReader ("x1" )},
992
+ })
993
+ multipartAdditionalProps , multipartMimeAdditionalProps , err := newTestMultipartForm ([]* testFormPart {
994
+ {name : "a" , contentType : "text/plain" , data : strings .NewReader ("a1" )},
995
+ {name : "x" , contentType : "text/plain" , data : strings .NewReader ("x1" )},
996
+ })
997
+ multipartAdditionalPropsErr , multipartMimeAdditionalPropsErr , err := newTestMultipartForm ([]* testFormPart {
998
+ {name : "a" , contentType : "text/plain" , data : strings .NewReader ("a1" )},
999
+ {name : "x" , contentType : "text/plain" , data : strings .NewReader ("x1" )},
1000
+ {name : "y" , contentType : "text/plain" , data : strings .NewReader ("y1" )},
1001
+ })
1002
+ require .NoError (t , err )
1003
+
983
1004
testCases := []struct {
984
1005
name string
985
1006
mime string
@@ -1060,6 +1081,45 @@ func TestDecodeBody(t *testing.T) {
1060
1081
WithProperty ("f" , openapi3 .NewStringSchema ().WithFormat ("binary" )),
1061
1082
want : map [string ]interface {}{"a" : "a1" , "b" : float64 (10 ), "c" : []interface {}{"c1" , "c2" }, "d" : map [string ]interface {}{"d1" : "d1" }, "f" : "foo" },
1062
1083
},
1084
+ {
1085
+ name : "multipartExtraPart" ,
1086
+ mime : multipartFormMimeExtraPart ,
1087
+ body : multipartFormExtraPart ,
1088
+ schema : openapi3 .NewObjectSchema ().
1089
+ WithProperty ("a" , openapi3 .NewStringSchema ()),
1090
+ want : map [string ]interface {}{"a" : "a1" },
1091
+ wantErr : & ParseError {Kind : KindOther },
1092
+ },
1093
+ {
1094
+ name : "multipartAnyAdditionalProperties" ,
1095
+ mime : multipartMimeAnyAdditionalProps ,
1096
+ body : multipartAnyAdditionalProps ,
1097
+ schema : openapi3 .NewObjectSchema ().
1098
+ WithAnyAdditionalProperties ().
1099
+ WithProperty ("a" , openapi3 .NewStringSchema ()),
1100
+ want : map [string ]interface {}{"a" : "a1" },
1101
+ },
1102
+ {
1103
+ name : "multipartWithAdditionalProperties" ,
1104
+ mime : multipartMimeAdditionalProps ,
1105
+ body : multipartAdditionalProps ,
1106
+ schema : openapi3 .NewObjectSchema ().
1107
+ WithAdditionalProperties (openapi3 .NewObjectSchema ().
1108
+ WithProperty ("x" , openapi3 .NewStringSchema ())).
1109
+ WithProperty ("a" , openapi3 .NewStringSchema ()),
1110
+ want : map [string ]interface {}{"a" : "a1" , "x" : "x1" },
1111
+ },
1112
+ {
1113
+ name : "multipartWithAdditionalPropertiesError" ,
1114
+ mime : multipartMimeAdditionalPropsErr ,
1115
+ body : multipartAdditionalPropsErr ,
1116
+ schema : openapi3 .NewObjectSchema ().
1117
+ WithAdditionalProperties (openapi3 .NewObjectSchema ().
1118
+ WithProperty ("x" , openapi3 .NewStringSchema ())).
1119
+ WithProperty ("a" , openapi3 .NewStringSchema ()),
1120
+ want : map [string ]interface {}{"a" : "a1" , "x" : "x1" },
1121
+ wantErr : & ParseError {Kind : KindOther },
1122
+ },
1063
1123
{
1064
1124
name : "file" ,
1065
1125
mime : "application/octet-stream" ,
0 commit comments