diff --git a/project/build.properties b/project/build.properties index db255c253720..f069b101c246 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.12.3 \ No newline at end of file +sbt.version=0.12.4 \ No newline at end of file diff --git a/src/main/resources/asyncscala/api.mustache b/src/main/resources/asyncscala/api.mustache index 1f92c30b96c6..d6f296b9a746 100644 --- a/src/main/resources/asyncscala/api.mustache +++ b/src/main/resources/asyncscala/api.mustache @@ -11,7 +11,14 @@ import collection.mutable class {{classname}}(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { {{#operation}} - def {{nickname}}({{#allParams}}{{paramName}}: {{dataType}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}: Future[{{returnType}}]{{/returnType}}{{^returnType}}: Future[Unit]{{/returnType}} = { + + def {{nickname}}({{#allParams}} + {{#optional}} + {{paramName}}: Option[{{dataType}}] = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{#hasMore}}, {{/hasMore}} + {{/optional}} + {{^optional}} + {{paramName}}: {{dataType}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#hasMore}}, {{/hasMore}} + {{/optional}}{{/allParams}}){{#returnType}}: Future[{{returnType}}]{{/returnType}}{{^returnType}}: Future[Unit]{{/returnType}} = { // create path and map variables val path = ("{{path}}" diff --git a/src/main/resources/asyncscala/model.mustache b/src/main/resources/asyncscala/model.mustache index 7b23910ae3f6..23bfd4839223 100644 --- a/src/main/resources/asyncscala/model.mustache +++ b/src/main/resources/asyncscala/model.mustache @@ -2,16 +2,17 @@ package {{package}} import org.joda.time.DateTime +{{#imports}}import {{import}} +{{/imports}} + {{#models}} {{#model}} - -case class {{className}} ( +case class {{classname}} ( {{#vars}} - {{#description}}/* {{{description}}} */ - {{/description}} - {{name}}: {{datatype}}{{#hasMore}},{{newline}} {{/hasMore}} - {{/vars}}) + {{name}}: {{#isNotRequired}}Option[{{/isNotRequired}}{{datatype}}{{#isNotRequired}}]{{/isNotRequired}} {{#hasMore}},{{/hasMore}}{{#description}} // {{description}}{{/description}}{{newline}} + {{/vars}} +) {{/model}} {{/models}} \ No newline at end of file diff --git a/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala b/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala index b93c3b0c9d5c..ac245e777e31 100644 --- a/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala +++ b/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala @@ -442,8 +442,7 @@ class Codegen(config: CodegenConfig) { "defaultValue" -> config.toDeclaration(propertyDocSchema)._2, "description" -> propertyDocSchema.description, "notes" -> propertyDocSchema.description, - "required" -> propertyDocSchema.required.toString, - "isNotRequired" -> (!propertyDocSchema.required).toString, + (if(propertyDocSchema.required) "required" else "isNotRequired") -> "true", "getter" -> config.toGetter(prop._1, config.toDeclaration(propertyDocSchema)._1), "setter" -> config.toSetter(prop._1, config.toDeclaration(propertyDocSchema)._1), "isList" -> isList, diff --git a/src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala b/src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala index b98ddba10392..a90c3021f0d4 100644 --- a/src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala +++ b/src/main/scala/com/wordnik/swagger/codegen/ScalaAsyncClientGenerator.scala @@ -95,10 +95,7 @@ object ScalaAsyncClientGenerator extends App { if (!r.startsWith("http") && !r.startsWith("file")) sys.props("fileMap") = r r } - val baseUrl = { - val r = opts.baseUrl() - if (r == null || r.trim.isEmpty) None else Some(r) - } + val baseUrl = opts.baseUrl.get val cfg = SwaggerGenConfig( api = SwaggerApi(opts.name(), resUrl, opts.`package`(), apiKey = opts.apiKey.get, baseUrl = baseUrl), templateDir = new File(opts.templateDir()),