Skip to content
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

Closed

Conversation

kewur
Copy link

@kewur kewur commented Jun 24, 2024

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.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    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.
  • File the PR against the correct branch: master (upcoming 7.6.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@kewur
Copy link
Author

kewur commented Jul 1, 2024

@ahmednfwela

@wing328
Copy link
Member

wing328 commented Jul 2, 2024

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.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@wing328
Copy link
Member

wing328 commented Jul 2, 2024

cc
@jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)

@@ -60,5 +60,5 @@ final _regMap = RegExp(r'^Map<String,(.*)>$');
}
break;
}
throw Exception('Cannot deserialize');
Copy link
Contributor

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);
}

Copy link
Author

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,
  });

Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

@kuhnroyal kuhnroyal Jul 2, 2024

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.

Copy link
Author

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.

@kuhnroyal
Copy link
Contributor

@wing328 This is no valid change. Please close the PR.

@kewur kewur closed this Jul 2, 2024
@kewur kewur deleted the dart_deserializer_correct_constructor branch July 2, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants