-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Fix dart-dio deserializer generation with json_serializable exception construction #19010
Fix dart-dio deserializer generation with json_serializable exception construction #19010
Conversation
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
cc |
@@ -60,5 +60,5 @@ final _regMap = RegExp(r'^Map<String,(.*)>$'); | |||
} | |||
break; | |||
} | |||
throw Exception('Cannot deserialize'); |
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 looks wrong, do you have a stacktrace for the error?
abstract interface class Exception {
factory Exception([var message]) => _Exception(message);
}
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.
it's a compiler error for when using json serializer with these arguments
-g dart-dio --additional-properties=serializationLibrary=json_serializable
this is the generated exception
@JsonSerializable(
checked: true,
createToJson: true,
disallowUnrecognizedKeys: false,
explicitToJson: true,
)
class Exception {
/// Returns a new [Exception] instance.
Exception({
this.targetSite,
this.message,
this.data,
this.innerException,
this.helpLink,
this.source_,
this.hResult,
this.stackTrace,
});
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.
You seem to have a custom Exception
class/element in your schema that conflicts with the default Exception
class from Dart.
Please rename the element in your schema or follow https://openapi-generator.tech/docs/customization/#name-mapping to map it if you can't change your schema.
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.
interesting, the swashbuckle .net generator does indeed create an Exception definition.
Perhaps the OpenApi exception should be renamed instead, as this seems to be picking up the C# Exception implementation. I'm suprised im the first one to run into this issue.
either way, the change isn't valid you're correct. closing.
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 the Dart SDK Exception
class, we have no way of renaming it.
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 was thinking about using the ApiException, since that's also used throughout the code, except for this instance.
@wing328 This is no valid change. Please close the PR. |
PR checklist
Commit all changed files.
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*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming 7.6.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)