-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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][dart-dio] Nullable support/improvements #8235
[dart][dart-dio] Nullable support/improvements #8235
Conversation
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
@josh-burton Would really like your input on this. |
31126fb
to
96cd974
Compare
* prevent further name conflicts by correctly naming the enum, until now there could potentially occur conflicts e.g. 2x `MapTestInnerEnum` by renaming the `items` child property * correctly set `enumName` to match `datatypeWithEnum`
This is not in line with the OAS and will prevent future Dart nullabilty features (NNBD) from being useful as all types would be optional. Users can still opt-in for this.
* properties in built_value need to be nullable when they are nullable in OAS or when they are not required in OAS * built_value does not support serializing `null` values by default as it is based on a serialization format based on iterables/lists and not maps * dart-dio uses the built_value json plugin to convert the built_value format to regular json * by generating a custom serializer for each class we can add support for serializing `null` values if the property is required AND nullable in OAS * this is a breaking change as not all properties in the models are nullable by default anymore
96cd974
to
f4768f4
Compare
@agilob Please check it out, serialization for the normal Dart generator is a mess so I am not so sure |
@@ -1,5 +1,6 @@ | |||
# RELEASE_VERSION | |||
openApiGeneratorVersion=5.0.1-SNAPSHOT | |||
openApiGeneratorVersion=5.1.0-SNAPSHOT | |||
>>>>>>> origin/master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge conflict message here
@@ -4,7 +4,7 @@ | |||
<groupId>org.openapitools</groupId> | |||
<artifactId>openapi-generator-project</artifactId> | |||
<!-- RELEASE_VERSION --> | |||
<version>5.0.1-SNAPSHOT</version> | |||
<version>5.1.0-SNAPSHOT</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think version bump should go in a separate PR, but leaving this to @wing328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong target branch
@@ -1,14 +1,14 @@ | |||
{{#description}}/// {{{description}}}{{/description}} | |||
class {{{classname}}}{{{enumName}}} { | |||
class {{{enumName}}} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a big breaking change for no big benefit, enum serialisation still won't be as good as in other languages. I think it's time to give up on doing this in openapi and use a more popular 3rd party library do it for us. I'm only familiar with json_serializable but it doesn't handle standalone enums so can't use it here. I'll look around soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually part of #8220 but required for this to work.
Yea, wrong target and the enum branch this is based up on has already been discussed. |
dart-dio/built_value
Disable all fields nullable by default:
This is not in line with OAS and will prevent future Dart nullabilty features (NNBD) from being useful as all types would be optional.
Properties are
@nullable
when not required AND not nullableSupport nullable/required fields in JSON
@nullable
when they are nullable in OAS or when they are not required in OASnull
values by default as it is based on a serialization format based on iterables/lists and not mapsnull
values if the property is required AND nullable in OASDart
null
when the field is required and nullableThis is based on #8220 which needs to be merged first.
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