Merge remote-tracking branch 'upstream/master' into fix-no-content

Conflicts:
	samples/client/petstore/java/src/main/java/com/wordnik/client/ApiInvoker.java
This commit is contained in:
Andrew Young
2013-12-02 13:42:15 -08:00
17 changed files with 91 additions and 20 deletions

View File

@@ -10,6 +10,12 @@ public class {{classname}} {
{{#description}}/* {{{description}}} */
{{/description}}
private {{{datatype}}} {{name}} = {{{defaultValue}}};
{{#allowableValues}}{{#min}} // range from {{min}} to {{max}}
{{/min}}
//{{^min}}public enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };
{{/min}}
{{/allowableValues}}
{{/vars}}
{{#vars}}

View File

@@ -188,6 +188,19 @@ class Codegen(config: CodegenConfig) {
(srcName, engine -> template)
}
def rawAllowableValuesToString(v: AllowableValues) = {
v match {
case av: AllowableListValues => {
av
}
case av: AllowableRangeValues => {
av
}
case _ => None
}
}
def allowableValuesToString(v: AllowableValues) = {
v match {
case av: AllowableListValues => {
@@ -306,6 +319,11 @@ class Codegen(config: CodegenConfig) {
case _ => requiredParams.last.asInstanceOf[HashMap[String, String]] -= "hasMore"
}
headerParams.size match {
case 0 =>
case _ => headerParams.last.asInstanceOf[HashMap[String, String]] -= "hasMore"
}
queryParams.size match {
case 0 =>
case _ => queryParams.last.asInstanceOf[HashMap[String, String]] -= "hasMore"
@@ -466,6 +484,7 @@ class Codegen(config: CodegenConfig) {
"defaultValue" -> config.toDeclaration(propertyDocSchema)._2,
"description" -> propertyDocSchema.description,
"notes" -> propertyDocSchema.description,
"allowableValues" -> rawAllowableValuesToString(propertyDocSchema.allowableValues),
(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),

View File

@@ -347,10 +347,16 @@ object SwaggerSerializers {
else {
val min = (json \ "min") match {
case e: JObject => e.extract[String]
case e: JString => e.s
case e: JInt => e.num.toString
case e: JDouble => e.num.toString
case _ => ""
}
val max = (json \ "max") match {
case e: JObject => e.extract[String]
case e: JString => e.s
case e: JInt => e.num.toString
case e: JDouble => e.num.toString
case _ => ""
}
if(min != "" && max != "")