Skip to content

Commit 18dbae6

Browse files
committed
refactor: explicitly check for empty string and add a comment
1 parent ceecfed commit 18dbae6

File tree

1 file changed

+8
-2
lines changed
  • src/core/plugins/oas31/oas3-extensions

1 file changed

+8
-2
lines changed

src/core/plugins/oas31/oas3-extensions/fn.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ export const makeIsFileUploadIntended = (getSystem) => {
88
const isFileUploadIntended = (schema, mediaType = null) => {
99
const { fn } = getSystem()
1010

11+
/**
12+
* Return `true` early if the media type indicates a file upload
13+
* or if a combination of type: `string` and format: `binary/byte` is detected.
14+
* This ensures support for empty Media Type Objects,
15+
* as the schema check is performed later.
16+
*/
1117
const isFileUploadIntendedOAS30 = fn.isFileUploadIntendedOAS30(
1218
schema,
1319
mediaType
@@ -31,8 +37,8 @@ export const makeIsFileUploadIntended = (getSystem) => {
3137
: schema.contentEncoding
3238

3339
return (
34-
(contentMediaType && typeof contentMediaType === "string") ||
35-
(contentEncoding && typeof contentEncoding === "string")
40+
(typeof contentMediaType === "string" && contentMediaType !== "") ||
41+
(typeof contentEncoding === "string" && contentEncoding !== "")
3642
)
3743
}
3844

0 commit comments

Comments
 (0)