diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache index c584eadee58..640db9da815 100644 --- a/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache @@ -212,6 +212,19 @@ inline FString CollectionToUrlString_multi(const TArray& Collection, const TC ////////////////////////////////////////////////////////////////////////// +inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr& Value) +{ + if (Value.IsValid()) + { + FJsonSerializer::Serialize(Value.ToSharedRef(), "", Writer, false); + } + else + { + Writer->WriteObjectStart(); + Writer->WriteObjectEnd(); + } +} + inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr& Value) { if (Value.IsValid()) @@ -324,6 +337,12 @@ inline bool TryGetJsonValue(const TSharedPtr& JsonValue, bool& Value return false; } +inline bool TryGetJsonValue(const TSharedPtr& JsonValue, TSharedPtr& JsonObjectValue) +{ + JsonObjectValue = JsonValue; + return true; +} + inline bool TryGetJsonValue(const TSharedPtr& JsonValue, TSharedPtr& JsonObjectValue) { const TSharedPtr* Object; diff --git a/samples/client/petstore/cpp-ue4/Public/OpenAPIHelpers.h b/samples/client/petstore/cpp-ue4/Public/OpenAPIHelpers.h index 606e1e9851c..ff8497f23f9 100644 --- a/samples/client/petstore/cpp-ue4/Public/OpenAPIHelpers.h +++ b/samples/client/petstore/cpp-ue4/Public/OpenAPIHelpers.h @@ -221,6 +221,19 @@ inline FString CollectionToUrlString_multi(const TArray& Collection, const TC ////////////////////////////////////////////////////////////////////////// +inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr& Value) +{ + if (Value.IsValid()) + { + FJsonSerializer::Serialize(Value.ToSharedRef(), "", Writer, false); + } + else + { + Writer->WriteObjectStart(); + Writer->WriteObjectEnd(); + } +} + inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr& Value) { if (Value.IsValid()) @@ -333,6 +346,12 @@ inline bool TryGetJsonValue(const TSharedPtr& JsonValue, bool& Value return false; } +inline bool TryGetJsonValue(const TSharedPtr& JsonValue, TSharedPtr& JsonObjectValue) +{ + JsonObjectValue = JsonValue; + return true; +} + inline bool TryGetJsonValue(const TSharedPtr& JsonValue, TSharedPtr& JsonObjectValue) { const TSharedPtr* Object;