-
-
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
[BUG] ModelBase.cpp fromJson method for int64 types always returns 0, regardless of JSON value #8450
Closed
5 tasks done
Labels
Comments
Thanks for putting this together Diana. If the maintainer/developer investigating this ticket needs additional info, we could likely put together a throwaway Docker script + container to execute the build + run operations that yield the behaviors noted in the report above. I believe I already have a template for that which I use for VIM bug reports. |
shayan-eftekhari
added a commit
to aimms/openapi-generator
that referenced
this issue
Aug 31, 2021
shayan-eftekhari
added a commit
to aimms/openapi-generator
that referenced
this issue
Aug 31, 2021
shayan-eftekhari
added a commit
to aimms/openapi-generator
that referenced
this issue
Aug 31, 2021
shayan-eftekhari
added a commit
to aimms/openapi-generator
that referenced
this issue
Aug 31, 2021
This reverts commit 7d8f842.
shayan-eftekhari
added a commit
to aimms/openapi-generator
that referenced
this issue
Aug 31, 2021
5 tasks
wing328
pushed a commit
that referenced
this issue
Sep 9, 2021
…t&) bug which incorrectly returns zero (#10300) * BUG FIX: A missing semicolon in cpp-pistache-server generated code. * BUG FIX: Provide default values of schema in cpp-pistache-server generated code. * BUG FIX: Provide default values of schema in cpp-pistache-server generated code. * Fix a bug in cpprest-sdk generator (Issue #8450) * Fix a bug in cpprest-sdk generator (Issue #8450) * Fix a bug in cpprest-sdk generator (Issue #8450) * Revert "Fix a bug in cpprest-sdk generator (Issue #8450)" This reverts commit 7d8f842. * Fix a bug in cpprest-sdk generator (Issue #8450)
wing328
pushed a commit
that referenced
this issue
Oct 13, 2021
…ead of 1/0 (#10554) * BUG FIX: A missing semicolon in cpp-pistache-server generated code. * BUG FIX: Provide default values of schema in cpp-pistache-server generated code. * BUG FIX: Provide default values of schema in cpp-pistache-server generated code. * Fix a bug in cpprest-sdk generator (Issue #8450) * Fix a bug in cpprest-sdk generator (Issue #8450) * Fix a bug in cpprest-sdk generator (Issue #8450) * Revert "Fix a bug in cpprest-sdk generator (Issue #8450)" This reverts commit 7d8f842. * Fix a bug in cpprest-sdk generator (Issue #8450) * A new overloaded version of parameterToString method is added to the ApiClient class (mustache file) of cpp-rest-sdk-client generator. This new overload accepts bool value and is added to serialize bool values as boolapha instead of integer representation. * A new overloaded version of parameterToString method is added to the ApiClient class (mustache file) of cpp-rest-sdk-client generator. This new overload accepts bool value and is added to serialize bool values as boolapha instead of integer representation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report Checklist
Description
Hello!
I am attempting to determine if I have found a bug in the openapi-generator for cpprestsdk or if there's just a bug in my project (i.e. JSON or API spec).
I used the openapi-generator to generate cpprest code from a JSON definition given as input. The JSON definition is linked below. My definition uses int64 numbers and the generated
bool ModelBase::fromJson( const web::json::value& val, int64_t & outVal )
implementation in ModelBase.cpp always returns 0, regardless of the JSON value.openapi-generator version
I have used openapi-generator-cli-5.0.0-beta3.jar when I found the bug, but I tested with the latest from master, as well, using the following:
The bug can still be reproduced with the list of generators above.
OpenAPI declaration file content or url
The test.json file used as input to the openapi-generator
Generation Details
This is the code generated for the
bool ModelBase::fromJson( const web::json::value& val, int64_t & outVal )
method, from ModelBase.cpp:The line that generates the bug seems to be
outVal = !val.is_null() ? std::numeric_limits<int64_t>::quiet_NaN() : val.as_number().to_int64();
specifically the condition by which the value is assigned:
!val.is_null()
.This number will never be null, therefore the condition will always be true and the assigned value
std::numeric_limits<int64_t>::quiet_NaN()
(which, in my case, is 0).Steps to reproduce
You need to have cpprestsdk and Java installed on your machine.
Suggest a fix
Looking through similar code generated for other data types(such as int32, float, double), I think the condition should be
!val.is_number()
, because 'number' is the data type that is being used to convert from to int64:Thank you!
The text was updated successfully, but these errors were encountered: