[BUG][C++][cpp-restsdk] Error compiling c++ client library with enums
Created by: animesh-bhadouria
Bug Report Checklist
-
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? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I defined a schema object type enum in yaml file as per the reusable enum samples docs/data-models/enums and generated the cpprestsdk API client library. Getting a compilation error while upon compiling the API client library.
openapi-generator version
openapi-generator-cli 5.3.0-SNAPSHOT
commit : 0c7ec41
built : 2021-08-31T18:02:21-07:00
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: Open API Sample
version: 1.0.0
servers:
- url: http://localhost:8000
paths:
/products:
get:
parameters:
- in: query
name: color
required: true
schema:
$ref: '#/components/schemas/Color'
responses:
'200':
description: OK
components:
schemas:
Color:
type: string
enum:
- black
- white
- red
- green
- blue
Generation Details
java -jar ./openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g cpp-restsdk -i test.yaml -o ./test/
Steps to reproduce
- Create a
test.yaml
file with the provided (above) sample configuration. (validated)
java -jar ./openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar validate -i test.yaml
Validating spec (test.yaml)
No validation issues detected.
- Generate the Client API library.
java -jar ./openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g cpp-restsdk -i test.yaml -o ./test/
- Compile the C++ Client API library.
cd test
cmake -DCPPREST_ROOT=/usr -DCMAKE_CXX_FLAGS="-I/usr/local/opt/openssl/include" -DCMAKE_MODULE_LINKER_FLAGS="-L/usr/local/opt/openssl/lib"
make
Error Log
The generated client code cannot match the template parameterToString()
conversion for enums.
In file included from /test/api/DefaultApi.cpp:13:
In file included from /test/api/DefaultApi.h:22:
/test/api/../ApiClient.h:104:12: error: use of undeclared identifier 'parameterToString'
return parameterToString(*value.get());
^
/test/api/DefaultApi.cpp:86:86: note: in instantiation of function template specialization
'org::openapitools::client::api::ApiClient::parameterToString<org::openapitools::client::model::Color>' requested here
localVarQueryParams[utility::conversions::to_string_t("color")] = ApiClient::parameterToString(color);
^
/test/api/../ApiClient.h:59:30: note: must qualify identifier to find this declaration in dependent base class
static utility::string_t parameterToString(utility::string_t value);
^
/test/api/../ApiClient.h:60:30: note: must qualify identifier to find this declaration in dependent base class
static utility::string_t parameterToString(int32_t value);
^
/test/api/../ApiClient.h:61:30: note: must qualify identifier to find this declaration in dependent base class
static utility::string_t parameterToString(int64_t value);
^
/test/api/../ApiClient.h:62:30: note: must qualify identifier to find this declaration in dependent base class
static utility::string_t parameterToString(float value);
^
/test/api/../ApiClient.h:63:30: note: must qualify identifier to find this declaration in dependent base class
static utility::string_t parameterToString(double value);
^
/test/api/../ApiClient.h:64:30: note: must qualify identifier to find this declaration in dependent base class
static utility::string_t parameterToString(const utility::datetime &value);
^
/test/api/../ApiClient.h:88:30: note: must qualify identifier to find this declaration in dependent base class
utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
^
/test/api/../ApiClient.h:102:30: note: must qualify identifier to find this declaration in dependent base class
utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
^
/test/api/../ApiClient.h:104:12: error: no matching function for call to 'parameterToString'
return parameterToString(*value.get());
^~~~~~~~~~~~~~~~~
/test/api/../ApiClient.h:59:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'utility::string_t' (aka
'basic_string<char, char_traits<char>, allocator<char> >') for 1st argument
static utility::string_t parameterToString(utility::string_t value);
^
/test/api/../ApiClient.h:60:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'int32_t' (aka 'int') for 1st argument
static utility::string_t parameterToString(int32_t value);
^
/test/api/../ApiClient.h:61:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'int64_t' (aka 'long long') for 1st argument
static utility::string_t parameterToString(int64_t value);
^
/test/api/../ApiClient.h:62:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'float' for 1st argument
static utility::string_t parameterToString(float value);
^
/test/api/../ApiClient.h:63:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'double' for 1st argument
static utility::string_t parameterToString(double value);
^
/test/api/../ApiClient.h:64:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'const utility::datetime' for 1st argument
static utility::string_t parameterToString(const utility::datetime &value);
^
/test/api/../ApiClient.h:88:30: note: candidate template ignored: could not match 'vector<type-parameter-0-0, allocator<type-parameter-0-0> >'
against 'org::openapitools::client::model::Color'
utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
^
/test/api/../ApiClient.h:102:30: note: candidate template ignored: could not match 'shared_ptr<type-parameter-0-0>' against
'org::openapitools::client::model::Color'
utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
^
/test/api/../ApiClient.h:104:12: error: no matching function for call to 'parameterToString'
return parameterToString(*value.get());
^~~~~~~~~~~~~~~~~
/test/api/../ApiClient.h:59:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'utility::string_t' (aka
'basic_string<char, char_traits<char>, allocator<char> >') for 1st argument
static utility::string_t parameterToString(utility::string_t value);
^
/test/api/../ApiClient.h:60:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'int32_t' (aka 'int') for 1st argument
static utility::string_t parameterToString(int32_t value);
^
/test/api/../ApiClient.h:61:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'int64_t' (aka 'long long') for 1st argument
static utility::string_t parameterToString(int64_t value);
^
/test/api/../ApiClient.h:62:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'float' for 1st argument
static utility::string_t parameterToString(float value);
^
/test/api/../ApiClient.h:63:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'double' for 1st argument
static utility::string_t parameterToString(double value);
^
/test/api/../ApiClient.h:64:30: note: candidate function not viable: no known conversion from
'std::__1::shared_ptr<org::openapitools::client::model::Color>::element_type' (aka 'org::openapitools::client::model::Color') to 'const utility::datetime' for 1st argument
static utility::string_t parameterToString(const utility::datetime &value);
^
/test/api/../ApiClient.h:88:30: note: candidate template ignored: could not match 'vector<type-parameter-0-0, allocator<type-parameter-0-0> >'
against 'org::openapitools::client::model::Color'
utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
^
/test/api/../ApiClient.h:102:30: note: candidate template ignored: could not match 'shared_ptr<type-parameter-0-0>' against
'org::openapitools::client::model::Color'
utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
^
1 warning and 3 errors generated.
make[2]: *** [CMakeFiles/CppRestOpenAPIClient.dir/api/DefaultApi.cpp.o] Error 1
make[1]: *** [CMakeFiles/CppRestOpenAPIClient.dir/all] Error 2
make: *** [all] Error 2