-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Description
Description
The fromJson method defined via model-source.mustache declares newItem to be of type items.datatype. When processing an array of stings this results in generating declaring newItem as std::string and subsequently attempting to execute the fromJson() method which is undefined. In this case, here is a snippet of the generated code for UePerLocationReport::fromJson(nlohmann:json& val).
...
void UePerLocationReport::fromJson(nlohmann::json& val)
{
setUeCount(val.at("ueCount"));
{
m_ExternalIds.clear();
nlohmann::json jsonArray;
if(val.find("externalIds") != val.end())
{
for( auto& item : val["externalIds"] )
{
if(item.is_null())
{
m_ExternalIds.push_back( std::string() );
}
else
{
std::string newItem;
newItem.fromJson(item);
m_ExternalIds.push_back( newItem );
}
}
}
}
...
openapi-generator version
3.3.0
OpenAPI declaration file content or url
Archive .zip contains the yaml and support files to reproduce the issue.
Command line used for generation
java -jar ~/code/git/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i updated/TS29122_MonitoringEvent.yaml -g cpp-pistache-server --config config -o ./src/MonitoringEvent/
Modify the openapi-generator-cli.jar path to match your system.
Steps to reproduce
- Create a blank working directory
- Unzip Archive.zip to the newly created directory.
- Generate the source using the provided command making path adjustments for your system.
- Install pistache.io.
- Compile with the following command:
g++ -g -pthread -std=c++11 -I ./include -I ./src/MonitoringEvent/api -I ./src/MonitoringEvent/impl -I t8/src/MonitoringEvent/model -c -o ./UePerLocationReport.o ./src/MonitoringEvent/model/UePerLocationReport.cpp