Skip to content

Conversation

@kuhnroyal
Copy link
Contributor

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto 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.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

CC @swipesight (2018/09) @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12)

* correctly generate enums from `mostInnerItems`
* use `datatypeWithEnum` which should always be he correct type
* dart generators prefix inner enums with the classname of the containing class, ensure datatypeWithEnum always matches
@auto-labeler
Copy link

auto-labeler bot commented Dec 13, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

const EnumArraysArrayEnumEnum._(this.value);

/// The underlying value of this enum member.
final List<String> value;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agilob This commit also fixes the wrong value type that was appearrent in the other PR.

{{/allowableValues}}
{{/isContainer}}
{{/isEnum}}
{{{datatypeWithEnum}}} {{{name}}};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about all of this change, especially the enum default value. Currently all default values are set in the constructor. As far as I can tell in that case a wrong constructor default value would be generated.

Copy link
Contributor

@agilob agilob Dec 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the default value should stay as null, unless field is marked as non-nullable, required or has default value provided, this looks good to me. Dart generator doesn't support non-nullable so it's fine. It will get more complex.

@agilob
Copy link
Contributor

agilob commented Dec 13, 2020

Took me long time to understand from class name whether this is correct or not... Do we need ...EnumEnum? Do we need to append every enum class with Enum? Kind of excessive.

dart.dev doesn't recommend it https://dart.dev/guides/language/language-tour#enumerated-types

No other generator does it. It was even difficult to reverse engineer to find original spec from the names.

@kuhnroyal
Copy link
Contributor Author

The EnumEnum is just happening because the model/property name already ends with Enum.
Appending Enum is done in DefaultCodegen and some generators do their own modifications but it is that way in several languages: https://github.com/OpenAPITools/openapi-generator/blob/master/samples/openapi3/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumArrays.java

This is already this way in the dart generator and has always been. (hence no changes to dart output, only dart-dio)

I am not particularly fond of the naming, I was actually thinking about removing it. Removing it will be a breaking change in the dart generator instead of dart-dio. Would be good to get some some more opinions on this.

@wing328 wing328 added this to the 5.0.0 milestone Dec 14, 2020
@wing328 wing328 merged commit e412145 into OpenAPITools:master Dec 14, 2020
@kuhnroyal kuhnroyal deleted the dart/enum-inner-types branch December 15, 2020 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants