forked from loafle/openapi-generator-original
Squashed commit of the following:
commit c5a0d0f7394aa742fa336fff7e7c1d3049761868 Merge:8c4991ba3ef8ff8c8760Author: William Cheng <wing328hk@gmail.com> Date: Tue Aug 17 18:28:12 2021 +0800 Merge branch 'mustache-linting' of https://github.com/NathanBaulch/openapi-generator into NathanBaulch-mustache-linting commitf8ff8c8760Author: Nathan Baulch <nathan.baulch@gmail.com> Date: Thu Aug 5 14:12:47 2021 +1000 Reorder tags that handle missing values commitf5d8a33709Author: Nathan Baulch <nathan.baulch@gmail.com> Date: Thu Aug 5 14:08:59 2021 +1000 Use dot notation where possible commit493d14921eAuthor: Nathan Baulch <nathan.baulch@gmail.com> Date: Thu Aug 5 14:10:49 2021 +1000 Remove empty tags commit32480dc53fAuthor: Nathan Baulch <nathan.baulch@gmail.com> Date: Thu Aug 5 10:41:58 2021 +1000 Remove redundant sections commita8edabd722Author: Nathan Baulch <nathan.baulch@gmail.com> Date: Wed Aug 4 22:02:22 2021 +1000 Trim extra EOF new lines commite89bd7458eAuthor: Nathan Baulch <nathan.baulch@gmail.com> Date: Wed Aug 4 21:59:26 2021 +1000 Trim trailing whitespace
This commit is contained in:
@@ -23,43 +23,43 @@ ApiResponse::~ApiResponse()
|
||||
|
||||
void
|
||||
ApiResponse::fromJson(std::string jsonObj)
|
||||
{
|
||||
{
|
||||
bourne::json object = bourne::json::parse(jsonObj);
|
||||
|
||||
const char *codeKey = "code";
|
||||
|
||||
if(object.has_key(codeKey))
|
||||
|
||||
if(object.has_key(codeKey))
|
||||
{
|
||||
bourne::json value = object[codeKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&code, value, "int");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *typeKey = "type";
|
||||
|
||||
if(object.has_key(typeKey))
|
||||
|
||||
if(object.has_key(typeKey))
|
||||
{
|
||||
bourne::json value = object[typeKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&type, value, "std::string");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *messageKey = "message";
|
||||
|
||||
if(object.has_key(messageKey))
|
||||
|
||||
if(object.has_key(messageKey))
|
||||
{
|
||||
bourne::json value = object[messageKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&message, value, "std::string");
|
||||
|
||||
|
||||
@@ -73,21 +73,21 @@ ApiResponse::toJson()
|
||||
{
|
||||
bourne::json object = bourne::json::object();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["code"] = getCode();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["type"] = getType();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,30 +22,30 @@ Category::~Category()
|
||||
|
||||
void
|
||||
Category::fromJson(std::string jsonObj)
|
||||
{
|
||||
{
|
||||
bourne::json object = bourne::json::parse(jsonObj);
|
||||
|
||||
const char *idKey = "id";
|
||||
|
||||
if(object.has_key(idKey))
|
||||
|
||||
if(object.has_key(idKey))
|
||||
{
|
||||
bourne::json value = object[idKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&id, value, "long");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *nameKey = "name";
|
||||
|
||||
if(object.has_key(nameKey))
|
||||
|
||||
if(object.has_key(nameKey))
|
||||
{
|
||||
bourne::json value = object[nameKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&name, value, "std::string");
|
||||
|
||||
|
||||
@@ -59,14 +59,14 @@ Category::toJson()
|
||||
{
|
||||
bourne::json object = bourne::json::object();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["id"] = getId();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,39 +23,39 @@ jsonToValue(void* target, bourne::json value, std::string type)
|
||||
{
|
||||
if (target == NULL || value.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
else if (type.compare("bool") == 0)
|
||||
}
|
||||
|
||||
else if (type.compare("bool") == 0)
|
||||
{
|
||||
bool* val = static_cast<bool*> (target);
|
||||
*val = value.to_bool();
|
||||
}
|
||||
|
||||
else if (type.compare("int") == 0)
|
||||
}
|
||||
|
||||
else if (type.compare("int") == 0)
|
||||
{
|
||||
int* val = static_cast<int*> (target);
|
||||
*val = value.to_int();
|
||||
}
|
||||
|
||||
else if (type.compare("float") == 0)
|
||||
}
|
||||
|
||||
else if (type.compare("float") == 0)
|
||||
{
|
||||
float* val = static_cast<float*> (target);
|
||||
*val = (float)(value.to_float());
|
||||
}
|
||||
}
|
||||
|
||||
else if (type.compare("long") == 0)
|
||||
{
|
||||
long* val = static_cast<long*> (target);
|
||||
*val = (long)(value.to_int());
|
||||
}
|
||||
|
||||
else if (type.compare("double") == 0)
|
||||
}
|
||||
|
||||
else if (type.compare("double") == 0)
|
||||
{
|
||||
double* val = static_cast<double*> (target);
|
||||
*val = value.to_float();
|
||||
}
|
||||
|
||||
else if (type.compare("std::string") == 0)
|
||||
}
|
||||
|
||||
else if (type.compare("std::string") == 0)
|
||||
{
|
||||
std::string* val = static_cast<std::string*> (target);
|
||||
*val = value.to_string();
|
||||
|
||||
@@ -19,4 +19,3 @@ std::string stringify(float input);
|
||||
std::string stringify(std::string input);
|
||||
|
||||
#endif /* TINY_CPP_CLIENT_HELPERS_H_ */
|
||||
|
||||
|
||||
@@ -26,82 +26,82 @@ Order::~Order()
|
||||
|
||||
void
|
||||
Order::fromJson(std::string jsonObj)
|
||||
{
|
||||
{
|
||||
bourne::json object = bourne::json::parse(jsonObj);
|
||||
|
||||
const char *idKey = "id";
|
||||
|
||||
if(object.has_key(idKey))
|
||||
|
||||
if(object.has_key(idKey))
|
||||
{
|
||||
bourne::json value = object[idKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&id, value, "long");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *petIdKey = "petId";
|
||||
|
||||
if(object.has_key(petIdKey))
|
||||
|
||||
if(object.has_key(petIdKey))
|
||||
{
|
||||
bourne::json value = object[petIdKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&petId, value, "long");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *quantityKey = "quantity";
|
||||
|
||||
if(object.has_key(quantityKey))
|
||||
|
||||
if(object.has_key(quantityKey))
|
||||
{
|
||||
bourne::json value = object[quantityKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&quantity, value, "int");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *shipDateKey = "shipDate";
|
||||
|
||||
if(object.has_key(shipDateKey))
|
||||
|
||||
if(object.has_key(shipDateKey))
|
||||
{
|
||||
bourne::json value = object[shipDateKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&shipDate, value, "std::string");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *statusKey = "status";
|
||||
|
||||
if(object.has_key(statusKey))
|
||||
|
||||
if(object.has_key(statusKey))
|
||||
{
|
||||
bourne::json value = object[statusKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&status, value, "std::string");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *completeKey = "complete";
|
||||
|
||||
if(object.has_key(completeKey))
|
||||
|
||||
if(object.has_key(completeKey))
|
||||
{
|
||||
bourne::json value = object[completeKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&complete, value, "bool");
|
||||
|
||||
|
||||
@@ -115,42 +115,42 @@ Order::toJson()
|
||||
{
|
||||
bourne::json object = bourne::json::object();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["id"] = getId();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["petId"] = getPetId();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["quantity"] = getQuantity();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["shipDate"] = getShipDate();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["status"] = getStatus();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,30 +26,30 @@ Pet::~Pet()
|
||||
|
||||
void
|
||||
Pet::fromJson(std::string jsonObj)
|
||||
{
|
||||
{
|
||||
bourne::json object = bourne::json::parse(jsonObj);
|
||||
|
||||
const char *idKey = "id";
|
||||
|
||||
if(object.has_key(idKey))
|
||||
|
||||
if(object.has_key(idKey))
|
||||
{
|
||||
bourne::json value = object[idKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&id, value, "long");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *categoryKey = "category";
|
||||
|
||||
if(object.has_key(categoryKey))
|
||||
|
||||
if(object.has_key(categoryKey))
|
||||
{
|
||||
bourne::json value = object[categoryKey];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Category* obj = &category;
|
||||
obj->fromJson(value.dump());
|
||||
@@ -57,21 +57,21 @@ Pet::fromJson(std::string jsonObj)
|
||||
}
|
||||
|
||||
const char *nameKey = "name";
|
||||
|
||||
if(object.has_key(nameKey))
|
||||
|
||||
if(object.has_key(nameKey))
|
||||
{
|
||||
bourne::json value = object[nameKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&name, value, "std::string");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *photoUrlsKey = "photoUrls";
|
||||
|
||||
if(object.has_key(photoUrlsKey))
|
||||
|
||||
if(object.has_key(photoUrlsKey))
|
||||
{
|
||||
bourne::json value = object[photoUrlsKey];
|
||||
|
||||
@@ -82,8 +82,8 @@ Pet::fromJson(std::string jsonObj)
|
||||
{
|
||||
|
||||
jsonToValue(&element, var, "std::string");
|
||||
|
||||
|
||||
|
||||
|
||||
photoUrls_list.push_back(element);
|
||||
}
|
||||
photoUrls = photoUrls_list;
|
||||
@@ -92,8 +92,8 @@ Pet::fromJson(std::string jsonObj)
|
||||
}
|
||||
|
||||
const char *tagsKey = "tags";
|
||||
|
||||
if(object.has_key(tagsKey))
|
||||
|
||||
if(object.has_key(tagsKey))
|
||||
{
|
||||
bourne::json value = object[tagsKey];
|
||||
|
||||
@@ -103,9 +103,9 @@ Pet::fromJson(std::string jsonObj)
|
||||
for(auto& var : value.array_range())
|
||||
{
|
||||
|
||||
|
||||
|
||||
element.fromJson(var.dump());
|
||||
|
||||
|
||||
tags_list.push_back(element);
|
||||
}
|
||||
tags = tags_list;
|
||||
@@ -114,13 +114,13 @@ Pet::fromJson(std::string jsonObj)
|
||||
}
|
||||
|
||||
const char *statusKey = "status";
|
||||
|
||||
if(object.has_key(statusKey))
|
||||
|
||||
if(object.has_key(statusKey))
|
||||
{
|
||||
bourne::json value = object[statusKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&status, value, "std::string");
|
||||
|
||||
|
||||
@@ -134,30 +134,30 @@ Pet::toJson()
|
||||
{
|
||||
bourne::json object = bourne::json::object();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["id"] = getId();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["category"] = getCategory().toJson();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["name"] = getName();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::list<std::string> photoUrls_list = getPhotoUrls();
|
||||
bourne::json photoUrls_arr = bourne::json::array();
|
||||
|
||||
@@ -167,12 +167,12 @@ Pet::toJson()
|
||||
}
|
||||
object["photoUrls"] = photoUrls_arr;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::list<Tag> tags_list = getTags();
|
||||
bourne::json tags_arr = bourne::json::array();
|
||||
@@ -186,7 +186,7 @@ Pet::toJson()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,30 +22,30 @@ Tag::~Tag()
|
||||
|
||||
void
|
||||
Tag::fromJson(std::string jsonObj)
|
||||
{
|
||||
{
|
||||
bourne::json object = bourne::json::parse(jsonObj);
|
||||
|
||||
const char *idKey = "id";
|
||||
|
||||
if(object.has_key(idKey))
|
||||
|
||||
if(object.has_key(idKey))
|
||||
{
|
||||
bourne::json value = object[idKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&id, value, "long");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *nameKey = "name";
|
||||
|
||||
if(object.has_key(nameKey))
|
||||
|
||||
if(object.has_key(nameKey))
|
||||
{
|
||||
bourne::json value = object[nameKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&name, value, "std::string");
|
||||
|
||||
|
||||
@@ -59,14 +59,14 @@ Tag::toJson()
|
||||
{
|
||||
bourne::json object = bourne::json::object();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["id"] = getId();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,108 +28,108 @@ User::~User()
|
||||
|
||||
void
|
||||
User::fromJson(std::string jsonObj)
|
||||
{
|
||||
{
|
||||
bourne::json object = bourne::json::parse(jsonObj);
|
||||
|
||||
const char *idKey = "id";
|
||||
|
||||
if(object.has_key(idKey))
|
||||
|
||||
if(object.has_key(idKey))
|
||||
{
|
||||
bourne::json value = object[idKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&id, value, "long");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *usernameKey = "username";
|
||||
|
||||
if(object.has_key(usernameKey))
|
||||
|
||||
if(object.has_key(usernameKey))
|
||||
{
|
||||
bourne::json value = object[usernameKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&username, value, "std::string");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *firstNameKey = "firstName";
|
||||
|
||||
if(object.has_key(firstNameKey))
|
||||
|
||||
if(object.has_key(firstNameKey))
|
||||
{
|
||||
bourne::json value = object[firstNameKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&firstName, value, "std::string");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *lastNameKey = "lastName";
|
||||
|
||||
if(object.has_key(lastNameKey))
|
||||
|
||||
if(object.has_key(lastNameKey))
|
||||
{
|
||||
bourne::json value = object[lastNameKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&lastName, value, "std::string");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *emailKey = "email";
|
||||
|
||||
if(object.has_key(emailKey))
|
||||
|
||||
if(object.has_key(emailKey))
|
||||
{
|
||||
bourne::json value = object[emailKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&email, value, "std::string");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *passwordKey = "password";
|
||||
|
||||
if(object.has_key(passwordKey))
|
||||
|
||||
if(object.has_key(passwordKey))
|
||||
{
|
||||
bourne::json value = object[passwordKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&password, value, "std::string");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *phoneKey = "phone";
|
||||
|
||||
if(object.has_key(phoneKey))
|
||||
|
||||
if(object.has_key(phoneKey))
|
||||
{
|
||||
bourne::json value = object[phoneKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&phone, value, "std::string");
|
||||
|
||||
|
||||
}
|
||||
|
||||
const char *userStatusKey = "userStatus";
|
||||
|
||||
if(object.has_key(userStatusKey))
|
||||
|
||||
if(object.has_key(userStatusKey))
|
||||
{
|
||||
bourne::json value = object[userStatusKey];
|
||||
|
||||
|
||||
|
||||
|
||||
jsonToValue(&userStatus, value, "int");
|
||||
|
||||
|
||||
@@ -143,56 +143,56 @@ User::toJson()
|
||||
{
|
||||
bourne::json object = bourne::json::object();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["id"] = getId();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["username"] = getUsername();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["firstName"] = getFirstName();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["lastName"] = getLastName();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["email"] = getEmail();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["password"] = getPassword();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
object["phone"] = getPhone();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user