From 9ae3cd0824c0e3e6e851e9bbe9060a1b3d6258f3 Mon Sep 17 00:00:00 2001 From: Joel Kaasinen Date: Wed, 8 Mar 2023 14:11:28 +0200 Subject: [PATCH] fix: reitit.openapi route data validation :kind set? would've worked, but there's no need to insist a set also, turn on route data validation in openapi_test.clj --- modules/reitit-openapi/src/reitit/openapi.cljc | 2 +- test/cljc/reitit/openapi_test.clj | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/reitit-openapi/src/reitit/openapi.cljc b/modules/reitit-openapi/src/reitit/openapi.cljc index 6b1a465e..0328ce43 100644 --- a/modules/reitit-openapi/src/reitit/openapi.cljc +++ b/modules/reitit-openapi/src/reitit/openapi.cljc @@ -9,7 +9,7 @@ (s/def ::id (s/or :keyword keyword? :set (s/coll-of keyword? :into #{}))) (s/def ::no-doc boolean?) -(s/def ::tags (s/coll-of (s/or :keyword keyword? :string string?) :kind #{})) +(s/def ::tags (s/coll-of (s/or :keyword keyword? :string string?))) (s/def ::summary string?) (s/def ::description string?) diff --git a/test/cljc/reitit/openapi_test.clj b/test/cljc/reitit/openapi_test.clj index 8f950c89..a1c944d2 100644 --- a/test/cljc/reitit/openapi_test.clj +++ b/test/cljc/reitit/openapi_test.clj @@ -10,6 +10,7 @@ [reitit.coercion.spec :as spec] [reitit.openapi :as openapi] [reitit.ring :as ring] + [reitit.ring.spec] [reitit.ring.coercion :as rrc] [reitit.swagger-ui :as swagger-ui] [schema.core :as s] @@ -117,7 +118,8 @@ xs :body} :parameters}] {:status 200, :body {:total (+ (reduce + xs) z)}})}}]]] - {:data {:middleware [openapi/openapi-feature + {:validate reitit.ring.spec/validate + :data {:middleware [openapi/openapi-feature rrc/coerce-exceptions-middleware rrc/coerce-request-middleware rrc/coerce-response-middleware]}}))) @@ -379,7 +381,8 @@ ["/openapi.json" {:get {:handler (openapi/create-openapi-handler) :openapi {:info {:title "" :version "0.0.1"}} - :no-doc true}}]])) + :no-doc true}}]] + {:data {:middleware [openapi/openapi-feature]}})) spec (-> {:request-method :get :uri "/openapi.json"} app @@ -446,7 +449,9 @@ {:get {:handler (openapi/create-openapi-handler) :openapi {:info {:title "" :version "0.0.1"}} :no-doc true}}]] - {:data {:middleware [rrc/coerce-request-middleware + {:validate reitit.ring.spec/validate + :data {:middleware [openapi/openapi-feature + rrc/coerce-request-middleware rrc/coerce-response-middleware]}})) spec (-> {:request-method :get :uri "/openapi.json"} @@ -531,7 +536,9 @@ {:get {:handler (openapi/create-openapi-handler) :openapi {:info {:title "" :version "0.0.1"}} :no-doc true}}]] - {:data {:middleware [rrc/coerce-request-middleware + {:validate reitit.ring.spec/validate + :data {:middleware [openapi/openapi-feature + rrc/coerce-request-middleware rrc/coerce-response-middleware]}})) spec (-> {:request-method :get :uri "/openapi.json"}