@@ -1649,6 +1649,18 @@ func TestDecodeBody(t *testing.T) {
16491649 })
16501650 require .NoError (t , err )
16511651
1652+ multipartBinaryEncodingCT , multipartMimeBinaryEncodingCT , err := newTestMultipartForm ([]* testFormPart {
1653+ {name : "b" , contentType : "application/json" , data : strings .NewReader (`{"bar1": "bar1"}` ), filename : "b1" },
1654+ {name : "d" , contentType : "application/pdf" , data : strings .NewReader ("doo1" ), filename : "d1" },
1655+ {name : "f" , contentType : "application/json" , data : strings .NewReader (`{"foo1": "foo1"}` ), filename : "f1" },
1656+ {name : "f" , contentType : "application/pdf" , data : strings .NewReader ("foo2" ), filename : "f2" },
1657+ })
1658+
1659+ multipartBinaryEncodingCTUnsupported , multipartMimeBinaryEncodingCTUnsupported , err := newTestMultipartForm ([]* testFormPart {
1660+ {name : "b" , contentType : "application/json" , data : strings .NewReader (`{"bar1": "bar1"}` ), filename : "b1" },
1661+ {name : "d" , contentType : "application/pdf" , data : strings .NewReader ("doo1" ), filename : "d1" },
1662+ })
1663+
16521664 testCases := []struct {
16531665 name string
16541666 mime string
@@ -1787,6 +1799,39 @@ func TestDecodeBody(t *testing.T) {
17871799 body : strings .NewReader ("foo" ),
17881800 want : "foo" ,
17891801 },
1802+ {
1803+ name : "multipartEncodingCT" ,
1804+ mime : multipartMimeBinaryEncodingCT ,
1805+ body : multipartBinaryEncodingCT ,
1806+ schema : openapi3 .NewObjectSchema ().
1807+ WithProperty ("b" , openapi3 .NewStringSchema ().WithFormat ("binary" )).
1808+ WithProperty ("d" , openapi3 .NewStringSchema ().WithFormat ("binary" )).
1809+ WithProperty ("f" , openapi3 .NewArraySchema ().WithItems (
1810+ openapi3 .NewStringSchema ().WithFormat ("binary" ),
1811+ )),
1812+ want : map [string ]any {"b" : `{"bar1": "bar1"}` , "d" : "doo1" , "f" : []any {`{"foo1": "foo1"}` , "foo2" }},
1813+ },
1814+ {
1815+ name : "multipartEncodingCTUnsupported" ,
1816+ mime : multipartMimeBinaryEncodingCTUnsupported ,
1817+ body : multipartBinaryEncodingCTUnsupported ,
1818+ schema : openapi3 .NewObjectSchema ().
1819+ WithProperty ("b" , openapi3 .NewStringSchema ().WithFormat ("binary" )).
1820+ WithProperty ("d" , openapi3 .NewStringSchema ().WithFormat ("binary" )),
1821+ encoding : map [string ]* openapi3.Encoding {
1822+ "b" : {ContentType : "application/json" },
1823+ "d" : {ContentType : "application/pdf" },
1824+ },
1825+ want : map [string ]any {"b" : map [string ]any {"bar1" : "bar1" }},
1826+ wantErr : & ParseError {
1827+ Kind : KindOther ,
1828+ Cause : & ParseError {
1829+ Kind : KindUnsupportedFormat ,
1830+ Reason : fmt .Sprintf ("%s %q" , prefixUnsupportedCT , "application/pdf" ),
1831+ },
1832+ path : []any {"d" },
1833+ },
1834+ },
17901835 }
17911836 for _ , tc := range testCases {
17921837 t .Run (tc .name , func (t * testing.T ) {
0 commit comments