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

#9808 - Dart double cast #9809

Merged
merged 10 commits into from
Dec 15, 2020
Merged

Conversation

MichaelMarner
Copy link
Contributor

@MichaelMarner MichaelMarner commented Oct 28, 2019

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

This PR resolves #9808 by explicitly casting double properties from JSON payloads before assignment. This works around dart's JsonCodec parsing numbers that look like ints to int, which cannot then be assigned directly to a double.

This PR takes advantage of the fact all Dart's number types have a toDouble method. As long as the JSON payload contains a number, calling toDouble is safe.

@ircecho

@MichaelMarner MichaelMarner changed the title Dart double cast #9808 - Dart double cast Oct 28, 2019
@MichaelMarner
Copy link
Contributor Author

Have added a check for null before parsing toDouble to prevent exception being thrown in the case where the data is not present in the json payload.

@MichaelMarner
Copy link
Contributor Author

Hey just wondering the likelihood of this PR being merged, or if there's anything further I can do to get it merged?

@skordesign
Copy link

@MichaelMarner I saw The Travis CI build failed, have you try to solve it?

@MichaelMarner
Copy link
Contributor Author

@skordesign sync'd with master, which made Travis pass. Thanks

@skordesign
Copy link

Any update? Still open?

@sm2017
Copy link

sm2017 commented Dec 14, 2020

Why no one accept the PR?

This was referenced Mar 11, 2021
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.

[Dart] Number decoded to int causes an exception when assigning to double
4 participants