OpenAPITools / OpenAPITools/openapi-generator

[BUG] AbstractJavaCodegen unable to customize "set" type

Open
#13,549 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

Extending JavaClientCodegen with

    // import/interface type
    typeMapping().put("set", typeMapping().get("array"));
    // concrete type
    instantiationTypes().put("set", instantiationTypes().get("array"));

and generating schema with arrays with uniqueItems=true sometimes results in compilation error due to missing "ArrayList" import.

openapi-generator version

6.2.0, regression since 5.0.0 (could be even earlier for types other than "set")

OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

Use type mappings for "set" everywhere in AbstractJavaCodegen imports.
https://github.com/OpenAPITools/openapi-generator/pull/13550

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

Inspect import handling in AbstractJavaCodegen and compare how typeMapping() and instantiationTypes() are used for "set" versus "array" when extending JavaClientCodegen. Reproduce generation for an array schema with uniqueItems=true using the described mappings, then verify that the generated Java compiles without a missing ArrayList import. The suggested fix is linked in PR #13550.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.