Skip to content

Commit 11d1b8f

Browse files
committed
Merge branch 'master' of github.com:wordnik/swagger-codegen
2 parents 5076d76 + 6f1a4a2 commit 11d1b8f

File tree

7 files changed

+28
-7
lines changed

7 files changed

+28
-7
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name := "swagger-codegen"
77

88
version := "2.0.10-SNAPSHOT"
99

10-
scalaVersion := "2.9.1"
10+
scalaVersion := "2.10.0"
1111

1212
javacOptions ++= Seq("-target", "1.6", "-source", "1.6", "-Xlint:unchecked", "-Xlint:deprecation")
1313

samples/docs/swagger-static-docs/src/main/webapp/assets/js/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,16 @@ function goToAnchor() {
6060
window.scrollTo(0,$('a[name='+anchor+']').offset().top - 80);
6161
}
6262
}
63+
function resize()
64+
{
65+
$(".sidebar").css('height', $(window).height() -60);
66+
$("#content-window").css('height', $(window).height() -60);
6367

68+
}
69+
$(function(){
70+
window.onresize = resize;
71+
resize();
72+
$(window).bind('hashchange', function() {
73+
choose(window.location.href.toString());
74+
});
75+
});

src/main/resources/Java/api.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public class {{classname}} {
4141
{{/requiredParamCount}}
4242

4343
{{#queryParams}}if(!"null".equals(String.valueOf({{paramName}})))
44-
queryParams.put("{{paramName}}", String.valueOf({{paramName}}));
44+
queryParams.put("{{baseName}}", String.valueOf({{paramName}}));
4545
{{/queryParams}}
4646

47-
{{#headerParams}}headerParams.put("{{paramName}}", {{paramName}});
47+
{{#headerParams}}headerParams.put("{{baseName}}", {{paramName}});
4848
{{/headerParams}}
4949

5050
String contentType = "application/json";
@@ -68,4 +68,4 @@ public class {{classname}} {
6868
}
6969
{{/operation}}
7070
}
71-
{{/operations}}
71+
{{/operations}}

src/main/resources/python/swagger.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class ApiClient:
159159
instance = objClass()
160160

161161
for attr, attrType in instance.swaggerTypes.iteritems():
162-
if attr in obj:
162+
if obj is not None and attr in obj and type(obj) in [list, dict]:
163163
value = obj[attr]
164164
if attrType in ['str', 'int', 'long', 'float', 'bool']:
165165
attrType = eval(attrType)

src/main/scala/com/wordnik/swagger/codegen/BasicJavaGenerator.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ class BasicJavaGenerator extends BasicGenerator {
9393
// file suffix
9494
override def fileSuffix = ".java"
9595

96+
override def toVarName(name: String): String = {
97+
val paramName = name.replaceAll("[^a-zA-Z0-9_]","")
98+
super.toVarName(paramName)
99+
}
100+
96101
// response classes
97102
override def processResponseClass(responseClass: String): Option[String] = {
98103
responseClass match {
@@ -209,4 +214,4 @@ class BasicJavaGenerator extends BasicGenerator {
209214
("JsonUtil.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "JsonUtil.java"),
210215
("apiException.mustache", destinationDir + java.io.File.separator + invokerPackage.get.replace(".", java.io.File.separator) + java.io.File.separator, "ApiException.java"),
211216
("pom.mustache", "generated-code/java", "pom.xml"))
212-
}
217+
}

src/main/scala/com/wordnik/swagger/codegen/Codegen.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ class Codegen(config: CodegenConfig) {
209209
val formParams = new ListBuffer[AnyRef]
210210
var paramList = new ListBuffer[HashMap[String, AnyRef]]
211211
var errorList = new ListBuffer[HashMap[String, AnyRef]]
212+
var bodyParamRequired: Option[String] = Some("true")
212213

213214
if (operation.responseMessages != null) {
214215
operation.responseMessages.foreach(param => {
@@ -256,8 +257,9 @@ class Codegen(config: CodegenConfig) {
256257
params += "baseName" -> "body"
257258
param.required match {
258259
case true => params += "required" -> "true"
259-
case _ =>
260+
case _ => bodyParamRequired = None
260261
}
262+
261263
bodyParam = Some("body")
262264
bodyParams += params.clone
263265
}
@@ -353,6 +355,7 @@ class Codegen(config: CodegenConfig) {
353355
"notes" -> operation.notes,
354356
"deprecated" -> operation.`deprecated`,
355357
"bodyParam" -> bodyParam,
358+
"bodyParamRequired" -> bodyParamRequired,
356359
"emptyBodyParam" -> (if (writeMethods contains operation.method.toUpperCase) "{}" else ""),
357360
"allParams" -> sp,
358361
"bodyParams" -> bodyParams.toList,

src/main/scala/com/wordnik/swagger/model/SwaggerModelSerializer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ object SwaggerSerializers {
8787
new ResourceListingSerializer +
8888
new ApiListingSerializer
8989
}
90+
case _ => throw new IllegalArgumentException("%s is not a valid Swagger version".format(version))
9091
}
9192
}
9293

0 commit comments

Comments
 (0)