Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3270
Closed
Open
Issue created Jul 03, 2019 by Administrator@rootContributor

[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>();
Assignee
Assign to
Time tracking