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

[BUG][C++-rest-sdk] Issue when default value is nullptr #3374

Closed
5 of 6 tasks
dan-drl opened this issue Jul 16, 2019 · 2 comments
Closed
5 of 6 tasks

[BUG][C++-rest-sdk] Issue when default value is nullptr #3374

dan-drl opened this issue Jul 16, 2019 · 2 comments

Comments

@dan-drl
Copy link
Contributor

dan-drl commented Jul 16, 2019

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Run time error occurs because default type is set to nullptr. This breaks the fromJSON and toJSON methods in model-source.mustache.

openapi-generator version

4.1.0-SNAPSHOT

OpenAPI declaration file content or url

See test.json: https://gist.github.com/dan-drl/147e962298d1f1467638c00786cd9b6f
See resulting c++: https://gist.github.com/dan-drl/0ec11853c939d5d05ab3c2699238d324

Command line used for generation

java -jar openapi-generator-cli.jar generate -i test.json -g cpp-restsdk -o \src\test

Steps to reproduce

If a JSON containing a "value":null is provided to the AdditionalField model for deserialization, a runtime error occurs because of this:

std::shared_ptr<Object> newValue(nullptr);
newValue->fromJson(val.at(utility::conversions::to_string_t(L"value")));
Related issues/PRs

I didn't find anything.

Suggest a fix

Planning on making a pull request. See this commit, dan-drl@7b42948

@wing328
Copy link
Member

wing328 commented Jul 18, 2019

please provide more details. otherwise, it would be hard for others to help you out.

@dan-drl
Copy link
Contributor Author

dan-drl commented Jul 18, 2019

Sorry, I didn't realize that submitted : / ... Please see revised issue above.

Since the proposed fix, although small, could have a large impact, feedback about the change would be good. I am simply not familiar enough with the code to full understand the the ramifications of a change to the toDefaultValue method.

I am currently waiting to see if anything else comes up as other folks use my patched build. So far, things seem okay though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants