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

Cpp boost beast client #12197

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

LukasWoodtli
Copy link
Contributor

C++ Boost Beast client code generator

Generated example code is committed under the samples directory and integration tests are also available there.

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/utils/export_docs_generators.sh
    
    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*.
    For Windows users, please run the script in Git BASH.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

I'm happy to get some feedback
@ravinikam
@stkrwork
@etherealjoy
@MartinDelille
@muttleyxd

@wing328
Copy link
Member

wing328 commented Apr 22, 2022

@LukasWoodtli thanks for the PR. I got build errors as follows:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.0:compile (default-compile) on project openapi-generator: Compilation failure: Compilation failure: 
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java:[99,85] cannot find symbol
[ERROR]   symbol:   variable Object
[ERROR]   location: class org.openapitools.codegen.meta.features.DataTypeFeature
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppBoostBeastClientCodegen.java:[110,32] name clash: updateAllModels(java.util.Map<java.lang.String,java.lang.Object>) in org.openapitools.codegen.languages.CppBoostBeastClientCodegen and updateAllModels(java.util.Map<java.lang.String,org.openapitools.codegen.model.ModelsMap>) in org.openapitools.codegen.DefaultCodegen have the same erasure, yet neither overrides the other
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppBoostBeastClientCodegen.java:[109,5] method does not override or implement a method from a supertype
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppBoostBeastClientCodegen.java:[112,60] incompatible types: java.util.Map<java.lang.String,java.lang.Object> cannot be converted to java.util.Map<java.lang.String,org.openapitools.codegen.model.ModelsMap>
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppBoostBeastClientCodegen.java:[130,38] incompatible types: java.util.Map<java.lang.String,java.lang.Object> cannot be converted to java.util.Map<java.lang.String,org.openapitools.codegen.model.ModelsMap>
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppBoostBeastClientCodegen.java:[221,5] method does not override or implement a method from a supertype
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java:[116,40] cannot find symbol
[ERROR]   symbol:   variable Null
[ERROR]   location: class org.openapitools.codegen.meta.features.DataTypeFeature
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java:[117,40] cannot find symbol
[ERROR]   symbol:   variable AnyType
[ERROR]   location: class org.openapitools.codegen.meta.features.DataTypeFeature
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java:[118,40] cannot find symbol
[ERROR]   symbol:   variable Uuid
[ERROR]   location: class org.openapitools.codegen.meta.features.DataTypeFeature
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java:[102,45] cannot find symbol
[ERROR]   symbol:   variable allOf
[ERROR]   location: class org.openapitools.codegen.meta.features.SchemaSupportFeature
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java:[103,45] cannot find symbol
[ERROR]   symbol:   variable anyOf
[ERROR]   location: class org.openapitools.codegen.meta.features.SchemaSupportFeature
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java:[104,45] cannot find symbol
[ERROR]   symbol:   variable oneOf
[ERROR]   location: class org.openapitools.codegen.meta.features.SchemaSupportFeature
[ERROR] /Users/williamcheng/Code/openapi-generator5/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java:[105,45] cannot find symbol
[ERROR]   symbol:   variable not
[ERROR]   location: class org.openapitools.codegen.meta.features.SchemaSupportFeature
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :openapi-generator

Can you please take a look when you've time? Maybe merge the latest master into your branch?

@wing328 wing328 added this to the 6.0.0 milestone Apr 22, 2022
@LukasWoodtli LukasWoodtli force-pushed the cpp-boost-beast-client branch 3 times, most recently from 396598e to 91b6c8b Compare April 22, 2022 09:14
@LukasWoodtli
Copy link
Contributor Author

So finally I managed to pass all test

@wing328
Copy link
Member

wing328 commented Apr 22, 2022

Thanks. Let me test it out over the weekend.

@LukasWoodtli
Copy link
Contributor Author

I look forward to getting some feedback.
But no hurry. I’m off next week. So I won’t be able to work on some improvements.

@wing328
Copy link
Member

wing328 commented Apr 25, 2022

UPDATE: Tried to test it in the Travis CI but got

CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.18 or higher is required.  You are running version 3.12.4
-- Configuring incomplete, errors occurred!
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (pet-test) on project CppBoostBeastPetstoreClientTests: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (pet-test) on project CppBoostBeastPetstoreClientTests: Command execution failed.

Ref: https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds/249795681

looks like we need to update cmake to a newer version in the CI

I'll try to test it locally for the time being.

@LukasWoodtli
Copy link
Contributor Author

Made some fixes.
I'm looking for feedback!

@wing328
Copy link
Member

wing328 commented May 3, 2022

I tried to test it in a linux box but got the following errors:

[ 20%] Building CXX object generated/CMakeFiles/client.dir/model/Tag.cpp.o
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
[ 25%] Building CXX object generated/CMakeFiles/client.dir/model/User.cpp.o
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
[ 29%] Building CXX object generated/CMakeFiles/client.dir/api/PetApi.cpp.o
/home/wing328/Code/openapi-generator/samples/client/petstore/cpp-boost-beast/generated/api/PetApi.cpp: In function 'std::string org::openapitools::client::api::{anonymous}::base64encodeImpl(const string&)':
/home/wing328/Code/openapi-generator/samples/client/petstore/cpp-boost-beast/generated/api/PetApi.cpp:68:49: error: cannot convert 'const string' {aka 'const std::__cxx11::basic_string<char>'} to 'void*'
   68 |     return boost::beast::detail::base64::encode(str);
      |                                                 ^~~
      |                                                 |
      |                                                 const string {aka const std::__cxx11::basic_string<char>}
In file included from /usr/include/boost/beast/core/detail/base64.hpp:85,
                 from /home/wing328/Code/openapi-generator/samples/client/petstore/cpp-boost-beast/generated/api/PetApi.cpp:24:
/usr/include/boost/beast/core/detail/base64.ipp:103:14: note:   initializing argument 1 of 'std::size_t boost::beast::detail::base64::encode(void*, const void*, std::size_t)'
  103 | encode(void* dest, void const* src, std::size_t len)
      |        ~~~~~~^~~~
make[2]: *** [generated/CMakeFiles/client.dir/build.make:141: generated/CMakeFiles/client.dir/api/PetApi.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:154: generated/CMakeFiles/client.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Can you please take a look when you've time?

@wing328 wing328 modified the milestones: 6.0.0, 6.0.1 May 26, 2022
@wing328
Copy link
Member

wing328 commented Jun 25, 2022

UPDATE: compiled without issues but somehow the tests couldn't run to completion:

➜  cpp-boost-beast git:(LukasWoodtli-cpp-boost-beast-client2) ✗ /bin/bash build-and-test.bash
cmake: /usr/local/lib/libcurl.so.4: no version information available (required by cmake)
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.66.0")  
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.66") found components: system 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wing328/Code/openapi-generator/samples/client/petstore/cpp-boost-beast/build
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
[ 45%] Built target client
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
[ 66%] Built target api_tests
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
[100%] Built target model_tests
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
Running tests...
/usr/bin/ctest: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/ctest)
Test project /home/wing328/Code/openapi-generator/samples/client/petstore/cpp-boost-beast/build
    Start 1: api_tests

@wing328 wing328 modified the milestones: 6.0.1, 6.1.0 Jul 5, 2022
@LukasWoodtli
Copy link
Contributor Author

Currently I don't have any resources left to work on that generator. The project that this would be needed for is on hold. Sorry for that. But I hope that I will be able to continue to work on this generator asap...

@wing328 wing328 modified the milestones: 6.1.0, 6.1.1 Sep 11, 2022
@wing328 wing328 modified the milestones: 6.1.1, 6.2.1 Sep 24, 2022
@wing328 wing328 modified the milestones: 6.2.1, 6.3.0 Nov 1, 2022
@wing328 wing328 modified the milestones: 6.3.0, 6.3.1 Jan 20, 2023
@wing328 wing328 modified the milestones: 6.4.0, 6.5.0 Feb 19, 2023
@wing328 wing328 modified the milestones: 6.5.0, 6.6.0 Apr 1, 2023
@wing328 wing328 modified the milestones: 6.6.0, 7.0.0 May 11, 2023
@wing328 wing328 removed this from the 7.0.0 milestone Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants