Description
When generating a model from a swagger file with
myProperty:
type: boolean
the generated model file will contain
@JsonProperty("myProperty")
private Boolean myProperty= null;
@ApiModelProperty()
public Boolean isMyProperty() {
return myProperty;
}
public void setMyProperty(Boolean myProperty) {
this.myProperty= myProperty;
}
The problematic line is the following:
public Boolean isMyProperty() {
since the JavaBeans Specification - section 8.3.2 states that
In addition, for boolean properties, we allow a getter method to match the pattern:
public boolean is<PropertyName>();
This “is” method may be provided instead of a “get” method,
or it may be provided in addition to a “get” method.
And in the example above, the isMyProperty() method is generated for a non-primitive Boolean property, which should not be the case.
First, this is a breaking change that was introduced with 2.3.0, which could easily have been avoided by adding the isMyProperty() in addition to a getMyProperty() method.
Second, some bean property mappers may not recognized the property as a readable attribute, e.g.
in the Spring BeanWrapper: https://jira.spring.io/browse/SPR-9482
This change was introduced in #6177
Swagger-codegen version
affected: 2.3.0
type: regression, used to work in 2.2.3
Related issues/PRs
#6177
Suggest a fix/enhancement
I suggest to have the isMyProperty() method in addition to the getMyProperty() method instead of replacing it.
Description
When generating a model from a swagger file with
the generated model file will contain
The problematic line is the following:
since the JavaBeans Specification - section 8.3.2 states that
And in the example above, the
isMyProperty()method is generated for a non-primitiveBooleanproperty, which should not be the case.First, this is a breaking change that was introduced with
2.3.0, which could easily have been avoided by adding theisMyProperty()in addition to agetMyProperty()method.Second, some bean property mappers may not recognized the property as a readable attribute, e.g.
in the Spring BeanWrapper: https://jira.spring.io/browse/SPR-9482
This change was introduced in #6177
Swagger-codegen version
affected: 2.3.0
type: regression, used to work in 2.2.3
Related issues/PRs
#6177
Suggest a fix/enhancement
I suggest to have the
isMyProperty()method in addition to thegetMyProperty()method instead of replacing it.