OpenAPITools / OpenAPITools/openapi-generator
[BUG][DART] Non-required non-nullable field is always assigned null value if value not present
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Dart generator always insert null for non-required non-nullable field if a value is not provided. However, it seems not the specified behaviour.
openapi-generator version
7.5.0
OpenAPI declaration file content or url
UpdateUser:
type: object
required: []
properties:
name:
type: string
example: testName
nullable: false
(...)
Generation Details
java -jar openapi-generator-cli.jar generate -i {input filename} -g dart -o {output directory name}
Steps to reproduce
Generate output with the above code snippet
Related issues/PRs
Suggest a fix
This PR comment should point out the issue. Non-required, non-nullable field should not by default assign a null value which should be contradictory to how JSON schema treats non-required field.
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 the issue with the UpdateUser OpenAPI declaration and the documented java -jar openapi-generator-cli.jar generate ... -g dart command, then inspect the Dart generator entry point and its generated model output. Done means a non-required, non-nullable field is not assigned null when the value is absent, with regression coverage added in the generator's existing test area.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100