From d7e374504fbca67d23b99c9f3a27d1f2f727f12a Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrai Date: Fri, 18 May 2018 06:22:02 +0300 Subject: [PATCH] [Clojure] Add util method to set the api-context globally (#93) --- .../src/main/resources/clojure/core.mustache | 5 +++++ .../client/petstore/clojure/src/open_api_petstore/core.clj | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/clojure/core.mustache b/modules/openapi-generator/src/main/resources/clojure/core.mustache index d55442603ae..4506eab9f22 100644 --- a/modules/openapi-generator/src/main/resources/clojure/core.mustache +++ b/modules/openapi-generator/src/main/resources/clojure/core.mustache @@ -24,6 +24,11 @@ "Dynamic API context to be applied in API calls." default-api-context) +(defn set-api-context + "Set the *api-context* globally" + [new-context] + (alter-var-root #'*api-context* (constantly (merge *api-context* new-context)))) + (defmacro with-api-context "A helper macro to wrap *api-context* with default values." [api-context & body] diff --git a/samples/client/petstore/clojure/src/open_api_petstore/core.clj b/samples/client/petstore/clojure/src/open_api_petstore/core.clj index 8dae9bb0f81..28993e8b0d6 100644 --- a/samples/client/petstore/clojure/src/open_api_petstore/core.clj +++ b/samples/client/petstore/clojure/src/open_api_petstore/core.clj @@ -24,6 +24,11 @@ "Dynamic API context to be applied in API calls." default-api-context) +(defn set-api-context + "Set the *api-context* globally" + [new-context] + (alter-var-root #'*api-context* (constantly (merge *api-context* new-context)))) + (defmacro with-api-context "A helper macro to wrap *api-context* with default values." [api-context & body]