@@ -105,21 +105,13 @@ const RequestBody = ({
105
105
}
106
106
requestBodyErrors = List . isList ( requestBodyErrors ) ? requestBodyErrors : List ( )
107
107
108
- if ( ! mediaTypeValue . size ) {
109
- return null
110
- }
111
-
112
- const isObjectContent = mediaTypeValue . getIn ( [ "schema" , "type" ] ) === "object"
113
- const isBinaryFormat = mediaTypeValue . getIn ( [ "schema" , "format" ] ) === "binary"
114
- const isBase64Format = mediaTypeValue . getIn ( [ "schema" , "format" ] ) === "base64"
108
+ const isFileUploadIntended = fn . isFileUploadIntended (
109
+ mediaTypeValue ?. get ( "schema" ) ,
110
+ contentType
111
+ )
115
112
116
113
if (
117
- contentType === "application/octet-stream"
118
- || contentType . indexOf ( "image/" ) === 0
119
- || contentType . indexOf ( "audio/" ) === 0
120
- || contentType . indexOf ( "video/" ) === 0
121
- || isBinaryFormat
122
- || isBase64Format
114
+ isFileUploadIntended
123
115
) {
124
116
const Input = getComponent ( "Input" )
125
117
@@ -132,6 +124,13 @@ const RequestBody = ({
132
124
return < Input type = { "file" } onChange = { handleFile } />
133
125
}
134
126
127
+
128
+ if ( ! mediaTypeValue . size ) {
129
+ return null
130
+ }
131
+
132
+ const isObjectContent = fn . hasSchemaType ( mediaTypeValue . get ( "schema" ) , "object" )
133
+
135
134
if (
136
135
isObjectContent &&
137
136
(
@@ -190,11 +189,11 @@ const RequestBody = ({
190
189
initialValue = JSON . parse ( initialValue )
191
190
}
192
191
193
- const isFile = type === "string" && ( format === "binary" || format === "base64" )
192
+ const isFileUploadIntended = fn . isFileUploadIntended ( schema )
194
193
195
194
const jsonSchemaForm = < JsonSchemaForm
196
195
fn = { fn }
197
- dispatchInitialValue = { ! isFile }
196
+ dispatchInitialValue = { ! isFileUploadIntended }
198
197
schema = { schema }
199
198
description = { key }
200
199
getComponent = { getComponent }
0 commit comments