forked from loafle/openapi-generator-original
generate boolean getter method according to a code convention (#6169)
This commit is contained in:
parent
b683d6a335
commit
5223c80c6d
@ -1660,6 +1660,7 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
if (p instanceof BooleanProperty) {
|
if (p instanceof BooleanProperty) {
|
||||||
property.isBoolean = true;
|
property.isBoolean = true;
|
||||||
|
property.getter = "is" + getterAndSetterCapitalize(name);
|
||||||
}
|
}
|
||||||
if (p instanceof BinaryProperty) {
|
if (p instanceof BinaryProperty) {
|
||||||
property.isBinary = true;
|
property.isBinary = true;
|
||||||
|
@ -4,6 +4,7 @@ import io.swagger.codegen.CodegenProperty;
|
|||||||
import io.swagger.codegen.DefaultCodegen;
|
import io.swagger.codegen.DefaultCodegen;
|
||||||
import io.swagger.codegen.languages.StaticDocCodegen;
|
import io.swagger.codegen.languages.StaticDocCodegen;
|
||||||
import io.swagger.models.properties.ArrayProperty;
|
import io.swagger.models.properties.ArrayProperty;
|
||||||
|
import io.swagger.models.properties.BooleanProperty;
|
||||||
import io.swagger.models.properties.RefProperty;
|
import io.swagger.models.properties.RefProperty;
|
||||||
import io.swagger.models.properties.StringProperty;
|
import io.swagger.models.properties.StringProperty;
|
||||||
|
|
||||||
@ -26,6 +27,21 @@ public class StaticOperationTest {
|
|||||||
Assert.assertTrue(cp.isNotContainer);
|
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")
|
@Test(description = "convert a complex parameter")
|
||||||
public void complexParameterTest() {
|
public void complexParameterTest() {
|
||||||
final RefProperty property = new RefProperty("Children");
|
final RefProperty property = new RefProperty("Children");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user