OpenAPITools / OpenAPITools/openapi-generator

While generating Java models from OpenAPI spec (v5.4.0) using openapi-generator-maven-plugin, the Maps in java class are initialized by default to null. How do we prevent this?

Open
#12,241 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

In OpenAPI v5.4.0 a generated line is

private Map<String, String> extension = null;

In OpenAPI v4.0.3 this line used to be

private Map<String, String> extension = new HashMap();

What is it that has changed and can we go back to what used to happen while using v5.4.0?

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 openapi-generator-maven-plugin and the generated Java model output; begin by reproducing the result with v5.4.0 and comparing it with v4.0.3. Then inspect the generator configuration and templates or options related to map initialization. Done when the requested non-null initialization is restored through a documented configuration or confirmed generator change.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, backend
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.