Skip to content

Commit 27bec6f

Browse files
committed
use FileBodyDecoder if the format is specified as binary
1 parent 90fb641 commit 27bec6f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

openapi3filter/req_resp_decoder.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,8 +1246,17 @@ func decodeBody(body io.Reader, header http.Header, schema *openapi3.SchemaRef,
12461246
contentType = "text/plain"
12471247
}
12481248
}
1249+
12491250
mediaType := parseMediaType(contentType)
1250-
decoder, ok := bodyDecoders[mediaType]
1251+
var decoder BodyDecoder
1252+
var ok bool
1253+
if schema.Value.Format == "binary" {
1254+
ok = true
1255+
decoder = FileBodyDecoder
1256+
} else {
1257+
decoder, ok = bodyDecoders[mediaType]
1258+
}
1259+
12511260
if !ok {
12521261
return "", nil, &ParseError{
12531262
Kind: KindUnsupportedFormat,

0 commit comments

Comments
 (0)