added check, fix for #1103

This commit is contained in:
Tony Tam 2015-08-21 15:02:56 -07:00
parent b68beefa69
commit 44b4af0374
2 changed files with 17 additions and 2 deletions

View File

@ -636,8 +636,10 @@ public class DefaultCodegen {
if (np.getMaximum() != null) {
allowableValues.put("max", np.getMaximum());
}
if(allowableValues.size() > 0) {
property.allowableValues = allowableValues;
}
}
if (p instanceof StringProperty) {
StringProperty sp = (StringProperty) p;

View File

@ -2,6 +2,7 @@ package Java
import io.swagger.codegen.languages.JavaClientCodegen
import io.swagger.models._
import io.swagger.models.parameters._
import io.swagger.models.properties._
import io.swagger.util.Json
import org.junit.runner.RunWith
@ -382,7 +383,6 @@ class JavaModelTest2 extends FlatSpec with Matchers {
cm.vars.size should be(1)
val vars = cm.vars
Json.prettyPrint(vars.get(0))
vars.get(0).baseName should be("_")
vars.get(0).getter should be("getU")
vars.get(0).setter should be("setU")
@ -393,4 +393,17 @@ class JavaModelTest2 extends FlatSpec with Matchers {
vars.get(0).hasMore should equal(null)
vars.get(0).isNotContainer should equal(true)
}
it should "convert a parameter" in {
val parameter = new QueryParameter()
.property(
new IntegerProperty())
.name("limit")
.required(true)
val codegen = new JavaClientCodegen()
val cp = codegen.fromParameter(parameter, null)
cp.allowableValues should be (null)
}
}