OpenAPITools / OpenAPITools/openapi-generator

[BUG] [JAVA] Generated classes no longer contain instantiated lists

Open
#4,091 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Some time ago, there was a change so that Java lists are instantiated instead of null:

private List<Foo> foos = new ArrayList<>();

instead of

private List<Foo> foos = null;

This was the change that provided instantiated lists: https://github.com/OpenAPITools/openapi-generator/pull/1683

It worked in version 4.0.0 and 4.1.0, but it no longer works in version 4.1.1 and 4.1.2.

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

Compare generated Java classes from versions 4.1.0 through 4.1.2, focusing on whether list fields are initialized or null. Read the change in pull request 1683 and trace the generator path responsible for Java field declarations. Done means the regression is reproduced, its cause is identified, and generated lists again use the intended initialization with coverage for the affected behavior.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.