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[]
{
"Core",
"Http",
"HTTP",
"Json",
}
);

View File

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

View File

@ -103,12 +103,18 @@ FString Base64UrlEncode(const T& Value)
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)
{
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)
{
return FStringFormatArg(Value.ToIso8601());