swagger-api / swagger-api/swagger-codegen
[JAVA] Not possible to disable builder pattern in models
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When we generate the Java client of the defined API, the model comes with a builder pattern that makes no possible to access attributes on Freemarker without using the full getter method name. It forces us to use ${item.getId()} instead of ${item.id} or change the generated code, which is not an option in a project where the model must be generated many times.
Swagger-codegen version
2.3.1
Command line used for generation
Maven plugin configuration:
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/docs/api.yaml</inputSpec>
<language>java</language>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
<dateLibrary>legacy</dateLibrary>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Suggest a fix/enhancement
A configuration option to disable builder generation
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
Start by tracing the Java model generation path used by the swagger-codegen Maven plugin and reviewing how generator configuration options reach the model templates. Confirm how builder methods are currently emitted and identify the existing generation tests. Done means a configuration option can disable builders while preserving the default behavior and is covered by generation tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100