swagger-api / swagger-api/swagger-codegen

`containerDefaultToNull` behavior

Open
#12,542 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

when set containerDefaultToNull to false. eg data

data will init as new ArrayList<>().

but when we set data as null in request

{
     "data": null
}
public void setData(List<@Size(min = 1, max = 64)String> data) {
        this.data = data;
    }

data was override to null.

epxected as empty array,should be follow example

public void setData(List<@Size(min = 1, max = 64)String> data) {
      if(data== null){
          return;
      }
        this.data = data;
    }

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

The issue names no repository file or test; start by locating the Java model template and the handling of containerDefaultToNull, then reproduce generation with a nullable data list. Done means generated setters preserve the initialized empty list when the request supplies null while still assigning non-null values.

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.