OpenAPITools / OpenAPITools/openapi-generator

[BUG] [JAVA] error: too many parameters

Open
#20,019 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

After upgrading from 7.3.0, we started getting error: too many parameters on a generated POJO Model of an object that has 255 fields.
Tracked it down to Java/pojo.mustache)

We've tried manually setting x-java-all-args-constructor: false and x-has-readonly-properties: false, but these result in the same error.
As far as I can tell, x-java-all-args-constructor is respected, but x-has-readonly-properties is superseded by the property being read only itself -- which makes sense (see AbstractJavaCodegen.java).

As such, we're unable to instruct the generator to not add these constructors at all.
I understand this was done to fix an issue with Jackson (see #18870 ), but sadly it brings this issue on the other side.

openapi-generator version

7.9.0

Suggest a fix

Issue: Java/pojo.mustache)
Commit: #18870

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read modules/openapi-generator/src/main/resources/Java/pojo.mustache around lines 102-119 and AbstractJavaCodegen.java around lines 1780-1782, then review #18870 for the Jackson-related change. Reproduce generation for a Java POJO with 255 fields and determine how constructor generation should be controlled. Done means generated code no longer triggers “too many parameters” while retaining the behavior introduced for Jackson.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.