forked from loafle/openapi-generator-original
UE4 client generator fixes (#6438)
* Added the possibility for a codegen to set the location of the generated model files, similarly to API files. * Removed std::shared_ptr from the generated types. Types in UE4Codegen are handled as POD structs, not shared pointers. * Fixed handling of body parameters as per the specification, the single body object is written directly as the payload. * Fixed handling of files and binaries, if a field is both isFile and isBinary, file will take precedence. * Updated cpp-ue4 client samples * Fixed handling of enums in models Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
76
samples/client/petstore/cpp-ue4/Private/OpenAPIUser.cpp
Normal file
76
samples/client/petstore/cpp-ue4/Private/OpenAPIUser.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator
|
||||
* https://github.com/OpenAPITools/openapi-generator
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
#include "OpenAPIUser.h"
|
||||
|
||||
#include "OpenAPIModule.h"
|
||||
#include "OpenAPIHelpers.h"
|
||||
|
||||
#include "Templates/SharedPointer.h"
|
||||
|
||||
namespace OpenAPI
|
||||
{
|
||||
|
||||
void OpenAPIUser::WriteJson(JsonWriter& Writer) const
|
||||
{
|
||||
Writer->WriteObjectStart();
|
||||
if (Id.IsSet())
|
||||
{
|
||||
Writer->WriteIdentifierPrefix(TEXT("id")); WriteJsonValue(Writer, Id.GetValue());
|
||||
}
|
||||
if (Username.IsSet())
|
||||
{
|
||||
Writer->WriteIdentifierPrefix(TEXT("username")); WriteJsonValue(Writer, Username.GetValue());
|
||||
}
|
||||
if (FirstName.IsSet())
|
||||
{
|
||||
Writer->WriteIdentifierPrefix(TEXT("firstName")); WriteJsonValue(Writer, FirstName.GetValue());
|
||||
}
|
||||
if (LastName.IsSet())
|
||||
{
|
||||
Writer->WriteIdentifierPrefix(TEXT("lastName")); WriteJsonValue(Writer, LastName.GetValue());
|
||||
}
|
||||
if (Email.IsSet())
|
||||
{
|
||||
Writer->WriteIdentifierPrefix(TEXT("email")); WriteJsonValue(Writer, Email.GetValue());
|
||||
}
|
||||
if (Password.IsSet())
|
||||
{
|
||||
Writer->WriteIdentifierPrefix(TEXT("password")); WriteJsonValue(Writer, Password.GetValue());
|
||||
}
|
||||
if (Phone.IsSet())
|
||||
{
|
||||
Writer->WriteIdentifierPrefix(TEXT("phone")); WriteJsonValue(Writer, Phone.GetValue());
|
||||
}
|
||||
if (UserStatus.IsSet())
|
||||
{
|
||||
Writer->WriteIdentifierPrefix(TEXT("userStatus")); WriteJsonValue(Writer, UserStatus.GetValue());
|
||||
}
|
||||
Writer->WriteObjectEnd();
|
||||
}
|
||||
|
||||
bool OpenAPIUser::FromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
||||
{
|
||||
bool ParseSuccess = true;
|
||||
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("id"), Id);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("username"), Username);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("firstName"), FirstName);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("lastName"), LastName);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("email"), Email);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("password"), Password);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("phone"), Phone);
|
||||
ParseSuccess &= TryGetJsonValue(JsonObject, TEXT("userStatus"), UserStatus);
|
||||
|
||||
return ParseSuccess;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user