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
  • #10274
Closed
Open
Issue created Aug 26, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [cpp-ue4] Missing WriteJsonValue and TryGetJsonValue for arbitrary-typed variables

Created by: madrazzl3

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

This bug was brought in PR #10267, where type TSharedPtr<FJsonValue> was introduced to hold arbitrary-typed variables. However, this solution was not complete because it's missing overloads of WriteJsonValue and TryGetJsonValue functions for TSharedPtr<FJsonValue> type, that leads to compile-time errors.

openapi-generator version

master - 5.3.0

OpenAPI declaration file content or url

Full scheme

arrayOfSomething:
          type: array
          items: {}
          nullable: true
Generation Details
openapi-generator  generate -i https://gist.githubusercontent.com/madrazzl3/da2502b6816aaa98713cba75e595f373/raw/d53da8c6098167768c3e5b1ad1381467397d6a51/example-scheme.yaml -g cpp-ue4 -o generated-client/ --additional-properties=cppNamespace='api',unrealModuleName='MyAPI',modelNamePrefix=''
Steps to reproduce
  1. Generate UE4 client with any of available tools
  2. Try to build generated module
Related issues/PRs

Issue #10266 (closed)

Suggest a fix

We need to define proper implementations of WriteJsonValue and TryGetJsonValue for TSharedPtr<FJsonValue> type used for arbitrary-typed variables.

inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr<FJsonValue>& Value)
{
	if (Value.IsValid())
	{
		FJsonSerializer::Serialize(Value.ToSharedRef(), "", Writer, false);
	}
	else
	{
		Writer->WriteObjectStart();
		Writer->WriteObjectEnd();
	}
}

inline bool TryGetJsonValue(const TSharedPtr<FJsonValue>& JsonValue, TSharedPtr<FJsonValue>& JsonObjectValue)
{
	JsonObjectValue = JsonValue;
	return true;
}
Assignee
Assign to
Time tracking