[dart-dio][client] Generated code for property that is array type with default value does not compile
See original GitHub issueBug 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?
Description
Support for default values was added in #8201 by @kuhnroyal. Now when array type with default value which is an empty array []
is in the spec, dart code that does not compile is generated:
pets:
type: array
items:
$ref: '#/components/schemas/Pet'
default: []
Error as follows:
A value of type 'List<dynamic>' can't be assigned to a variable of type 'ListBuilder<Pet>'.
Snippet of generated code causing the issue:
@nullable
@BuiltValueField(wireName: r'pets')
BuiltList<Pet> get pets;
static void _initializeBuilder(OrderBuilder b) => b
..pets = [] // <-- line causing error
..complete = false;
openapi-generator version
master
Steps to reproduce
You can reproduce the issue by running the dart-dio generator for this modified petstore example here
Related issues/PRs
#8201 by @kuhnroyal is where the issue appears to be introduced
@swipesight (2018/09) @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Error message. "Props with type Object/Array must use a ...
There was no problem with the performance but I got a console error. [Vue warn]: Invalid default value for prop "multiselectKey": Props with ......
Read more >Is Display the default property value in the class diagram ...
Is it possible to display the default property value ( true in my case) ... it would show up in the diagram but...
Read more >Default Sizes and Values of Arrays - NI - National Instruments
Configuring an Array Control for Use in a VI. An array shell without a data object is undefined and has no data type....
Read more >Features of setting the default value
Note: If the type of default value is not appropriate for the field type, the project will be generated but will not be...
Read more >C# Guide: Automatic Default Values for Variables - Pluralsight
Variable Categories. There are three distinct types of variables that are automatically initialized with a default value based on their type.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kuhnroyal That was the petstore example I just cobbled in the extra bits to see how it would act. I don’t actually need that functionality now, I was just checking to see if it validated.
Haven’t tested yet but it looks like the fixes in your PR cover my case.
@adg-mh Where is this config from that you have there?