OpenAPITools / OpenAPITools/openapi-generator
[BUG] OpenAPI failed to initialized variables while generating the code
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
Here is my spec file
Portfolios:
allOf:
- $ref: '#/components/schemas/DlCollection'
- type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/Portfolio'
Open API 6.6.0 version generating code like below
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
public class Portfolios extends DlCollection implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("items")
@Valid
private List<Portfolio> items = null;
My expectation is
@JsonProperty("items")
@Valid
private List<Portfolio> items = new ArrayList<>();
Is there any fix or workaround for this?
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
Start by reproducing Java SpringCodegen output with the supplied OpenAPI schema on version 6.6.0, then trace the generator path that initializes the Portfolios.items field. Compare the generated null initialization with the expected ArrayList initialization; done means the generated field uses the expected default without regressing related schemas.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100