OpenAPITools / OpenAPITools/openapi-generator
[dart-dio] non-nullable model fields defined as nullable in generated dart
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Using the example spec here the following snippet is generated
/// Outer
///
/// Properties:
/// * [results]
@BuiltValue()
abstract class Outer implements Built<Outer, OuterBuilder> {
@BuiltValueField(wireName: r'results')
BuiltList<int>? get results;
Outer._();
factory Outer([void updates(OuterBuilder b)]) = _$Outer;
@BuiltValueHook(initializeBuilder: true)
static void _defaults(OuterBuilder b) => b..results = ListBuilder();
@BuiltValueSerializer(custom: true)
static Serializer<Outer> get serializer => _$OuterSerializer();
}
When results is non-nullable I expect the type to be BuiltList<int> instead of BuiltList<int>?.
On this line you can see the template reads {{^isNullable}}{{^required}}?{{/required}}{{/isNullable}}, which seems backwards for the isNullable check.
Spec used to demonstrate issue is here
openapi-generator version: commit 031f0dcee692264681387bf8fbbece98f477801b (master as of now)
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 modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/class_members.mustache and compare its nullable and required conditionals with the reported output. Generate the Dart model from the linked example spec, then verify that the non-nullable results field is emitted as BuiltList rather than BuiltList?.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100