From 28e0d9b22e1dcbb0c51d9dffc1a0cf03b4765b85 Mon Sep 17 00:00:00 2001 From: Josh Wittner Date: Tue, 20 Apr 2021 06:23:36 -0700 Subject: [PATCH] Support FGuid with helpers (#9291) --- .../resources/cpp-ue4/helpers-header.mustache | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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 eb178e890af..67d60535987 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 @@ -105,6 +105,11 @@ inline FStringFormatArg ToStringFormatArg(const FDateTime& Value) return FStringFormatArg(Value.ToIso8601()); } +inline FStringFormatArg ToStringFormatArg(const FGuid& Value) +{ + return FStringFormatArg(Value.ToString(EGuidFormats::DigitsWithHyphens)); +} + inline FStringFormatArg ToStringFormatArg(const TArray& Value) { return FStringFormatArg(Base64UrlEncode(Value)); @@ -220,6 +225,11 @@ inline void WriteJsonValue(JsonWriter& Writer, const FDateTime& Value) Writer->WriteValue(Value.ToIso8601()); } +inline void WriteJsonValue(JsonWriter& Writer, const FGuid& Value) +{ + Writer->WriteValue(Value.ToString(EGuidFormats::DigitsWithHyphens)); +} + inline void WriteJsonValue(JsonWriter& Writer, const Model& Value) { Value.WriteJson(Writer); @@ -281,6 +291,17 @@ inline bool TryGetJsonValue(const TSharedPtr& JsonValue, FDateTime& return false; } +inline bool TryGetJsonValue(const TSharedPtr& JsonValue, FGuid& Value) +{ + FString TmpValue; + if (JsonValue->TryGetString(TmpValue)) + { + return FGuid::Parse(TmpValue, Value); + } + else + return false; +} + inline bool TryGetJsonValue(const TSharedPtr& JsonValue, bool& Value) { bool TmpValue;