Skip to content

[BUG][CPPRestSDK] Generated CPPRestSDK client does not compile in Visual Studio 2017 #6540

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

Closed
2 of 6 tasks
JordiGR-TheBreachStudios opened this issue Jun 4, 2020 · 6 comments · Fixed by #6608
Closed
2 of 6 tasks

Comments

@JordiGR-TheBreachStudios
Copy link

JordiGR-TheBreachStudios commented Jun 4, 2020

Bug Report Checklist

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

The generated CPPRestSDK client for the sample Pet Store does not compile in Visual Studio 2017 (CMake generated Visual Studio solution), with the following error:

2>...\samples\client\petstore\cpp-restsdk\client\ModelBase.cpp(239): error C2664: 'void org::openapitools::client::model::HttpContent::setData(std::shared_ptrstd::istream)': cannot convert argument 1 from 'std::shared_ptr < utility::stringstream_t >' to 'std::shared_ptr < std::istream >'
2>...\samples\client\petstore\cpp-restsdk\client\ModelBase.cpp(239): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

When using the CPPRestSDK library for Windows, in its basic_types.h the type utility::stringstream_t is always defined as an alias for std::wstringstream. However, the generated HttpContent::setData method always takes a std::shared_ptr < std::istream > as parameter, not a std::shared_ptr < std::wistream >

I need help with this. It's a blocker for any CPPRestSDK generated API client for Windows.

openapi-generator version

The client API is already generated in the openapi-generator repository.

OpenAPI declaration file content or url

The client API is already generated in the openapi-generator repository.

Command line used for generation

N/A

Steps to reproduce

Install CPPRestSDK with vcpck, as described in CPPRestSDK
Modify the local CMakeLists.txt file for compilation with vcpkg, as described in the file contents.
Generate the Visual Studio solution with 'cmake -G "Visual Studio 15 2017" < path of the CMakeLists.txt file > ' or 'cmake -G "Visual Studio 15 2017 Win64" < path of the CMakeLists.txt file > '
Open the generated solution and compile

Related issues/PRs

None

Suggest a fix

See the description above.

@JordiGR-TheBreachStudios
Copy link
Author

@Danielku15, you seem to be creator of the CppRestSDK generator, any update on this?
(cc: @wing328, @jimschubert, @cbornet, @ackintosh, @jmini, @etherealjoy, @spacether)

@Danielku15
Copy link
Contributor

Danielku15 commented Jun 9, 2020

I was mainly the very initial contributor of the generator to swagger-codegen. Since then it was taken over by the project maintainers of swagger-codegen and at some point the openapi-generator was founded as a fork.

From an quick look at your description look it seems correct to expect a std::shared_ptr < std::istream >. For files it is needed to have a byte stream for transmission, bytes are nothing but unsigned char or the common define uint8_t.

To me it seems a bug that utility::stringstream_t is used at some point which might result in a unicode string stream and therefore results in a 2-byte (wchar_t) stream instead of a 1-byte stream which is not easily serializable to the underlying network stream.

Digging deeper the bug was introduced as part of the following PR/commit where a lot of things were updated to utlity::string_t and utility::stringstream_t in favor of the old web::json::value and std::stringstream usage

2d6311c
#5222

Maybe @etherealjoy might give his bits to this change 👋😉

@etherealjoy
Copy link
Contributor

Will take a look at this in the coming days.

@JordiGR-TheBreachStudios
Copy link
Author

Thanks for fixing this! Is it applied now if I run the openapi-generator through Docker?

@etherealjoy
Copy link
Contributor

I think the docker images are updated only for released versions. So you would need to wait.
Other way is to compile it yourself or get the snapshot jar and put it on your docker image.

@wing328
Copy link
Member

wing328 commented Jun 12, 2020

We do publish the docker image for the latest master:

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

Successfully merging a pull request may close this issue.

4 participants