[BUG][C++-rest-sdk] the generated code crash
Created by: eimerej
Description
Here is the code generated from fromJson method:
if(val.has_field(utility::conversions::to_string_t("data")))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("data"));
if(!fieldValue.is_null())
{
std::shared_ptr<Object> newItem(nullptr);
newItem->fromJson(fieldValue); // <-- will crash here
setData( newItem );
}
}
openapi-generator version
4.0.2
OpenAPI declaration file content or url
description: A description of a record
title: records
type: object
properties:
data:
type: object
description: record data container
title: Data
Command line used for generation
java -jar tools\openapi-generator-cli.jar generate -i openapi\tl_storage.yaml -g cpp-restsdk -o generated
Steps to reproduce
Generate the code
Related issues/PRs
I do not find any related issues
Suggest a fix
The shared_ptr initialisation should be something like that:
auto newItem = std::make_shared<Object>();