diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-source.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-source.mustache index 4d262483e1f3..b2e621e7859e 100644 --- a/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-source.mustache @@ -170,11 +170,28 @@ void {{classname}}::{{operationIdCamelCase}}Request::SetupHttpRequest(const FHtt HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json; charset=utf-8")); HttpRequest->SetContentAsString(JsonBody); {{/bodyParams.0}} - {{#formParams.0}} + {{^bodyParams.0}} + // Form parameters + FString JsonBody; + JsonWriter Writer = TJsonWriterFactory<>::Create(&JsonBody); + Writer->WriteObjectStart(); {{#formParams}} - UE_LOG(Log{{unrealModuleName}}, Error, TEXT("Form parameter ({{baseName}}) was ignored, cannot be used in JsonBody")); + {{#required}} + Writer->WriteIdentifierPrefix(TEXT("{{baseName}}")); + WriteJsonValue(Writer, {{paramName}}); + {{/required}} + {{^required}} + if ({{paramName}}.IsSet()){ + Writer->WriteIdentifierPrefix(TEXT("{{baseName}}")); + WriteJsonValue(Writer, {{paramName}}.GetValue()); + } + {{/required}} {{/formParams}} - {{/formParams.0}} + Writer->WriteObjectEnd(); + Writer->Close(); + HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json; charset=utf-8")); + HttpRequest->SetContentAsString(JsonBody); + {{/bodyParams.0}} } else if (Consumes.Contains(TEXT("multipart/form-data"))) {