From ca9852a318aa7df1ae69d1e14d8cd3d76feb8982 Mon Sep 17 00:00:00 2001 From: Joel Kaasinen Date: Wed, 19 Apr 2023 10:49:23 +0300 Subject: [PATCH] test: multiple named openapi examples --- test/cljc/reitit/openapi_test.clj | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/cljc/reitit/openapi_test.clj b/test/cljc/reitit/openapi_test.clj index 4df3c050..bef17f7c 100644 --- a/test/cljc/reitit/openapi_test.clj +++ b/test/cljc/reitit/openapi_test.clj @@ -455,6 +455,18 @@ :request {:body (->schema :b)}} :responses {200 {:description "success" :body (->schema :ok)}} + :openapi {:requestBody + {:content + {"application/json" + {:examples + {"named-example" {:description "a named example" + :value {:b "named"}}}}}} + :responses + {200 + {:content + {"application/json" + {:examples + {"response-example" {:value {:ok "response"}}}}}}}} :handler identity}}] ["/openapi.json" {:get {:handler (openapi/create-openapi-handler) @@ -479,7 +491,9 @@ :properties {:b {:type "string" :example "EXAMPLE"}} :required ["b"] - :example {:b "EXAMPLE2"}}} + :example {:b "EXAMPLE2"}} + :examples {:named-example {:description "a named example" + :value {:b "named"}}}} (-> spec (get-in [:paths "/examples" :post :requestBody :content "application/json"]) normalize)))) @@ -488,7 +502,8 @@ :properties {:ok {:type "string" :example "EXAMPLE"}} :required ["ok"] - :example {:ok "EXAMPLE2"}}} + :example {:ok "EXAMPLE2"}} + :examples {:response-example {:value {:ok "response"}}}} (-> spec (get-in [:paths "/examples" :post :responses 200 :content "application/json"]) normalize))))