swagger-api / swagger-api/swagger-codegen
How to generate Java model constructor including all fields in a POJO class?
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
By default, only an empty constructor is generated, which leads to a rather tedious way of manually dealing with objects.
Here's an example (example is in kotlin, but I'd like to find out how to generate all parameter constructors in Java only)
val request = PojoRequest()
request.txnid = "txnid"
val customer = Customer()
customer.id = "customer_id"
request.customer = customer
I'd instead prefer that the following was generated
val request = PojoRequest("txnId", Customer("customer_id"))
Is this possible?
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
No source file, test, or generator entry point is identified in the issue. Start by finding the Java POJO generation path; done means establishing whether an all-fields constructor can be generated and recording the supported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100