swagger-api / swagger-api/swagger-codegen
Wrong getter for Boolean Object
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The Swagger Codegen produces wrong getter methods for Boolean. It uses a Boolean Object and the getter isMyProperty() which cannot be used in JSF applications.
This behaviour has changed in comparison to version 2.2.3 of the swagger-codegen.
Swagger-codegen version
2.3.1
Swagger declaration file content or url
properties:
active:
type: boolean
Command line used for generation
Using the maven plugin
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<!--<version>2.2.3</version>-->
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/swagger.json</inputSpec>
<language>java</language>
<modelPackage>modelPacakge</modelPackage>
<apiPackage>apiPackage</apiPackage>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModelDocumentation>false</generateModelDocumentation>
<generateModelTests>false</generateModelTests>
<configOptions>
<dateLibrary>java8-localdatetime</dateLibrary>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
Generate the Java Model using a Boolean attribute.
Related issues/PRs
Suggest a fix/enhancement
The Generator produces Boolean objects and not types, which is fine.
For Boolean Objects the getter should by getMyProperty, the setter setMyProperty()
In the example above is should produce
public Boolean getActive(){
...
}
and
public void setActive(Boolean boolValue){
...
}
If the Generator would produce boolean types, then the getter isMyPropery() and setMyProperty() is fine.
public boolean isActive(){
...
}
and
public void setActive(boolean boolValue){
...
}
The generated getter() for the Boolan object cannot be used in JSF Applications, since it expects proper getter() and setter() for Objects. The prefix is is only possible for primitive type boolean.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce Java model generation from the provided YAML boolean property using the swagger-codegen Maven plugin. Inspect the Java model-generation templates or entry points that choose getter names, then verify that a Boolean object produces getActive() and setActive(Boolean), rather than isActive().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100