Merge branch 'master' of github.com:wordnik/swagger-codegen

This commit is contained in:
Tony Tam 2013-10-18 14:46:21 -07:00
commit 11d1b8fcd4
7 changed files with 28 additions and 7 deletions

View File

@ -7,7 +7,7 @@ name := "swagger-codegen"
version := "2.0.10-SNAPSHOT"
scalaVersion := "2.9.1"
scalaVersion := "2.10.0"
javacOptions ++= Seq("-target", "1.6", "-source", "1.6", "-Xlint:unchecked", "-Xlint:deprecation")

View File

@ -60,4 +60,16 @@ function goToAnchor() {
window.scrollTo(0,$('a[name='+anchor+']').offset().top - 80);
}
}
function resize()
{
$(".sidebar").css('height', $(window).height() -60);
$("#content-window").css('height', $(window).height() -60);
}
$(function(){
window.onresize = resize;
resize();
$(window).bind('hashchange', function() {
choose(window.location.href.toString());
});
});

View File

@ -41,10 +41,10 @@ public class {{classname}} {
{{/requiredParamCount}}
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
queryParams.put("{{paramName}}", String.valueOf({{paramName}}));
queryParams.put("{{baseName}}", String.valueOf({{paramName}}));
{{/queryParams}}
{{#headerParams}}headerParams.put("{{paramName}}", {{paramName}});
{{#headerParams}}headerParams.put("{{baseName}}", {{paramName}});
{{/headerParams}}
String contentType = "application/json";
@ -68,4 +68,4 @@ public class {{classname}} {
}
{{/operation}}
}
{{/operations}}
{{/operations}}

View File

@ -159,7 +159,7 @@ class ApiClient:
instance = objClass()
for attr, attrType in instance.swaggerTypes.iteritems():
if attr in obj:
if obj is not None and attr in obj and type(obj) in [list, dict]:
value = obj[attr]
if attrType in ['str', 'int', 'long', 'float', 'bool']:
attrType = eval(attrType)

View File

@ -93,6 +93,11 @@ class BasicJavaGenerator extends BasicGenerator {
// file suffix
override def fileSuffix = ".java"
override def toVarName(name: String): String = {
val paramName = name.replaceAll("[^a-zA-Z0-9_]","")
super.toVarName(paramName)
}
// response classes
override def processResponseClass(responseClass: String): Option[String] = {
responseClass match {
@ -209,4 +214,4 @@ class BasicJavaGenerator extends BasicGenerator {
("JsonUtil.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "JsonUtil.java"),
("apiException.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "ApiException.java"),
("pom.mustache", "generated-code/java", "pom.xml"))
}
}

View File

@ -209,6 +209,7 @@ class Codegen(config: CodegenConfig) {
val formParams = new ListBuffer[AnyRef]
var paramList = new ListBuffer[HashMap[String, AnyRef]]
var errorList = new ListBuffer[HashMap[String, AnyRef]]
var bodyParamRequired: Option[String] = Some("true")
if (operation.responseMessages != null) {
operation.responseMessages.foreach(param => {
@ -256,8 +257,9 @@ class Codegen(config: CodegenConfig) {
params += "baseName" -> "body"
param.required match {
case true => params += "required" -> "true"
case _ =>
case _ => bodyParamRequired = None
}
bodyParam = Some("body")
bodyParams += params.clone
}
@ -353,6 +355,7 @@ class Codegen(config: CodegenConfig) {
"notes" -> operation.notes,
"deprecated" -> operation.`deprecated`,
"bodyParam" -> bodyParam,
"bodyParamRequired" -> bodyParamRequired,
"emptyBodyParam" -> (if (writeMethods contains operation.method.toUpperCase) "{}" else ""),
"allParams" -> sp,
"bodyParams" -> bodyParams.toList,

View File

@ -87,6 +87,7 @@ object SwaggerSerializers {
new ResourceListingSerializer +
new ApiListingSerializer
}
case _ => throw new IllegalArgumentException("%s is not a valid Swagger version".format(version))
}
}