From 79e46c6e0c82c33d69122e54900b56502850a1f3 Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrai Date: Fri, 18 May 2018 00:39:03 +0300 Subject: [PATCH] [Clojure] Add util method to set the api-context globally --- .../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 d55442603ae0..4506eab9f225 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 8dae9bb0f81b..28993e8b0d68 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]