Fix Integer stub value defaulting to String in nodejs-server if format not specified (#4436)

* check if property is a BaseIntegerProperty. This can occur when format is not specified in Swagger definition

* Change coding style to be more consistent
This commit is contained in:
Michael Fulton 2016-12-20 23:08:14 -08:00 committed by wing328
parent ba285759e1
commit d7afb22f1f

View File

@ -3,6 +3,7 @@ package io.swagger.codegen.examples;
import io.swagger.models.Model; import io.swagger.models.Model;
import io.swagger.models.ModelImpl; import io.swagger.models.ModelImpl;
import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.BaseIntegerProperty;
import io.swagger.models.properties.BooleanProperty; import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.DateProperty; import io.swagger.models.properties.DateProperty;
import io.swagger.models.properties.DateTimeProperty; import io.swagger.models.properties.DateTimeProperty;
@ -96,7 +97,7 @@ public class ExampleGenerator {
return "2000-01-23"; return "2000-01-23";
} else if (property instanceof DateTimeProperty) { } else if (property instanceof DateTimeProperty) {
return "2000-01-23T04:56:07.000+00:00"; return "2000-01-23T04:56:07.000+00:00";
} else if (property instanceof DecimalProperty) { } else if (property instanceof DecimalProperty) {
return new BigDecimal(1.3579); return new BigDecimal(1.3579);
} else if (property instanceof DoubleProperty) { } else if (property instanceof DoubleProperty) {
return 3.149; return 3.149;
@ -108,6 +109,9 @@ public class ExampleGenerator {
return 123; return 123;
} else if (property instanceof LongProperty) { } else if (property instanceof LongProperty) {
return 123456789L; return 123456789L;
// Properties that are not Integer or Long may still be BaseInteger
} else if (property instanceof BaseIntegerProperty) {
return 123;
} else if (property instanceof MapProperty) { } else if (property instanceof MapProperty) {
Map<String, Object> mp = new HashMap<String, Object>(); Map<String, Object> mp = new HashMap<String, Object>();
if (property.getName() != null) { if (property.getName() != null) {