From 63092b89237be6577895848230db1976c5a5af48 Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 9 Dec 2015 22:55:49 +0800 Subject: [PATCH] Clojure client: use case-insensitive checking on JSON MIME --- .../src/main/resources/clojure/core.mustache | 2 +- .../client/petstore/clojure/src/swagger_petstore/core.clj | 2 +- .../petstore/clojure/test/swagger_petstore/core_test.clj | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/clojure/core.mustache b/modules/swagger-codegen/src/main/resources/clojure/core.mustache index 79d0ee9b5e..0da2a45149 100644 --- a/modules/swagger-codegen/src/main/resources/clojure/core.mustache +++ b/modules/swagger-codegen/src/main/resources/clojure/core.mustache @@ -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, diff --git a/samples/client/petstore/clojure/src/swagger_petstore/core.clj b/samples/client/petstore/clojure/src/swagger_petstore/core.clj index 4c8a842696..665adfbc77 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/core.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/core.clj @@ -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, diff --git a/samples/client/petstore/clojure/test/swagger_petstore/core_test.clj b/samples/client/petstore/clojure/test/swagger_petstore/core_test.clj index 27a9e1db29..87ac0a8b73 100644 --- a/samples/client/petstore/clojure/test/swagger_petstore/core_test.clj +++ b/samples/client/petstore/clojure/test/swagger_petstore/core_test.clj @@ -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")) \ No newline at end of file + "plain text" "text/plain" "plain text"))