-
Notifications
You must be signed in to change notification settings - Fork 9.1k
/
Copy pathfn.js
40 lines (32 loc) · 974 Bytes
/
fn.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @prettier
*/
import { Map } from "immutable"
import isPlainObject from "lodash/isPlainObject"
export const makeIsFileUploadIntended = (getSystem) => {
const isFileUploadIntended = (schema, mediaType = null) => {
const { fn } = getSystem()
const isFileUploadIntendedOAS30 = fn.isFileUploadIntendedOAS30(
schema,
mediaType
)
if (isFileUploadIntendedOAS30) {
return true
}
const isSchemaImmutable = Map.isMap(schema)
if (!isSchemaImmutable && !isPlainObject(schema)) {
return false
}
const contentMediaType = isSchemaImmutable
? schema.get("contentMediaType")
: schema.contentMediaType
const contentEncoding = isSchemaImmutable
? schema.get("contentEncoding")
: schema.contentEncoding
return (
(contentMediaType && typeof contentMediaType === "string") ||
(contentEncoding && typeof contentEncoding === "string")
)
}
return isFileUploadIntended
}