From fd560f4dc1ad74e0a6ceee2c29120bffda506a32 Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Tue, 10 Feb 2015 13:55:19 +0000 Subject: [PATCH] Scala api.mustache: allow easy basePath and ApiInvoker override Gets rid of the smelly vars inside Scala api.mustache allowing the override of default basePath and ApiInvoker on the constructor. Previously the code for overriding was: val myApi = new MyApi() myApi.basePath = "http://myapi.endpoint.com" myApi.apiInvoker = new ApiInvoker(authScheme = "SPNEGO") after the change everything can be simply declared in the constructor: val myApi = new MyApi("http://myapi.endpoint.com", new ApiInvoker(authScheme = "SPNEGO")) --- .../swagger-codegen/src/main/resources/scala/api.mustache | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/scala/api.mustache b/modules/swagger-codegen/src/main/resources/scala/api.mustache index 7c05406a5a8..87b47446140 100644 --- a/modules/swagger-codegen/src/main/resources/scala/api.mustache +++ b/modules/swagger-codegen/src/main/resources/scala/api.mustache @@ -11,10 +11,9 @@ import java.util.Date import scala.collection.mutable.HashMap {{#operations}} -class {{classname}} { - var basePath: String = "{{basePath}}" - var apiInvoker = ApiInvoker - +class {{classname}}(val basePath: String = "{{basePath}}", + apiInvoker: ApiInvoker = ApiInvoker) { + def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value {{#operation}}