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" 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") 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); 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}} {{/requiredParamCount}}
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}}))) {{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
queryParams.put("{{paramName}}", String.valueOf({{paramName}})); queryParams.put("{{baseName}}", String.valueOf({{paramName}}));
{{/queryParams}} {{/queryParams}}
{{#headerParams}}headerParams.put("{{paramName}}", {{paramName}}); {{#headerParams}}headerParams.put("{{baseName}}", {{paramName}});
{{/headerParams}} {{/headerParams}}
String contentType = "application/json"; String contentType = "application/json";

View File

@ -159,7 +159,7 @@ class ApiClient:
instance = objClass() instance = objClass()
for attr, attrType in instance.swaggerTypes.iteritems(): 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] value = obj[attr]
if attrType in ['str', 'int', 'long', 'float', 'bool']: if attrType in ['str', 'int', 'long', 'float', 'bool']:
attrType = eval(attrType) attrType = eval(attrType)

View File

@ -93,6 +93,11 @@ class BasicJavaGenerator extends BasicGenerator {
// file suffix // file suffix
override def fileSuffix = ".java" override def fileSuffix = ".java"
override def toVarName(name: String): String = {
val paramName = name.replaceAll("[^a-zA-Z0-9_]","")
super.toVarName(paramName)
}
// response classes // response classes
override def processResponseClass(responseClass: String): Option[String] = { override def processResponseClass(responseClass: String): Option[String] = {
responseClass match { responseClass match {

View File

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

View File

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