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
  • #3374
Closed
Open
Issue created Jul 16, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][C++-rest-sdk] Issue when default value is nullptr

Created by: dan-drl

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Run time error occurs because default type is set to nullptr. This breaks the fromJSON and toJSON methods in model-source.mustache.

openapi-generator version

4.1.0-SNAPSHOT

OpenAPI declaration file content or url

See test.json: https://gist.github.com/dan-drl/147e962298d1f1467638c00786cd9b6f See resulting c++: https://gist.github.com/dan-drl/0ec11853c939d5d05ab3c2699238d324

Command line used for generation

java -jar openapi-generator-cli.jar generate -i test.json -g cpp-restsdk -o \src\test

Steps to reproduce

If a JSON containing a "value":null is provided to the AdditionalField model for deserialization, a runtime error occurs because of this:

std::shared_ptr<Object> newValue(nullptr);
newValue->fromJson(val.at(utility::conversions::to_string_t(L"value")));
Related issues/PRs

I didn't find anything.

Suggest a fix

Planning on making a pull request. See this commit, https://github.com/dan-drl/openapi-generator/commit/7b42948498ab0a82ee25c875a9787cdc685c9890

Assignee
Assign to
Time tracking