-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Dart][Client] Fix default value of enum variables #7496
Conversation
Merge master
Merge master
Hi, this is slightly offtopic, but do you have any array of enums in your scheme? It seems to be completely broken currently, instead of |
@szotp I don't think I have that issue |
@lchwe can you try to merge the latest master of the official repo into this branch to see if that fixes the CI failures? I wanted to do it for you but don't have the right to modify your branch. |
@wing328 nice, all green now! |
@lchwe I did a test manually with a top-level enum definition in the spec and here is what I got (partial code): part of openapi.api;
class ModelStatus {
/// The underlying value of this enum member.
final String value;
const ModelStatus._internal(this.value);
/// pet status in the store
static const ModelStatus available_ = ModelStatus._internal("available");
/// pet status in the store
static const ModelStatus pending_ = ModelStatus._internal("pending");
/// pet status in the store
static const ModelStatus sold_ = ModelStatus._internal("sold");
static List<ModelStatus> get values => const [
available_,
pending_,
sold_,
]; Are those |
@wing328 , weird. It should not be |
@wing328 thanks for the help btw! |
Agreed triple curly braces should not result in those HTML-escaped output. Likely a mistake in my end when testing the change. |
Classes that have enums properties with a default required value are initialized with a String value, rather than using the enum values, so the dart client fails to compile unless this is manually fixed.
For example, I get the following generated:
AppointmentStatusEnum status = "open";
while I should be getting instead:
AppointmentStatusEnum status = AppointmentStatusEnum._internal("open");
PR checklist
./bin/generate-samples.sh
to update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH.master
@ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @athornz (2019/12) @amondnet (2019/12)