mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
Clojure client: use case-insensitive checking on JSON MIME
This commit is contained in:
parent
7642314b20
commit
63092b8923
@ -174,7 +174,7 @@
|
||||
[mime]
|
||||
(if mime
|
||||
(or (= :json mime)
|
||||
(re-matches #"application/json(;.*)?" (name mime)))))
|
||||
(re-matches #"(?i)application/json(;.*)?" (name mime)))))
|
||||
|
||||
(defn json-preferred-mime
|
||||
"Choose a MIME from the given MIMEs with JSON preferred,
|
||||
|
@ -174,7 +174,7 @@
|
||||
[mime]
|
||||
(if mime
|
||||
(or (= :json mime)
|
||||
(re-matches #"application/json(;.*)?" (name mime)))))
|
||||
(re-matches #"(?i)application/json(;.*)?" (name mime)))))
|
||||
|
||||
(defn json-preferred-mime
|
||||
"Choose a MIME from the given MIMEs with JSON preferred,
|
||||
|
@ -151,10 +151,12 @@
|
||||
(is (= expected (boolean (json-mime? mime))))
|
||||
:json true
|
||||
"application/json" true
|
||||
"APPLICATION/JSON" true
|
||||
"application/json; charset=utf8" true
|
||||
nil false
|
||||
:xml false
|
||||
"application/pdf" false))
|
||||
"application/pdf" false
|
||||
"application/jsonp" false))
|
||||
|
||||
(deftest test-json-preferred-mime
|
||||
(are [mimes expected]
|
||||
@ -177,4 +179,4 @@
|
||||
"{\"aa\": 1, \"bb\": \"2\"}" "application/json" {:aa 1 :bb "2"}
|
||||
"[1, \"2\"]" "application/json; charset=UTF8" [1 "2"]
|
||||
"{invalid json}" "application/json" "{invalid json}"
|
||||
"plain text" "text/plain" "plain text"))
|
||||
"plain text" "text/plain" "plain text"))
|
||||
|
Loading…
Reference in New Issue
Block a user