Skip to content

Commit

Permalink
Fix isNotRequired/required on models
Browse files Browse the repository at this point in the history
  • Loading branch information
casualjim committed Aug 15, 2013
1 parent 1e24558 commit feb6c18
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.12.3
sbt.version=0.12.4
9 changes: 8 additions & 1 deletion src/main/resources/asyncscala/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down
13 changes: 7 additions & 6 deletions src/main/resources/asyncscala/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
3 changes: 1 addition & 2 deletions src/main/scala/com/wordnik/swagger/codegen/Codegen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit feb6c18

Please sign in to comment.