generate boolean getter method according to a code convention (#6169)

This commit is contained in:
Mykola Yashchenko 2017-07-25 18:43:56 +03:00 committed by wing328
parent b683d6a335
commit 5223c80c6d
2 changed files with 17 additions and 0 deletions

View File

@ -1660,6 +1660,7 @@ public class DefaultCodegen {
}
if (p instanceof BooleanProperty) {
property.isBoolean = true;
property.getter = "is" + getterAndSetterCapitalize(name);
}
if (p instanceof BinaryProperty) {
property.isBinary = true;

View File

@ -4,6 +4,7 @@ import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.languages.StaticDocCodegen;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.RefProperty;
import io.swagger.models.properties.StringProperty;
@ -26,6 +27,21 @@ public class StaticOperationTest {
Assert.assertTrue(cp.isNotContainer);
}
@Test(description = "convert a boolean parameter")
public void booleanParameterTest() {
final BooleanProperty property = new BooleanProperty();
final DefaultCodegen codegen = new StaticDocCodegen();
final CodegenProperty cp = codegen.fromProperty("property", property);
Assert.assertEquals(cp.baseName, "property");
Assert.assertEquals(cp.datatype, "Boolean");
Assert.assertEquals(cp.name, "property");
Assert.assertEquals(cp.baseType, "boolean");
Assert.assertTrue(cp.isNotContainer);
Assert.assertTrue(cp.isBoolean);
Assert.assertEquals(cp.getter, "isProperty");
}
@Test(description = "convert a complex parameter")
public void complexParameterTest() {
final RefProperty property = new RefProperty("Children");