update ue4 c++ client

This commit is contained in:
William Cheng 2023-04-01 19:11:37 +08:00
parent 033b946856
commit 3d7c173eb2
3 changed files with 11 additions and 8 deletions

View File

@ -22,7 +22,7 @@ public class OpenAPI : ModuleRules
new string[] new string[]
{ {
"Core", "Core",
"Http", "HTTP",
"Json", "Json",
} }
); );

View File

@ -382,7 +382,7 @@ void OpenAPIPetApi::UpdatePetWithFormRequest::SetupHttpRequest(const FHttpReques
// Default to Json Body request // Default to Json Body request
if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json"))) if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json")))
{ {
// Form parameters // Form parameters added to try to generate a json body when no body parameters are specified.
FString JsonBody; FString JsonBody;
JsonWriter Writer = TJsonWriterFactory<>::Create(&JsonBody); JsonWriter Writer = TJsonWriterFactory<>::Create(&JsonBody);
Writer->WriteObjectStart(); Writer->WriteObjectStart();
@ -470,7 +470,7 @@ void OpenAPIPetApi::UploadFileRequest::SetupHttpRequest(const FHttpRequestRef& H
// Default to Json Body request // Default to Json Body request
if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json"))) if (Consumes.Num() == 0 || Consumes.Contains(TEXT("application/json")))
{ {
// Form parameters // Form parameters added to try to generate a json body when no body parameters are specified.
FString JsonBody; FString JsonBody;
JsonWriter Writer = TJsonWriterFactory<>::Create(&JsonBody); JsonWriter Writer = TJsonWriterFactory<>::Create(&JsonBody);
Writer->WriteObjectStart(); Writer->WriteObjectStart();
@ -478,10 +478,7 @@ void OpenAPIPetApi::UploadFileRequest::SetupHttpRequest(const FHttpRequestRef& H
Writer->WriteIdentifierPrefix(TEXT("additionalMetadata")); Writer->WriteIdentifierPrefix(TEXT("additionalMetadata"));
WriteJsonValue(Writer, AdditionalMetadata.GetValue()); WriteJsonValue(Writer, AdditionalMetadata.GetValue());
} }
if (File.IsSet()){ UE_LOG(LogOpenAPI, Error, TEXT("Form parameter (file) was ignored, Files are not supported in json body"));
Writer->WriteIdentifierPrefix(TEXT("file"));
WriteJsonValue(Writer, File.GetValue());
}
Writer->WriteObjectEnd(); Writer->WriteObjectEnd();
Writer->Close(); Writer->Close();
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json; charset=utf-8")); HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json; charset=utf-8"));

View File

@ -103,12 +103,18 @@ FString Base64UrlEncode(const T& Value)
return Base64String; return Base64String;
} }
template<typename T> template<typename T, typename std::enable_if<!std::is_base_of<Model, T>::value, int>::type = 0>
inline FStringFormatArg ToStringFormatArg(const T& Value) inline FStringFormatArg ToStringFormatArg(const T& Value)
{ {
return FStringFormatArg(Value); return FStringFormatArg(Value);
} }
template<typename T, typename std::enable_if<std::is_base_of<Model, T>::value, int>::type = 0>
inline FStringFormatArg ToStringFormatArg(const T& EnumModelValue)
{
return FStringFormatArg(T::EnumToString(EnumModelValue.Value));
}
inline FStringFormatArg ToStringFormatArg(const FDateTime& Value) inline FStringFormatArg ToStringFormatArg(const FDateTime& Value)
{ {
return FStringFormatArg(Value.ToIso8601()); return FStringFormatArg(Value.ToIso8601());