OpenAPITools / OpenAPITools/openapi-generator
How to stop open API from initialising list variables in java
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
openapi version 3.0.2
I'm using the below Yaml for our code generation
Order:
type: "object"
properties:
LineItems:
type: "array"
items:
type: "string"
Pricing:
type: "array"
items:
type: "string"
While generating the pojo, lists are getting initialized to null.
private List<String> LineItems = null;
What should I do if I don't want a list to be initialsed at all?
example: What I need is
private List<String> LineItems;
What I don't want is
private List<String> LineItems = null;
or
private List<String> LineItems = new ArrayList();
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 with the OpenAPI 3.0.2 YAML and the generated Java POJO shown in the issue. Identify the generator option or template controlling list-field initialization, then verify that generated fields are declarations without either null or ArrayList assignments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, yaml
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100