OpenAPITools / OpenAPITools/openapi-generator
[BUG] [dart] How to correctly define an object reference that can be null in the generated code
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
Generated code contains
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
UrlPreview? urlPreview;
which actually should be nullable. But I couldn't find a way how to define a property with a reference schema that can be null, so that this note disappears
this is the json spec
"PostMetaData": {
"title": "PostMetaData",
"x-stoplight": {
"id": "wjwait32lwf1r"
},
"type": "object",
"properties": {
"url_preview": {
"$ref": "#/components/schemas/UrlPreview",
}
}
}
how do I correctly specify a property that is optional and should be nullable in the generated Dart code?
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 generated Dart property and the PostMetaData schema shown in the issue, then trace how the generator handles nullable properties that use $ref. Verify the OpenAPI specification syntax and generated output. Done means an optional UrlPreview reference is generated as nullable without the explanatory warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100