[BUG] [C++] Pistache compiling Pet example
Created by: MattC11
-
Have you provided a full/minimal spec to reproduce the issue?
[-] Have you validated the input using an OpenAPI validator (example)?
-
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output?
Using Release 5.3.1 and trying to create a REST server with pistache. It failes to compile using the default PetStore example.
openapi-generator version
5.3.1 Also exists on 5.4.x and 6.0.X
Details
I started with just the petstore.yaml since that was the given example and used the following command:
java -jar openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g cpp-pistache-server -o /var/tmp/pistache_pet
Then: cd /var/tmp/pistache_pet mkdir build cd build cmake -G Ninja .. ninja
This fails as below. I am surprise by this because I am using the example petstore.yaml which I would have expected is tested against often. So perhaps I am doing a step wrong?
I get the following error: FAILED: CMakeFiles/api-server.dir/impl/UserApiImpl.cpp.o /usr/bin/c++ -I/var/tmp/pistache_pet/external/include -I/var/tmp/pistache_pet/model -I/var/tmp/pistache_pet/api -I/var/tmp/pistache_pet/impl -std=c++17 -pg -g3 -MD -MT CMakeFiles/api-server.dir/impl/UserApiImpl.cpp.o -MF CMakeFiles/api-server.dir/impl/UserApiImpl.cpp.o.d -o CMakeFiles/api-server.dir/impl/UserApiImpl.cpp.o -c /var/tmp/pistache_pet/impl/UserApiImpl.cpp In file included from /var/tmp/pistache_pet/impl/UserApiImpl.h:29, from /var/tmp/pistache_pet/impl/UserApiImpl.cpp:13: /var/tmp/pistache_pet/api/UserApi.h:88:66: error: ‘User’ was not declared in this scope; did you mean ‘org::openapitools::server::model::User’? 88 | virtual void create_users_with_array_input(const std::vector &user, Pistache::Http::ResponseWriter &response) = 0; | ^~~~ | org::openapitools::server::model::User In file included from /var/tmp/pistache_pet/api/UserApi.h:29, from /var/tmp/pistache_pet/impl/UserApiImpl.h:29, from /var/tmp/pistache_pet/impl/UserApiImpl.cpp:13: /var/tmp/pistache_pet/model/User.h:31:8: note: ‘org::openapitools::server::model::User’ declared here 31 | class User | ^~~~ In file included from /var/tmp/pistache_pet/impl/UserApiImpl.h:29, from /var/tmp/pistache_pet/impl/UserApiImpl.cpp:13: /var/tmp/pistache_pet/api/UserApi.h:88:70: error: template argument 1 is invalid 88 | virtual void create_users_with_array_input(const std::vector &user, Pistache::Http::ResponseWriter &response) = 0; | ^ /var/tmp/pistache_pet/api/UserApi.h:88:70: error: template argument 2 is invalid /var/tmp/pistache_pet/api/UserApi.h:96:65: error: ‘User’ was not declared in this scope; did you mean ‘org::openapitools::server::model::User’? 96 | virtual void create_users_with_list_input(const std::vector &user, Pistache::Http::ResponseWriter &response) = 0; | ^~~~ | org::openapitools::server::model::User In file included from /var/tmp/pistache_pet/api/UserApi.h:29, from /var/tmp/pistache_pet/impl/UserApiImpl.h:29, from /var/tmp/pistache_pet/impl/UserApiImpl.cpp:13: /var/tmp/pistache_pet/model/User.h:31:8: note: ‘org::openapitools::server::model::User’ declared here 31 | class User | ^~~~ In file included from /var/tmp/pistache_pet/impl/UserApiImpl.h:29, from /var/tmp/pistache_pet/impl/UserApiImpl.cpp:13: /var/tmp/pistache_pet/api/UserApi.h:96:69: error: template argument 1 is invalid 96 | virtual void create_users_with_list_input(const std::vector &user, Pistache::Http::ResponseWriter &response) = 0; | ^ /var/tmp/pistache_pet/api/UserApi.h:96:69: error: template argument 2 is invalid [21/27] Building CXX object CMakeFiles/api-server.dir/api/UserApi.cpp.o
I can fix this specific error by specifying the User namespace. However, I then get a second error which I'm not sure how to fix:
FAILED: CMakeFiles/api-server.dir/api/UserApi.cpp.o /usr/bin/c++ -I/var/tmp/pistache_pet/external/include -I/var/tmp/pistache_pet/model -I/var/tmp/pistache_pet/api -I/var/tmp/pistache_pet/impl -std=c++17 -pg -g3 -MD -MT CMakeFiles/api-server.dir/api/UserApi.cpp.o -MF CMakeFiles/api-server.dir/api/UserApi.cpp.o.d -o CMakeFiles/api-server.dir/api/UserApi.cpp.o -c /var/tmp/pistache_pet/api/UserApi.cpp /var/tmp/pistache_pet/api/UserApi.cpp: In member function ‘void org::openapitools::server::api::UserApi::create_users_with_array_input_handler(const Pistache::Rest::Request&, Pistache::Http::ResponseWriter)’: /var/tmp/pistache_pet/api/UserApi.cpp:109:14: error: ‘class std::vectororg::openapitools::server::model::User’ has no member named ‘validate’ 109 | user.validate(); | ^~~~~~~~ /var/tmp/pistache_pet/api/UserApi.cpp: In member function ‘void org::openapitools::server::api::UserApi::create_users_with_list_input_handler(const Pistache::Rest::Request&, Pistache::Http::ResponseWriter)’: /var/tmp/pistache_pet/api/UserApi.cpp:141:14: error: ‘class std::vectororg::openapitools::server::model::User’ has no member named ‘validate’ 141 | user.validate(); | ^~~~~~~~ [15/16] Building CXX object CMakeFiles/api-server.dir/main-api-server.cpp.o