[qt5cpp] Disable creation of empty json fields and handle prefix in model generation (#7206)

* Disable creation of empty json fields and fields for primitives which were not set, but using default values
modelnamePrefix will be the one passed from command line or SWG if none

* Updates after review
Also common http files are splitted
Update Petstore examples
This commit is contained in:
etherealjoy 2018-01-07 10:50:44 +01:00 committed by William Cheng
parent 0469975632
commit c7ff303779
36 changed files with 771 additions and 353 deletions

View File

@ -169,6 +169,20 @@ public class Qt5CPPGenerator extends AbstractCppCodegen implements CodegenConfig
}
additionalProperties.put("cppNamespaceDeclarations", cppNamespace.split("\\::"));
if(additionalProperties.containsKey("modelNamePrefix")){
supportingFiles.clear();
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, modelNamePrefix + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder, modelNamePrefix + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("HttpRequest.h.mustache", sourceFolder, modelNamePrefix + "HttpRequest.h"));
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, modelNamePrefix + "HttpRequest.cpp"));
supportingFiles.add(new SupportingFile("modelFactory.mustache", sourceFolder, modelNamePrefix + "ModelFactory.h"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, modelNamePrefix + "Object.h"));
typeMapping.put("object", modelNamePrefix + "Object");
typeMapping.put("file", modelNamePrefix + "HttpRequestInputFileElement");
importMapping.put("SWGHttpRequestInputFileElement", "#include \"" + modelNamePrefix + "HttpRequest.h\"");
additionalProperties().put("prefix", modelNamePrefix);
}
}
/**
@ -258,7 +272,7 @@ public class Qt5CPPGenerator extends AbstractCppCodegen implements CodegenConfig
@Override
public String toApiFilename(String name) {
return PREFIX + initialCaps(name) + "Api";
return modelNamePrefix + initialCaps(name) + "Api";
}
/**
@ -398,7 +412,7 @@ public class Qt5CPPGenerator extends AbstractCppCodegen implements CodegenConfig
@Override
public String toApiName(String type) {
return PREFIX + Character.toUpperCase(type.charAt(0)) + type.substring(1) + "Api";
return modelNamePrefix + Character.toUpperCase(type.charAt(0)) + type.substring(1) + "Api";
}
@Override

View File

@ -1,5 +1,5 @@
{{>licenseInfo}}
#include "SWGHttpRequest.h"
#include "{{prefix}}HttpRequest.h"
#include <QDateTime>
#include <QUrl>
#include <QFileInfo>
@ -11,28 +11,28 @@
namespace {{this}} {
{{/cppNamespaceDeclarations}}
HttpRequestInput::HttpRequestInput() {
{{prefix}}HttpRequestInput::{{prefix}}HttpRequestInput() {
initialize();
}
HttpRequestInput::HttpRequestInput(QString v_url_str, QString v_http_method) {
{{prefix}}HttpRequestInput::{{prefix}}HttpRequestInput(QString v_url_str, QString v_http_method) {
initialize();
url_str = v_url_str;
http_method = v_http_method;
}
void HttpRequestInput::initialize() {
void {{prefix}}HttpRequestInput::initialize() {
var_layout = NOT_SET;
url_str = "";
http_method = "GET";
}
void HttpRequestInput::add_var(QString key, QString value) {
void {{prefix}}HttpRequestInput::add_var(QString key, QString value) {
vars[key] = value;
}
void HttpRequestInput::add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type) {
SWGHttpRequestInputFileElement file;
void {{prefix}}HttpRequestInput::add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type) {
{{prefix}}HttpRequestInputFileElement file;
file.variable_name = variable_name;
file.local_filename = local_filename;
file.request_filename = request_filename;
@ -41,7 +41,7 @@ void HttpRequestInput::add_file(QString variable_name, QString local_filename, Q
}
HttpRequestWorker::HttpRequestWorker(QObject *parent)
{{prefix}}HttpRequestWorker::{{prefix}}HttpRequestWorker(QObject *parent)
: QObject(parent), manager(nullptr)
{
qsrand(QDateTime::currentDateTime().toTime_t());
@ -50,10 +50,10 @@ HttpRequestWorker::HttpRequestWorker(QObject *parent)
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(on_manager_finished(QNetworkReply*)));
}
HttpRequestWorker::~HttpRequestWorker() {
{{prefix}}HttpRequestWorker::~{{prefix}}HttpRequestWorker() {
}
QString HttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
QString {{prefix}}HttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
// result structure follows RFC 5987
bool need_utf_encoding = false;
QString result = "";
@ -101,7 +101,7 @@ QString HttpRequestWorker::http_attribute_encode(QString attribute_name, QString
return QString("%1=\"%2\"; %1*=utf-8''%3").arg(attribute_name, result, result_utf8);
}
void HttpRequestWorker::execute(HttpRequestInput *input) {
void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
// reset variables
@ -181,7 +181,7 @@ void HttpRequestWorker::execute(HttpRequestInput *input) {
}
// add files
for (QList<SWGHttpRequestInputFileElement>::iterator file_info = input->files.begin(); file_info != input->files.end(); file_info++) {
for (QList<{{prefix}}HttpRequestInputFileElement>::iterator file_info = input->files.begin(); file_info != input->files.end(); file_info++) {
QFileInfo fi(file_info->local_filename);
// ensure necessary variables are available
@ -253,8 +253,8 @@ void HttpRequestWorker::execute(HttpRequestInput *input) {
// prepare connection
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
if (HttpRequestWorker::sslDefaultConfiguration != nullptr) {
request.setSslConfiguration(*HttpRequestWorker::sslDefaultConfiguration);
if ({{prefix}}HttpRequestWorker::sslDefaultConfiguration != nullptr) {
request.setSslConfiguration(*{{prefix}}HttpRequestWorker::sslDefaultConfiguration);
}
request.setRawHeader("User-Agent", "Swagger-Client");
foreach(QString key, input->headers.keys()) {
@ -301,7 +301,7 @@ void HttpRequestWorker::execute(HttpRequestInput *input) {
}
void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
void {{prefix}}HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
error_type = reply->error();
response = reply->readAll();
error_str = reply->errorString();
@ -310,7 +310,7 @@ void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
emit on_execution_finished(this);
}
QSslConfiguration* HttpRequestWorker::sslDefaultConfiguration;
QSslConfiguration* {{prefix}}HttpRequestWorker::sslDefaultConfiguration;
{{#cppNamespaceDeclarations}}

View File

@ -5,8 +5,8 @@
*
**/
#ifndef HTTPREQUESTWORKER_H
#define HTTPREQUESTWORKER_H
#ifndef {{prefix}}_HTTPREQUESTWORKER_H
#define {{prefix}}_HTTPREQUESTWORKER_H
#include <QObject>
#include <QString>
@ -14,13 +14,15 @@
#include <QNetworkAccessManager>
#include <QNetworkReply>
enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
{{#cppNamespaceDeclarations}}
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class SWGHttpRequestInputFileElement {
enum {{prefix}}HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
class {{prefix}}HttpRequestInputFileElement {
public:
QString variable_name;
@ -31,19 +33,19 @@ public:
};
class HttpRequestInput {
class {{prefix}}HttpRequestInput {
public:
QString url_str;
QString http_method;
HttpRequestVarLayout var_layout;
{{prefix}}HttpRequestVarLayout var_layout;
QMap<QString, QString> vars;
QMap<QString, QString> headers;
QList<SWGHttpRequestInputFileElement> files;
QList<{{prefix}}HttpRequestInputFileElement> files;
QByteArray request_body;
HttpRequestInput();
HttpRequestInput(QString v_url_str, QString v_http_method);
{{prefix}}HttpRequestInput();
{{prefix}}HttpRequestInput(QString v_url_str, QString v_http_method);
void initialize();
void add_var(QString key, QString value);
void add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type);
@ -51,7 +53,7 @@ public:
};
class HttpRequestWorker : public QObject {
class {{prefix}}HttpRequestWorker : public QObject {
Q_OBJECT
public:
@ -59,15 +61,15 @@ public:
QNetworkReply::NetworkError error_type;
QString error_str;
explicit HttpRequestWorker(QObject *parent = 0);
virtual ~HttpRequestWorker();
explicit {{prefix}}HttpRequestWorker(QObject *parent = 0);
virtual ~{{prefix}}HttpRequestWorker();
QString http_attribute_encode(QString attribute_name, QString input);
void execute(HttpRequestInput *input);
void execute({{prefix}}HttpRequestInput *input);
static QSslConfiguration* sslDefaultConfiguration;
signals:
void on_execution_finished(HttpRequestWorker *worker);
void on_execution_finished({{prefix}}HttpRequestWorker *worker);
private:
QNetworkAccessManager *manager;
@ -81,4 +83,4 @@ private slots:
}
{{/cppNamespaceDeclarations}}
#endif // HTTPREQUESTWORKER_H
#endif // {{prefix}}_HTTPREQUESTWORKER_H

View File

@ -87,8 +87,8 @@ void
{{/collectionFormat}}
{{/queryParams}}
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "{{httpMethod}}");
{{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker();
{{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}");
{{#formParams}}
if ({{paramName}} != nullptr) {
@ -99,15 +99,16 @@ void
{{#bodyParams}}
{{#isContainer}}
QJsonArray* {{paramName}}Array = new QJsonArray();
toJsonArray((QList<void*>*){{paramName}}, {{paramName}}Array, QString("body"), QString("SWGUser*"));
toJsonArray((QList<void*>*){{paramName}}, {{paramName}}Array, QString("body"), QString("{{prefix}}User*"));
QJsonDocument doc(*{{paramName}}Array);
QByteArray bytes = doc.toJson();
input.request_body.append(bytes);
{{/isContainer}}
{{^isContainer}}
QString output = {{paramName}}.asJson();
{{^isContainer}}{{#isString}}
QString output(*{{paramName}});{{/isString}}{{^isString}}
QString output = {{paramName}}.asJson();{{/isString}}
input.request_body.append(output);
{{/isContainer}}{{/bodyParams}}
@ -122,7 +123,7 @@ void
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&{{prefix}}HttpRequestWorker::on_execution_finished,
this,
&{{classname}}::{{nickname}}Callback);
@ -130,7 +131,7 @@ void
}
void
{{classname}}::{{nickname}}Callback(HttpRequestWorker * worker) {
{{classname}}::{{nickname}}Callback({{prefix}}HttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -159,10 +160,10 @@ void
}
{{/isListContainer}}
{{^isListContainer}}
{{^isListContainer}}{{^isMapContainer}}
{{#returnTypeIsPrimitive}}
{{{returnType}}} output; // TODO add primitive output support
{{/returnTypeIsPrimitive}}
{{/returnTypeIsPrimitive}}{{/isMapContainer}}
{{#isMapContainer}}
{{{returnType}}} output = {{{defaultResponse}}};
QString json(worker->response);

View File

@ -1,6 +1,6 @@
{{>licenseInfo}}
#ifndef _SWG_{{classname}}_H_
#define _SWG_{{classname}}_H_
#ifndef _{{prefix}}_{{classname}}_H_
#define _{{prefix}}_{{classname}}_H_
#include "{{prefix}}HttpRequest.h"
@ -28,14 +28,14 @@ public:
{{#operations}}{{#operation}}void {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/operation}}{{/operations}}
private:
{{#operations}}{{#operation}}void {{nickname}}Callback (HttpRequestWorker * worker);
{{#operations}}{{#operation}}void {{nickname}}Callback ({{prefix}}HttpRequestWorker * worker);
{{/operation}}{{/operations}}
signals:
{{#operations}}{{#operation}}void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}});
{{/operation}}{{/operations}}
{{#operations}}{{#operation}}void {{nickname}}SignalE({{#returnType}}{{{returnType}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, QString& error_str);
{{/operation}}{{/operations}}
{{#operations}}{{#operation}}void {{nickname}}SignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
{{#operations}}{{#operation}}void {{nickname}}SignalEFull({{prefix}}HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
{{/operation}}{{/operations}}
};

View File

@ -1,7 +1,7 @@
{{>licenseInfo}}
#include "SWGHelpers.h"
#include "SWGModelFactory.h"
#include "SWGObject.h"
#include "{{prefix}}Helpers.h"
#include "{{prefix}}ModelFactory.h"
#include "{{prefix}}Object.h"
#include <QDebug>
#include <QJsonArray>
#include <QJsonValue>
@ -119,31 +119,31 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
qDebug() << "Can't set value because the target pointer is nullptr";
}
}
else if(type.startsWith("SWG") && obj.isObject()) {
else if(type.startsWith("{{prefix}}") && obj.isObject()) {
// complex type
QJsonObject jsonObj = obj.toObject();
SWGObject * so = (SWGObject*)::{{cppNamespace}}::create(type);
{{prefix}}Object * so = ({{prefix}}Object*)::{{cppNamespace}}::create(type);
if(so != nullptr) {
so->fromJsonObject(jsonObj);
SWGObject **val = static_cast<SWGObject**>(value);
{{prefix}}Object **val = static_cast<{{prefix}}Object**>(value);
delete *val;
*val = so;
}
}
else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) {
// list of values
if(complexType.startsWith("SWG")) {
QList<SWGObject*>* output = new QList<SWGObject*>();
if(complexType.startsWith("{{prefix}}")) {
QList<{{prefix}}Object*>* output = new QList<{{prefix}}Object*>();
QJsonArray arr = obj.toArray();
for (const QJsonValue & jval : arr) {
// it's an object
SWGObject * val = (SWGObject*)create(complexType);
{{prefix}}Object * val = ({{prefix}}Object*)create(complexType);
QJsonObject t = jval.toObject();
val->fromJsonObject(t);
output->append(val);
}
QList<SWGObject*> **val = static_cast<QList<SWGObject*>**>(value);
QList<{{prefix}}Object*> **val = static_cast<QList<{{prefix}}Object*>**>(value);
for (auto item : **val) {
delete item;
}
@ -247,10 +247,10 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
if(value == nullptr) {
return;
}
if(type.startsWith("SWG")) {
SWGObject *swgObject = reinterpret_cast<SWGObject *>(value);
if(swgObject != nullptr) {
QJsonObject* o = (*swgObject).asJsonObject();
if(type.startsWith("{{prefix}}")) {
{{prefix}}Object *{{prefix}}object = reinterpret_cast<{{prefix}}Object *>(value);
if({{prefix}}object != nullptr) {
QJsonObject* o = (*{{prefix}}object).asJsonObject();
if(name != nullptr) {
output->insert(name, *o);
delete o;
@ -303,11 +303,11 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
void
toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
if(innerType.startsWith("SWG")){
if(innerType.startsWith("{{prefix}}")){
for(void* obj : *value) {
SWGObject *swgObject = reinterpret_cast<SWGObject *>(obj);
if(swgObject != nullptr) {
output->append(*(swgObject->asJsonObject()));
{{prefix}}Object *{{prefix}}object = reinterpret_cast<{{prefix}}Object *>(obj);
if({{prefix}}object != nullptr) {
output->append(*({{prefix}}object->asJsonObject()));
}
}
}

View File

@ -1,6 +1,6 @@
{{>licenseInfo}}
#ifndef SWGHELPERS_H
#define SWGHELPERS_H
#ifndef {{prefix}}_HELPERS_H
#define {{prefix}}_HELPERS_H
#include <QJsonValue>
@ -21,4 +21,4 @@ namespace {{this}} {
}
{{/cppNamespaceDeclarations}}
#endif // SWGHELPERS_H
#endif // {{prefix}}_HELPERS_H

View File

@ -2,7 +2,7 @@
{{#models}}{{#model}}
#include "{{classname}}.h"
#include "SWGHelpers.h"
#include "{{prefix}}Helpers.h"
#include <QJsonDocument>
#include <QJsonArray>
@ -30,6 +30,7 @@ void
{{classname}}::init() {
{{#vars}}
{{name}} = {{{defaultValue}}};
m_{{name}}_isSet = false;
{{/vars}}
}
@ -106,7 +107,18 @@ QJsonObject*
{{#complexType}}
{{^isContainer}}
{{#complexType}}
toJsonValue(QString("{{baseName}}"), {{name}}, obj, QString("{{complexType}}"));
{{^isString}}
{{^isDateTime}}
if({{name}}->isSet()){
toJsonValue(QString("{{baseName}}"), {{name}}, obj, QString("{{complexType}}"));
}
{{/isDateTime}}
{{/isString}}
{{#isString}}
if({{name}} != nullptr && *{{name}} != QString("")){
toJsonValue(QString("{{baseName}}"), {{name}}, obj, QString("{{complexType}}"));
}
{{/isString}}
{{/complexType}}
{{^complexType}}
if({{name}} != nullptr && *{{name}} != nullptr) {
@ -115,33 +127,52 @@ QJsonObject*
{{/complexType}}
{{/isContainer}}
{{#isListContainer}}
QJsonArray {{name}}JsonArray;
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{complexType}}");
obj->insert("{{baseName}}", {{name}}JsonArray);
if({{name}}->size() > 0){
QJsonArray {{name}}JsonArray;
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{complexType}}");
obj->insert("{{baseName}}", {{name}}JsonArray);
}
{{/isListContainer}}
{{#isMapContainer}}
QJsonObject {{name}}_jobj;
for(auto keyval : {{name}}->keys()){
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{complexType}}");
}
obj->insert("{{baseName}}", {{name}}_jobj);
if({{name}}->size() > 0) {
QJsonObject {{name}}_jobj;
for(auto keyval : {{name}}->keys()){
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{complexType}}");
}
obj->insert("{{baseName}}", {{name}}_jobj);
}
{{/isMapContainer}}
{{/complexType}}
{{^complexType}}
{{^isContainer}}
obj->insert("{{baseName}}", QJsonValue({{name}}));
{{^isString}}
{{^isDateTime}}
if(m_{{name}}_isSet){
obj->insert("{{baseName}}", QJsonValue({{name}}));
}
{{/isDateTime}}
{{/isString}}
{{#isString}}
if({{name}} != nullptr && *{{name}} != QString("")) {
obj->insert("{{name}}", QJsonValue(*{{name}}));
}
{{/isString}}
{{/isContainer}}
{{#isListContainer}}
QJsonArray {{name}}JsonArray;
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{items.baseType}}");
obj->insert("{{baseName}}", {{name}}JsonArray);
if({{name}}->size() > 0){
QJsonArray {{name}}JsonArray;
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{items.baseType}}");
obj->insert("{{baseName}}", {{name}}JsonArray);
}
{{/isListContainer}}
{{#isMapContainer}}
QJsonObject {{name}}_jobj;
for(auto keyval : {{name}}->keys()){
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{items.baseType}}");
}
obj->insert("{{baseName}}", {{name}}_jobj);
if({{name}}->size() > 0){
QJsonObject {{name}}_jobj;
for(auto keyval : {{name}}->keys()){
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{items.baseType}}");
}
obj->insert("{{baseName}}", {{name}}_jobj);
}
{{/isMapContainer}}
{{/complexType}}
{{/vars}}
@ -157,10 +188,21 @@ QJsonObject*
void
{{classname}}::{{setter}}({{{datatype}}} {{name}}) {
this->{{name}} = {{name}};
this->m_{{name}}_isSet = true;
}
{{/vars}}
bool
{{classname}}::isSet(){
bool isObjectUpdated = false;
do{
{{#vars}}
{{#isPrimitiveType}}if(m_{{name}}_isSet){ isObjectUpdated = true; break;}{{/isPrimitiveType}}{{#isContainer}}if({{name}}->size() > 0){ isObjectUpdated = true; break;}{{/isContainer}}{{^isContainer}}{{#complexType}}{{^isString}}{{^isDateTime}}if({{name}} != nullptr && {{name}}->isSet()){ isObjectUpdated = true; break;}{{/isDateTime}}{{/isString}}{{#isString}}if({{name}} != nullptr && *{{name}} != QString("")){ isObjectUpdated = true; break;}{{/isString}}{{/complexType}}{{/isContainer}}
{{/vars}}
}while(false);
return isObjectUpdated;
}
{{#cppNamespaceDeclarations}}
}
{{/cppNamespaceDeclarations}}

View File

@ -14,7 +14,7 @@
{{#imports}}{{{import}}}
{{/imports}}
#include "SWGObject.h"
#include "{{prefix}}Object.h"
{{#models}}
{{#model}}
@ -22,7 +22,7 @@
namespace {{this}} {
{{/cppNamespaceDeclarations}}
class {{classname}}: public SWGObject {
class {{classname}}: public {{prefix}}Object {
public:
{{classname}}();
{{classname}}(QString* json);
@ -41,9 +41,13 @@ public:
{{/vars}}
virtual bool isSet() override;
private:
{{#vars}}
{{{datatype}}} {{name}};
bool m_{{name}}_isSet;
{{/vars}}
};

View File

@ -20,7 +20,7 @@ namespace {{this}} {
inline void* create(QString json, QString type) {
void* val = create(type);
if(val != nullptr) {
SWGObject* obj = static_cast<SWGObject*>(val);
{{prefix}}Object* obj = static_cast<{{prefix}}Object*>(val);
return obj->fromJson(json);
}
if(type.startsWith("QString")) {

View File

@ -11,12 +11,12 @@ namespace {{this}} {
class {{prefix}}Object {
public:
virtual QJsonObject* asJsonObject() {
return nullptr;
return new QJsonObject();
}
virtual ~SWGObject() {}
virtual SWGObject* fromJson(QString &jsonString) {
virtual ~{{prefix}}Object() {}
virtual {{prefix}}Object* fromJson(QString &jsonString) {
Q_UNUSED(jsonString);
return nullptr;
return new {{prefix}}Object();
}
virtual void fromJsonObject(QJsonObject &json) {
Q_UNUSED(json);
@ -24,6 +24,9 @@ class {{prefix}}Object {
virtual QString asJson() {
return QString("");
}
virtual bool isSet() {
return false;
}
};
{{#cppNamespaceDeclarations}}

View File

@ -18,8 +18,8 @@ SWGPetApi* PetApiTests::getApi() {
return api;
}
Pet* PetApiTests::createRandomPet() {
Pet* pet = new Pet();
SWGPet* PetApiTests::createRandomPet() {
SWGPet* pet = new SWGPet();
qint64 id = QDateTime::currentMSecsSinceEpoch();
pet->setName(new QString("monster"));
@ -43,8 +43,8 @@ void PetApiTests::findPetsByStatusTest() {
timer.setInterval(14000);
timer.setSingleShot(true);
auto validator = [](QList<Pet*>* pets) {
foreach(Pet* pet, *pets) {
auto validator = [](QList<SWGPet*>* pets) {
foreach(SWGPet* pet, *pets) {
QVERIFY(pet->getStatus()->startsWith("available") || pet->getStatus()->startsWith("sold"));
}
loop.quit();
@ -79,7 +79,7 @@ void PetApiTests::createAndGetPetTest() {
connect(api, &SWGPetApi::addPetSignal, this, validator);
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
Pet* pet = createRandomPet();
SWGPet* pet = createRandomPet();
qint64 id = pet->getId();
api->addPet(*pet);
@ -90,7 +90,7 @@ void PetApiTests::createAndGetPetTest() {
timer.setInterval(1000);
timer.setSingleShot(true);
auto getPetValidator = [](Pet* pet) {
auto getPetValidator = [](SWGPet* pet) {
QVERIFY(pet->getId() > 0);
QVERIFY(pet->getStatus()->compare("freaky") == 0);
loop.quit();
@ -109,8 +109,8 @@ void PetApiTests::createAndGetPetTest() {
void PetApiTests::updatePetTest() {
static SWGPetApi* api = getApi();
Pet* pet = createRandomPet();
static Pet* petToCheck;
SWGPet* pet = createRandomPet();
static SWGPet* petToCheck;
qint64 id = pet->getId();
static QEventLoop loop;
QTimer timer;
@ -134,7 +134,7 @@ void PetApiTests::updatePetTest() {
timer.setInterval(1000);
timer.setSingleShot(true);
auto fetchPet = [](Pet* pet) {
auto fetchPet = [](SWGPet* pet) {
petToCheck = pet;
loop.quit();
};
@ -168,7 +168,7 @@ void PetApiTests::updatePetTest() {
timer.setInterval(1000);
timer.setSingleShot(true);
auto fetchPet2 = [](Pet* pet) {
auto fetchPet2 = [](SWGPet* pet) {
QVERIFY(pet->getId() == petToCheck->getId());
QVERIFY(pet->getStatus()->compare(petToCheck->getStatus()) == 0);
loop.quit();
@ -184,8 +184,8 @@ void PetApiTests::updatePetTest() {
void PetApiTests::updatePetWithFormTest() {
static SWGPetApi* api = getApi();
Pet* pet = createRandomPet();
static Pet* petToCheck;
SWGPet* pet = createRandomPet();
static SWGPet* petToCheck;
qint64 id = pet->getId();
static QEventLoop loop;
QTimer timer;
@ -209,7 +209,7 @@ void PetApiTests::updatePetWithFormTest() {
timer.setInterval(1000);
timer.setSingleShot(true);
auto fetchPet = [](Pet* pet) {
auto fetchPet = [](SWGPet* pet) {
petToCheck = pet;
loop.quit();
};
@ -237,7 +237,7 @@ void PetApiTests::updatePetWithFormTest() {
timer.setInterval(1000);
timer.setSingleShot(true);
auto fetchUpdatedPet = [](Pet* pet) {
auto fetchUpdatedPet = [](SWGPet* pet) {
QVERIFY(pet->getName()->compare(QString("gorilla")) == 0);
loop.quit();
};

View File

@ -18,7 +18,7 @@ public:
private:
SWGPetApi* getApi();
Pet* createRandomPet();
SWGPet* createRandomPet();
signals:
void quit();

View File

@ -38,8 +38,11 @@ SWGApiResponse::~SWGApiResponse() {
void
SWGApiResponse::init() {
code = 0;
m_code_isSet = false;
type = new QString("");
m_type_isSet = false;
message = new QString("");
m_message_isSet = false;
}
void
@ -82,9 +85,15 @@ SWGApiResponse::asJson ()
QJsonObject*
SWGApiResponse::asJsonObject() {
QJsonObject* obj = new QJsonObject();
obj->insert("code", QJsonValue(code));
toJsonValue(QString("type"), type, obj, QString("QString"));
toJsonValue(QString("message"), message, obj, QString("QString"));
if(m_code_isSet){
obj->insert("code", QJsonValue(code));
}
if(type != nullptr && *type != QString("")){
toJsonValue(QString("type"), type, obj, QString("QString"));
}
if(message != nullptr && *message != QString("")){
toJsonValue(QString("message"), message, obj, QString("QString"));
}
return obj;
}
@ -96,6 +105,7 @@ SWGApiResponse::getCode() {
void
SWGApiResponse::setCode(qint32 code) {
this->code = code;
this->m_code_isSet = true;
}
QString*
@ -105,6 +115,7 @@ SWGApiResponse::getType() {
void
SWGApiResponse::setType(QString* type) {
this->type = type;
this->m_type_isSet = true;
}
QString*
@ -114,8 +125,19 @@ SWGApiResponse::getMessage() {
void
SWGApiResponse::setMessage(QString* message) {
this->message = message;
this->m_message_isSet = true;
}
bool
SWGApiResponse::isSet(){
bool isObjectUpdated = false;
do{
if(m_code_isSet){ isObjectUpdated = true; break;}
if(type != nullptr && *type != QString("")){ isObjectUpdated = true; break;}
if(message != nullptr && *message != QString("")){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -51,10 +51,18 @@ public:
void setMessage(QString* message);
virtual bool isSet() override;
private:
qint32 code;
bool m_code_isSet;
QString* type;
bool m_type_isSet;
QString* message;
bool m_message_isSet;
};
}

View File

@ -38,7 +38,9 @@ SWGCategory::~SWGCategory() {
void
SWGCategory::init() {
id = 0L;
m_id_isSet = false;
name = new QString("");
m_name_isSet = false;
}
void
@ -77,8 +79,12 @@ SWGCategory::asJson ()
QJsonObject*
SWGCategory::asJsonObject() {
QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id));
toJsonValue(QString("name"), name, obj, QString("QString"));
if(m_id_isSet){
obj->insert("id", QJsonValue(id));
}
if(name != nullptr && *name != QString("")){
toJsonValue(QString("name"), name, obj, QString("QString"));
}
return obj;
}
@ -90,6 +96,7 @@ SWGCategory::getId() {
void
SWGCategory::setId(qint64 id) {
this->id = id;
this->m_id_isSet = true;
}
QString*
@ -99,8 +106,18 @@ SWGCategory::getName() {
void
SWGCategory::setName(QString* name) {
this->name = name;
this->m_name_isSet = true;
}
bool
SWGCategory::isSet(){
bool isObjectUpdated = false;
do{
if(m_id_isSet){ isObjectUpdated = true; break;}
if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -48,9 +48,15 @@ public:
void setName(QString* name);
virtual bool isSet() override;
private:
qint64 id;
bool m_id_isSet;
QString* name;
bool m_name_isSet;
};
}

View File

@ -141,10 +141,10 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
}
else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) {
// list of values
QList<void*>* output = new QList<void*>();
QJsonArray arr = obj.toArray();
foreach (const QJsonValue & jval, arr) {
if(complexType.startsWith("SWG")) {
if(complexType.startsWith("SWG")) {
QList<SWGObject*>* output = new QList<SWGObject*>();
QJsonArray arr = obj.toArray();
for (const QJsonValue & jval : arr) {
// it's an object
SWGObject * val = (SWGObject*)create(complexType);
QJsonObject t = jval.toObject();
@ -152,53 +152,102 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
val->fromJsonObject(t);
output->append(val);
}
else {
// primitives
if(QStringLiteral("qint32").compare(complexType) == 0) {
qint32 val;
setValue(&val, jval, QStringLiteral("qint32"), QStringLiteral(""));
output->append((void*)&val);
}
else if(QStringLiteral("qint64").compare(complexType) == 0) {
qint64 val;
setValue(&val, jval, QStringLiteral("qint64"), QStringLiteral(""));
output->append((void*)&val);
}
else if(QStringLiteral("bool").compare(complexType) == 0) {
bool val;
setValue(&val, jval, QStringLiteral("bool"), QStringLiteral(""));
output->append((void*)&val);
}
else if(QStringLiteral("float").compare(complexType) == 0) {
float val;
setValue(&val, jval, QStringLiteral("float"), QStringLiteral(""));
output->append((void*)&val);
}
else if(QStringLiteral("double").compare(complexType) == 0) {
double val;
setValue(&val, jval, QStringLiteral("double"), QStringLiteral(""));
output->append((void*)&val);
}
else if(QStringLiteral("QString").compare(complexType) == 0) {
QString * val = new QString();
setValue(&val, jval, QStringLiteral("QString"), QStringLiteral(""));
output->append((void*)val);
}
else if(QStringLiteral("QDate").compare(complexType) == 0) {
QDate * val = new QDate();
setValue(&val, jval, QStringLiteral("QDate"), QStringLiteral(""));
output->append((void*)val);
}
else if(QStringLiteral("QDateTime").compare(complexType) == 0) {
QDateTime * val = new QDateTime();
setValue(&val, jval, QStringLiteral("QDateTime"), QStringLiteral(""));
output->append((void*)val);
}
QList<SWGObject*> **val = static_cast<QList<SWGObject*>**>(value);
for (auto item : **val) {
delete item;
}
delete *val;
*val = output;
}
else if(QStringLiteral("qint32").compare(complexType) == 0) {
QList<qint32> **output = reinterpret_cast<QList<qint32> **> (value);
(*output)->clear();
QJsonArray arr = obj.toArray();
for (const QJsonValue & jval : arr){
qint32 val;
setValue(&val, jval, QStringLiteral("qint32"), QStringLiteral(""));
(*output)->push_back(val);
}
}
else if(QStringLiteral("qint64").compare(complexType) == 0) {
QList<qint64> **output = reinterpret_cast<QList<qint64> **> (value);
(*output)->clear();
QJsonArray arr = obj.toArray();
for (const QJsonValue & jval : arr){
qint64 val;
setValue(&val, jval, QStringLiteral("qint64"), QStringLiteral(""));
(*output)->push_back(val);
}
}
else if(QStringLiteral("bool").compare(complexType) == 0) {
QList<bool> **output = reinterpret_cast<QList<bool> **> (value);
(*output)->clear();
QJsonArray arr = obj.toArray();
for (const QJsonValue & jval : arr){
bool val;
setValue(&val, jval, QStringLiteral("bool"), QStringLiteral(""));
(*output)->push_back(val);
}
}
else if(QStringLiteral("float").compare(complexType) == 0) {
QList<float> **output = reinterpret_cast<QList<float> **> (value);
(*output)->clear();
QJsonArray arr = obj.toArray();
for (const QJsonValue & jval : arr){
float val;
setValue(&val, jval, QStringLiteral("float"), QStringLiteral(""));
(*output)->push_back(val);
}
}
else if(QStringLiteral("double").compare(complexType) == 0) {
QList<double> **output = reinterpret_cast<QList<double> **> (value);
(*output)->clear();
QJsonArray arr = obj.toArray();
for (const QJsonValue & jval : arr){
double val;
setValue(&val, jval, QStringLiteral("double"), QStringLiteral(""));
(*output)->push_back(val);
}
}
else if(QStringLiteral("QString").compare(complexType) == 0) {
QList<QString*> **output = reinterpret_cast<QList<QString*> **> (value);
for (auto item : **output) {
delete item;
}
(*output)->clear();
QJsonArray arr = obj.toArray();
for (const QJsonValue & jval : arr){
QString * val = new QString();
setValue(&val, jval, QStringLiteral("QString"), QStringLiteral(""));
(*output)->push_back(val);
}
}
else if(QStringLiteral("QDate").compare(complexType) == 0) {
QList<QDate*> **output = reinterpret_cast<QList<QDate*> **> (value);
for (auto item : **output) {
delete item;
}
(*output)->clear();
QJsonArray arr = obj.toArray();
for (const QJsonValue & jval : arr){
QDate * val = new QDate();
setValue(&val, jval, QStringLiteral("QDate"), QStringLiteral(""));
(*output)->push_back(val);
}
}
else if(QStringLiteral("QDateTime").compare(complexType) == 0) {
QList<QDateTime*> **output = reinterpret_cast<QList<QDateTime*> **> (value);
for (auto item : **output) {
delete item;
}
(*output)->clear();
QJsonArray arr = obj.toArray();
for (const QJsonValue & jval : arr){
QDateTime * val = new QDateTime();
setValue(&val, jval, QStringLiteral("QDateTime"), QStringLiteral(""));
(*output)->push_back(val);
}
}
QList<void*> **val = static_cast<QList<void*>**>(value);
delete *val;
*val = output;
}
}
@ -208,16 +257,16 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
return;
}
if(type.startsWith("SWG")) {
SWGObject *swgObject = reinterpret_cast<SWGObject *>(value);
if(swgObject != nullptr) {
QJsonObject* o = (*swgObject).asJsonObject();
SWGObject *SWGobject = reinterpret_cast<SWGObject *>(value);
if(SWGobject != nullptr) {
QJsonObject* o = (*SWGobject).asJsonObject();
if(name != nullptr) {
output->insert(name, *o);
delete o;
}
else {
output->empty();
foreach(QString key, o->keys()) {
for(QString key : o->keys()) {
output->insert(key, o->value(key));
}
}
@ -263,11 +312,52 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
void
toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
foreach(void* obj, *value) {
QJsonObject element;
toJsonValue(nullptr, obj, &element, innerType);
output->append(element);
if(innerType.startsWith("SWG")){
for(void* obj : *value) {
SWGObject *SWGobject = reinterpret_cast<SWGObject *>(obj);
if(SWGobject != nullptr) {
output->append(*(SWGobject->asJsonObject()));
}
}
}
else if(QStringLiteral("QString").compare(innerType) == 0) {
for(QString* obj : *(reinterpret_cast<QList<QString*>*>(value))){
output->append(QJsonValue(*obj));
}
}
else if(QStringLiteral("QDate").compare(innerType) == 0) {
for(QDate* obj : *(reinterpret_cast<QList<QDate*>*>(value))){
output->append(QJsonValue(obj->toString(Qt::ISODate)));
}
}
else if(QStringLiteral("QDateTime").compare(innerType) == 0) {
for(QDateTime* obj : *(reinterpret_cast<QList<QDateTime*>*>(value))){
output->append(QJsonValue(obj->toString(Qt::ISODate))); }
}
else if(QStringLiteral("QByteArray").compare(innerType) == 0) {
for(QByteArray* obj : *(reinterpret_cast<QList<QByteArray*>*>(value))){
output->append(QJsonValue(QString(obj->toBase64())));
}
}
else if(QStringLiteral("qint32").compare(innerType) == 0) {
for(qint32 obj : *(reinterpret_cast<QList<qint32>*>(value)))
output->append(QJsonValue(obj));
}
else if(QStringLiteral("qint64").compare(innerType) == 0) {
for(qint64 obj : *(reinterpret_cast<QList<qint64>*>(value)))
output->append(QJsonValue(obj));
}
else if(QStringLiteral("bool").compare(innerType) == 0) {
for(bool obj : *(reinterpret_cast<QList<bool>*>(value)))
output->append(QJsonValue(obj));
}
else if(QStringLiteral("float").compare(innerType) == 0) {
for(float obj : *(reinterpret_cast<QList<float>*>(value)))
output->append(QJsonValue(obj));
}
else if(QStringLiteral("double").compare(innerType) == 0) {
for(double obj : *(reinterpret_cast<QList<double>*>(value)))
output->append(QJsonValue(obj));
}
}

View File

@ -10,8 +10,8 @@
* Do not edit the class manually.
*/
#ifndef SWGHELPERS_H
#define SWGHELPERS_H
#ifndef SWG_HELPERS_H
#define SWG_HELPERS_H
#include <QJsonValue>
@ -28,4 +28,4 @@ namespace Swagger {
}
#endif // SWGHELPERS_H
#endif // SWG_HELPERS_H

View File

@ -20,27 +20,27 @@
namespace Swagger {
HttpRequestInput::HttpRequestInput() {
SWGHttpRequestInput::SWGHttpRequestInput() {
initialize();
}
HttpRequestInput::HttpRequestInput(QString v_url_str, QString v_http_method) {
SWGHttpRequestInput::SWGHttpRequestInput(QString v_url_str, QString v_http_method) {
initialize();
url_str = v_url_str;
http_method = v_http_method;
}
void HttpRequestInput::initialize() {
void SWGHttpRequestInput::initialize() {
var_layout = NOT_SET;
url_str = "";
http_method = "GET";
}
void HttpRequestInput::add_var(QString key, QString value) {
void SWGHttpRequestInput::add_var(QString key, QString value) {
vars[key] = value;
}
void HttpRequestInput::add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type) {
void SWGHttpRequestInput::add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type) {
SWGHttpRequestInputFileElement file;
file.variable_name = variable_name;
file.local_filename = local_filename;
@ -50,7 +50,7 @@ void HttpRequestInput::add_file(QString variable_name, QString local_filename, Q
}
HttpRequestWorker::HttpRequestWorker(QObject *parent)
SWGHttpRequestWorker::SWGHttpRequestWorker(QObject *parent)
: QObject(parent), manager(nullptr)
{
qsrand(QDateTime::currentDateTime().toTime_t());
@ -59,10 +59,10 @@ HttpRequestWorker::HttpRequestWorker(QObject *parent)
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(on_manager_finished(QNetworkReply*)));
}
HttpRequestWorker::~HttpRequestWorker() {
SWGHttpRequestWorker::~SWGHttpRequestWorker() {
}
QString HttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
QString SWGHttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
// result structure follows RFC 5987
bool need_utf_encoding = false;
QString result = "";
@ -110,7 +110,7 @@ QString HttpRequestWorker::http_attribute_encode(QString attribute_name, QString
return QString("%1=\"%2\"; %1*=utf-8''%3").arg(attribute_name, result, result_utf8);
}
void HttpRequestWorker::execute(HttpRequestInput *input) {
void SWGHttpRequestWorker::execute(SWGHttpRequestInput *input) {
// reset variables
@ -262,8 +262,8 @@ void HttpRequestWorker::execute(HttpRequestInput *input) {
// prepare connection
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
if (HttpRequestWorker::sslDefaultConfiguration != nullptr) {
request.setSslConfiguration(*HttpRequestWorker::sslDefaultConfiguration);
if (SWGHttpRequestWorker::sslDefaultConfiguration != nullptr) {
request.setSslConfiguration(*SWGHttpRequestWorker::sslDefaultConfiguration);
}
request.setRawHeader("User-Agent", "Swagger-Client");
foreach(QString key, input->headers.keys()) {
@ -310,7 +310,7 @@ void HttpRequestWorker::execute(HttpRequestInput *input) {
}
void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
void SWGHttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
error_type = reply->error();
response = reply->readAll();
error_str = reply->errorString();
@ -319,7 +319,7 @@ void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
emit on_execution_finished(this);
}
QSslConfiguration* HttpRequestWorker::sslDefaultConfiguration;
QSslConfiguration* SWGHttpRequestWorker::sslDefaultConfiguration;
}

View File

@ -16,8 +16,8 @@
*
**/
#ifndef HTTPREQUESTWORKER_H
#define HTTPREQUESTWORKER_H
#ifndef SWG_HTTPREQUESTWORKER_H
#define SWG_HTTPREQUESTWORKER_H
#include <QObject>
#include <QString>
@ -25,10 +25,12 @@
#include <QNetworkAccessManager>
#include <QNetworkReply>
enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
namespace Swagger {
enum SWGHttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
class SWGHttpRequestInputFileElement {
public:
@ -40,19 +42,19 @@ public:
};
class HttpRequestInput {
class SWGHttpRequestInput {
public:
QString url_str;
QString http_method;
HttpRequestVarLayout var_layout;
SWGHttpRequestVarLayout var_layout;
QMap<QString, QString> vars;
QMap<QString, QString> headers;
QList<SWGHttpRequestInputFileElement> files;
QByteArray request_body;
HttpRequestInput();
HttpRequestInput(QString v_url_str, QString v_http_method);
SWGHttpRequestInput();
SWGHttpRequestInput(QString v_url_str, QString v_http_method);
void initialize();
void add_var(QString key, QString value);
void add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type);
@ -60,7 +62,7 @@ public:
};
class HttpRequestWorker : public QObject {
class SWGHttpRequestWorker : public QObject {
Q_OBJECT
public:
@ -68,15 +70,15 @@ public:
QNetworkReply::NetworkError error_type;
QString error_str;
explicit HttpRequestWorker(QObject *parent = 0);
virtual ~HttpRequestWorker();
explicit SWGHttpRequestWorker(QObject *parent = 0);
virtual ~SWGHttpRequestWorker();
QString http_attribute_encode(QString attribute_name, QString input);
void execute(HttpRequestInput *input);
void execute(SWGHttpRequestInput *input);
static QSslConfiguration* sslDefaultConfiguration;
signals:
void on_execution_finished(HttpRequestWorker *worker);
void on_execution_finished(SWGHttpRequestWorker *worker);
private:
QNetworkAccessManager *manager;
@ -88,4 +90,4 @@ private slots:
}
#endif // HTTPREQUESTWORKER_H
#endif // SWG_HTTPREQUESTWORKER_H

View File

@ -20,12 +20,12 @@ namespace Swagger {
class SWGObject {
public:
virtual QJsonObject* asJsonObject() {
return nullptr;
return new QJsonObject();
}
virtual ~SWGObject() {}
virtual SWGObject* fromJson(QString &jsonString) {
Q_UNUSED(jsonString);
return nullptr;
return new SWGObject();
}
virtual void fromJsonObject(QJsonObject &json) {
Q_UNUSED(json);
@ -33,6 +33,9 @@ class SWGObject {
virtual QString asJson() {
return QString("");
}
virtual bool isSet() {
return false;
}
};
}

View File

@ -38,11 +38,17 @@ SWGOrder::~SWGOrder() {
void
SWGOrder::init() {
id = 0L;
m_id_isSet = false;
pet_id = 0L;
m_pet_id_isSet = false;
quantity = 0;
m_quantity_isSet = false;
ship_date = NULL;
m_ship_date_isSet = false;
status = new QString("");
m_status_isSet = false;
complete = false;
m_complete_isSet = false;
}
void
@ -91,12 +97,21 @@ SWGOrder::asJson ()
QJsonObject*
SWGOrder::asJsonObject() {
QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id));
obj->insert("petId", QJsonValue(pet_id));
obj->insert("quantity", QJsonValue(quantity));
toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
toJsonValue(QString("status"), status, obj, QString("QString"));
obj->insert("complete", QJsonValue(complete));
if(m_id_isSet){
obj->insert("id", QJsonValue(id));
}
if(m_pet_id_isSet){
obj->insert("petId", QJsonValue(pet_id));
}
if(m_quantity_isSet){
obj->insert("quantity", QJsonValue(quantity));
}
if(status != nullptr && *status != QString("")){
toJsonValue(QString("status"), status, obj, QString("QString"));
}
if(m_complete_isSet){
obj->insert("complete", QJsonValue(complete));
}
return obj;
}
@ -108,6 +123,7 @@ SWGOrder::getId() {
void
SWGOrder::setId(qint64 id) {
this->id = id;
this->m_id_isSet = true;
}
qint64
@ -117,6 +133,7 @@ SWGOrder::getPetId() {
void
SWGOrder::setPetId(qint64 pet_id) {
this->pet_id = pet_id;
this->m_pet_id_isSet = true;
}
qint32
@ -126,6 +143,7 @@ SWGOrder::getQuantity() {
void
SWGOrder::setQuantity(qint32 quantity) {
this->quantity = quantity;
this->m_quantity_isSet = true;
}
QDateTime*
@ -135,6 +153,7 @@ SWGOrder::getShipDate() {
void
SWGOrder::setShipDate(QDateTime* ship_date) {
this->ship_date = ship_date;
this->m_ship_date_isSet = true;
}
QString*
@ -144,6 +163,7 @@ SWGOrder::getStatus() {
void
SWGOrder::setStatus(QString* status) {
this->status = status;
this->m_status_isSet = true;
}
bool
@ -153,8 +173,22 @@ SWGOrder::isComplete() {
void
SWGOrder::setComplete(bool complete) {
this->complete = complete;
this->m_complete_isSet = true;
}
bool
SWGOrder::isSet(){
bool isObjectUpdated = false;
do{
if(m_id_isSet){ isObjectUpdated = true; break;}
if(m_pet_id_isSet){ isObjectUpdated = true; break;}
if(m_quantity_isSet){ isObjectUpdated = true; break;}
if(status != nullptr && *status != QString("")){ isObjectUpdated = true; break;}
if(m_complete_isSet){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -61,13 +61,27 @@ public:
void setComplete(bool complete);
virtual bool isSet() override;
private:
qint64 id;
bool m_id_isSet;
qint64 pet_id;
bool m_pet_id_isSet;
qint32 quantity;
bool m_quantity_isSet;
QDateTime* ship_date;
bool m_ship_date_isSet;
QString* status;
bool m_status_isSet;
bool complete;
bool m_complete_isSet;
};
}

View File

@ -38,11 +38,17 @@ SWGPet::~SWGPet() {
void
SWGPet::init() {
id = 0L;
m_id_isSet = false;
category = new SWGCategory();
m_category_isSet = false;
name = new QString("");
m_name_isSet = false;
photo_urls = new QList<QString*>();
m_photo_urls_isSet = false;
tags = new QList<SWGTag*>();
m_tags_isSet = false;
status = new QString("");
m_status_isSet = false;
}
void
@ -105,16 +111,28 @@ SWGPet::asJson ()
QJsonObject*
SWGPet::asJsonObject() {
QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id));
toJsonValue(QString("category"), category, obj, QString("SWGCategory"));
toJsonValue(QString("name"), name, obj, QString("QString"));
QJsonArray photo_urlsJsonArray;
toJsonArray((QList<void*>*)photo_urls, &photo_urlsJsonArray, "photo_urls", "QString");
obj->insert("photoUrls", photo_urlsJsonArray);
QJsonArray tagsJsonArray;
toJsonArray((QList<void*>*)tags, &tagsJsonArray, "tags", "SWGTag");
obj->insert("tags", tagsJsonArray);
toJsonValue(QString("status"), status, obj, QString("QString"));
if(m_id_isSet){
obj->insert("id", QJsonValue(id));
}
if(category->isSet()){
toJsonValue(QString("category"), category, obj, QString("SWGCategory"));
}
if(name != nullptr && *name != QString("")){
toJsonValue(QString("name"), name, obj, QString("QString"));
}
if(photo_urls->size() > 0){
QJsonArray photo_urlsJsonArray;
toJsonArray((QList<void*>*)photo_urls, &photo_urlsJsonArray, "photo_urls", "QString");
obj->insert("photoUrls", photo_urlsJsonArray);
}
if(tags->size() > 0){
QJsonArray tagsJsonArray;
toJsonArray((QList<void*>*)tags, &tagsJsonArray, "tags", "SWGTag");
obj->insert("tags", tagsJsonArray);
}
if(status != nullptr && *status != QString("")){
toJsonValue(QString("status"), status, obj, QString("QString"));
}
return obj;
}
@ -126,6 +144,7 @@ SWGPet::getId() {
void
SWGPet::setId(qint64 id) {
this->id = id;
this->m_id_isSet = true;
}
SWGCategory*
@ -135,6 +154,7 @@ SWGPet::getCategory() {
void
SWGPet::setCategory(SWGCategory* category) {
this->category = category;
this->m_category_isSet = true;
}
QString*
@ -144,6 +164,7 @@ SWGPet::getName() {
void
SWGPet::setName(QString* name) {
this->name = name;
this->m_name_isSet = true;
}
QList<QString*>*
@ -153,6 +174,7 @@ SWGPet::getPhotoUrls() {
void
SWGPet::setPhotoUrls(QList<QString*>* photo_urls) {
this->photo_urls = photo_urls;
this->m_photo_urls_isSet = true;
}
QList<SWGTag*>*
@ -162,6 +184,7 @@ SWGPet::getTags() {
void
SWGPet::setTags(QList<SWGTag*>* tags) {
this->tags = tags;
this->m_tags_isSet = true;
}
QString*
@ -171,8 +194,22 @@ SWGPet::getStatus() {
void
SWGPet::setStatus(QString* status) {
this->status = status;
this->m_status_isSet = true;
}
bool
SWGPet::isSet(){
bool isObjectUpdated = false;
do{
if(m_id_isSet){ isObjectUpdated = true; break;}
if(category != nullptr && category->isSet()){ isObjectUpdated = true; break;}
if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
if(photo_urls->size() > 0){ isObjectUpdated = true; break;}
if(tags->size() > 0){ isObjectUpdated = true; break;}
if(status != nullptr && *status != QString("")){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -63,13 +63,27 @@ public:
void setStatus(QString* status);
virtual bool isSet() override;
private:
qint64 id;
bool m_id_isSet;
SWGCategory* category;
bool m_category_isSet;
QString* name;
bool m_name_isSet;
QList<QString*>* photo_urls;
bool m_photo_urls_isSet;
QList<SWGTag*>* tags;
bool m_tags_isSet;
QString* status;
bool m_status_isSet;
};
}

View File

@ -35,10 +35,11 @@ SWGPetApi::addPet(SWGPet body) {
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "POST");
QString output = body.asJson();
input.request_body.append(output);
@ -49,7 +50,7 @@ SWGPetApi::addPet(SWGPet body) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::addPetCallback);
@ -57,7 +58,7 @@ SWGPetApi::addPet(SWGPet body) {
}
void
SWGPetApi::addPetCallback(HttpRequestWorker * worker) {
SWGPetApi::addPetCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -88,8 +89,8 @@ SWGPetApi::deletePet(qint64 pet_id, QString* api_key) {
fullPath.replace(pet_idPathParam, stringValue(pet_id));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "DELETE");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "DELETE");
@ -103,7 +104,7 @@ SWGPetApi::deletePet(qint64 pet_id, QString* api_key) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::deletePetCallback);
@ -111,7 +112,7 @@ SWGPetApi::deletePet(qint64 pet_id, QString* api_key) {
}
void
SWGPetApi::deletePetCallback(HttpRequestWorker * worker) {
SWGPetApi::deletePetCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -182,8 +183,8 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
}
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "GET");
@ -194,7 +195,7 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::findPetsByStatusCallback);
@ -202,7 +203,7 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
}
void
SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) {
SWGPetApi::findPetsByStatusCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -228,7 +229,7 @@ SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) {
output->append(o);
}
worker->deleteLater();
worker->deleteLater();
if (worker->error_type == QNetworkReply::NoError) {
emit findPetsByStatusSignal(output);
@ -287,8 +288,8 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
}
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "GET");
@ -299,7 +300,7 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::findPetsByTagsCallback);
@ -307,7 +308,7 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
}
void
SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) {
SWGPetApi::findPetsByTagsCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -333,7 +334,7 @@ SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) {
output->append(o);
}
worker->deleteLater();
worker->deleteLater();
if (worker->error_type == QNetworkReply::NoError) {
emit findPetsByTagsSignal(output);
@ -352,8 +353,8 @@ SWGPetApi::getPetById(qint64 pet_id) {
fullPath.replace(pet_idPathParam, stringValue(pet_id));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "GET");
@ -364,7 +365,7 @@ SWGPetApi::getPetById(qint64 pet_id) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::getPetByIdCallback);
@ -372,7 +373,7 @@ SWGPetApi::getPetById(qint64 pet_id) {
}
void
SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
SWGPetApi::getPetByIdCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -385,6 +386,8 @@ SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
}
QString json(worker->response);
SWGPet* output = static_cast<SWGPet*>(create(json, QString("SWGPet")));
worker->deleteLater();
@ -404,10 +407,11 @@ SWGPetApi::updatePet(SWGPet body) {
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "PUT");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "PUT");
QString output = body.asJson();
input.request_body.append(output);
@ -418,7 +422,7 @@ SWGPetApi::updatePet(SWGPet body) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::updatePetCallback);
@ -426,7 +430,7 @@ SWGPetApi::updatePet(SWGPet body) {
}
void
SWGPetApi::updatePetCallback(HttpRequestWorker * worker) {
SWGPetApi::updatePetCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -457,8 +461,8 @@ SWGPetApi::updatePetWithForm(qint64 pet_id, QString* name, QString* status) {
fullPath.replace(pet_idPathParam, stringValue(pet_id));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "POST");
if (name != nullptr) {
input.add_var("name", *name);
@ -475,7 +479,7 @@ SWGPetApi::updatePetWithForm(qint64 pet_id, QString* name, QString* status) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::updatePetWithFormCallback);
@ -483,7 +487,7 @@ SWGPetApi::updatePetWithForm(qint64 pet_id, QString* name, QString* status) {
}
void
SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) {
SWGPetApi::updatePetWithFormCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -514,8 +518,8 @@ SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpReques
fullPath.replace(pet_idPathParam, stringValue(pet_id));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "POST");
if (additional_metadata != nullptr) {
input.add_var("additionalMetadata", *additional_metadata);
@ -532,7 +536,7 @@ SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpReques
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGPetApi::uploadFileCallback);
@ -540,7 +544,7 @@ SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpReques
}
void
SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
SWGPetApi::uploadFileCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -553,6 +557,8 @@ SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
}
QString json(worker->response);
SWGApiResponse* output = static_cast<SWGApiResponse*>(create(json, QString("SWGApiResponse")));
worker->deleteLater();

View File

@ -46,14 +46,14 @@ public:
void uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file);
private:
void addPetCallback (HttpRequestWorker * worker);
void deletePetCallback (HttpRequestWorker * worker);
void findPetsByStatusCallback (HttpRequestWorker * worker);
void findPetsByTagsCallback (HttpRequestWorker * worker);
void getPetByIdCallback (HttpRequestWorker * worker);
void updatePetCallback (HttpRequestWorker * worker);
void updatePetWithFormCallback (HttpRequestWorker * worker);
void uploadFileCallback (HttpRequestWorker * worker);
void addPetCallback (SWGHttpRequestWorker * worker);
void deletePetCallback (SWGHttpRequestWorker * worker);
void findPetsByStatusCallback (SWGHttpRequestWorker * worker);
void findPetsByTagsCallback (SWGHttpRequestWorker * worker);
void getPetByIdCallback (SWGHttpRequestWorker * worker);
void updatePetCallback (SWGHttpRequestWorker * worker);
void updatePetWithFormCallback (SWGHttpRequestWorker * worker);
void uploadFileCallback (SWGHttpRequestWorker * worker);
signals:
void addPetSignal();
@ -74,14 +74,14 @@ signals:
void updatePetWithFormSignalE(QNetworkReply::NetworkError error_type, QString& error_str);
void uploadFileSignalE(SWGApiResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void addPetSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void deletePetSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void findPetsByStatusSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void findPetsByTagsSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void getPetByIdSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void updatePetSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void updatePetWithFormSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void uploadFileSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void addPetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void deletePetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void findPetsByStatusSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void findPetsByTagsSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void getPetByIdSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void updatePetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void updatePetWithFormSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void uploadFileSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
};

View File

@ -37,8 +37,8 @@ SWGStoreApi::deleteOrder(QString* order_id) {
fullPath.replace(order_idPathParam, stringValue(order_id));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "DELETE");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "DELETE");
@ -49,7 +49,7 @@ SWGStoreApi::deleteOrder(QString* order_id) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGStoreApi::deleteOrderCallback);
@ -57,7 +57,7 @@ SWGStoreApi::deleteOrder(QString* order_id) {
}
void
SWGStoreApi::deleteOrderCallback(HttpRequestWorker * worker) {
SWGStoreApi::deleteOrderCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -86,8 +86,8 @@ SWGStoreApi::getInventory() {
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "GET");
@ -98,7 +98,7 @@ SWGStoreApi::getInventory() {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGStoreApi::getInventoryCallback);
@ -106,7 +106,7 @@ SWGStoreApi::getInventory() {
}
void
SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) {
SWGStoreApi::getInventoryCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -119,7 +119,7 @@ SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) {
}
QMap<QString, qint32>* output; // TODO add primitive output support
QMap<QString, qint32>* output = new QMap<QString, qint32>();
QString json(worker->response);
QByteArray array (json.toStdString().c_str());
@ -150,8 +150,8 @@ SWGStoreApi::getOrderById(qint64 order_id) {
fullPath.replace(order_idPathParam, stringValue(order_id));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "GET");
@ -162,7 +162,7 @@ SWGStoreApi::getOrderById(qint64 order_id) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGStoreApi::getOrderByIdCallback);
@ -170,7 +170,7 @@ SWGStoreApi::getOrderById(qint64 order_id) {
}
void
SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
SWGStoreApi::getOrderByIdCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -183,6 +183,8 @@ SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
}
QString json(worker->response);
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
worker->deleteLater();
@ -202,10 +204,11 @@ SWGStoreApi::placeOrder(SWGOrder body) {
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "POST");
QString output = body.asJson();
input.request_body.append(output);
@ -216,7 +219,7 @@ SWGStoreApi::placeOrder(SWGOrder body) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGStoreApi::placeOrderCallback);
@ -224,7 +227,7 @@ SWGStoreApi::placeOrder(SWGOrder body) {
}
void
SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
SWGStoreApi::placeOrderCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -237,6 +240,8 @@ SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
}
QString json(worker->response);
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
worker->deleteLater();

View File

@ -41,10 +41,10 @@ public:
void placeOrder(SWGOrder body);
private:
void deleteOrderCallback (HttpRequestWorker * worker);
void getInventoryCallback (HttpRequestWorker * worker);
void getOrderByIdCallback (HttpRequestWorker * worker);
void placeOrderCallback (HttpRequestWorker * worker);
void deleteOrderCallback (SWGHttpRequestWorker * worker);
void getInventoryCallback (SWGHttpRequestWorker * worker);
void getOrderByIdCallback (SWGHttpRequestWorker * worker);
void placeOrderCallback (SWGHttpRequestWorker * worker);
signals:
void deleteOrderSignal();
@ -57,10 +57,10 @@ signals:
void getOrderByIdSignalE(SWGOrder* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void placeOrderSignalE(SWGOrder* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void deleteOrderSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void getInventorySignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void getOrderByIdSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void placeOrderSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void deleteOrderSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void getInventorySignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void getOrderByIdSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void placeOrderSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
};

View File

@ -38,7 +38,9 @@ SWGTag::~SWGTag() {
void
SWGTag::init() {
id = 0L;
m_id_isSet = false;
name = new QString("");
m_name_isSet = false;
}
void
@ -77,8 +79,12 @@ SWGTag::asJson ()
QJsonObject*
SWGTag::asJsonObject() {
QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id));
toJsonValue(QString("name"), name, obj, QString("QString"));
if(m_id_isSet){
obj->insert("id", QJsonValue(id));
}
if(name != nullptr && *name != QString("")){
toJsonValue(QString("name"), name, obj, QString("QString"));
}
return obj;
}
@ -90,6 +96,7 @@ SWGTag::getId() {
void
SWGTag::setId(qint64 id) {
this->id = id;
this->m_id_isSet = true;
}
QString*
@ -99,8 +106,18 @@ SWGTag::getName() {
void
SWGTag::setName(QString* name) {
this->name = name;
this->m_name_isSet = true;
}
bool
SWGTag::isSet(){
bool isObjectUpdated = false;
do{
if(m_id_isSet){ isObjectUpdated = true; break;}
if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -48,9 +48,15 @@ public:
void setName(QString* name);
virtual bool isSet() override;
private:
qint64 id;
bool m_id_isSet;
QString* name;
bool m_name_isSet;
};
}

View File

@ -38,13 +38,21 @@ SWGUser::~SWGUser() {
void
SWGUser::init() {
id = 0L;
m_id_isSet = false;
username = new QString("");
m_username_isSet = false;
first_name = new QString("");
m_first_name_isSet = false;
last_name = new QString("");
m_last_name_isSet = false;
email = new QString("");
m_email_isSet = false;
password = new QString("");
m_password_isSet = false;
phone = new QString("");
m_phone_isSet = false;
user_status = 0;
m_user_status_isSet = false;
}
void
@ -105,14 +113,30 @@ SWGUser::asJson ()
QJsonObject*
SWGUser::asJsonObject() {
QJsonObject* obj = new QJsonObject();
obj->insert("id", QJsonValue(id));
toJsonValue(QString("username"), username, obj, QString("QString"));
toJsonValue(QString("firstName"), first_name, obj, QString("QString"));
toJsonValue(QString("lastName"), last_name, obj, QString("QString"));
toJsonValue(QString("email"), email, obj, QString("QString"));
toJsonValue(QString("password"), password, obj, QString("QString"));
toJsonValue(QString("phone"), phone, obj, QString("QString"));
obj->insert("userStatus", QJsonValue(user_status));
if(m_id_isSet){
obj->insert("id", QJsonValue(id));
}
if(username != nullptr && *username != QString("")){
toJsonValue(QString("username"), username, obj, QString("QString"));
}
if(first_name != nullptr && *first_name != QString("")){
toJsonValue(QString("firstName"), first_name, obj, QString("QString"));
}
if(last_name != nullptr && *last_name != QString("")){
toJsonValue(QString("lastName"), last_name, obj, QString("QString"));
}
if(email != nullptr && *email != QString("")){
toJsonValue(QString("email"), email, obj, QString("QString"));
}
if(password != nullptr && *password != QString("")){
toJsonValue(QString("password"), password, obj, QString("QString"));
}
if(phone != nullptr && *phone != QString("")){
toJsonValue(QString("phone"), phone, obj, QString("QString"));
}
if(m_user_status_isSet){
obj->insert("userStatus", QJsonValue(user_status));
}
return obj;
}
@ -124,6 +148,7 @@ SWGUser::getId() {
void
SWGUser::setId(qint64 id) {
this->id = id;
this->m_id_isSet = true;
}
QString*
@ -133,6 +158,7 @@ SWGUser::getUsername() {
void
SWGUser::setUsername(QString* username) {
this->username = username;
this->m_username_isSet = true;
}
QString*
@ -142,6 +168,7 @@ SWGUser::getFirstName() {
void
SWGUser::setFirstName(QString* first_name) {
this->first_name = first_name;
this->m_first_name_isSet = true;
}
QString*
@ -151,6 +178,7 @@ SWGUser::getLastName() {
void
SWGUser::setLastName(QString* last_name) {
this->last_name = last_name;
this->m_last_name_isSet = true;
}
QString*
@ -160,6 +188,7 @@ SWGUser::getEmail() {
void
SWGUser::setEmail(QString* email) {
this->email = email;
this->m_email_isSet = true;
}
QString*
@ -169,6 +198,7 @@ SWGUser::getPassword() {
void
SWGUser::setPassword(QString* password) {
this->password = password;
this->m_password_isSet = true;
}
QString*
@ -178,6 +208,7 @@ SWGUser::getPhone() {
void
SWGUser::setPhone(QString* phone) {
this->phone = phone;
this->m_phone_isSet = true;
}
qint32
@ -187,8 +218,24 @@ SWGUser::getUserStatus() {
void
SWGUser::setUserStatus(qint32 user_status) {
this->user_status = user_status;
this->m_user_status_isSet = true;
}
bool
SWGUser::isSet(){
bool isObjectUpdated = false;
do{
if(m_id_isSet){ isObjectUpdated = true; break;}
if(username != nullptr && *username != QString("")){ isObjectUpdated = true; break;}
if(first_name != nullptr && *first_name != QString("")){ isObjectUpdated = true; break;}
if(last_name != nullptr && *last_name != QString("")){ isObjectUpdated = true; break;}
if(email != nullptr && *email != QString("")){ isObjectUpdated = true; break;}
if(password != nullptr && *password != QString("")){ isObjectUpdated = true; break;}
if(phone != nullptr && *phone != QString("")){ isObjectUpdated = true; break;}
if(m_user_status_isSet){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -66,15 +66,33 @@ public:
void setUserStatus(qint32 user_status);
virtual bool isSet() override;
private:
qint64 id;
bool m_id_isSet;
QString* username;
bool m_username_isSet;
QString* first_name;
bool m_first_name_isSet;
QString* last_name;
bool m_last_name_isSet;
QString* email;
bool m_email_isSet;
QString* password;
bool m_password_isSet;
QString* phone;
bool m_phone_isSet;
qint32 user_status;
bool m_user_status_isSet;
};
}

View File

@ -35,10 +35,11 @@ SWGUserApi::createUser(SWGUser body) {
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "POST");
QString output = body.asJson();
input.request_body.append(output);
@ -49,7 +50,7 @@ SWGUserApi::createUser(SWGUser body) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::createUserCallback);
@ -57,7 +58,7 @@ SWGUserApi::createUser(SWGUser body) {
}
void
SWGUserApi::createUserCallback(HttpRequestWorker * worker) {
SWGUserApi::createUserCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -86,8 +87,8 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "POST");
QJsonArray* bodyArray = new QJsonArray();
@ -97,7 +98,7 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
QByteArray bytes = doc.toJson();
input.request_body.append(bytes);
foreach(QString key, this->defaultHeaders.keys()) {
@ -105,7 +106,7 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::createUsersWithArrayInputCallback);
@ -113,7 +114,7 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
}
void
SWGUserApi::createUsersWithArrayInputCallback(HttpRequestWorker * worker) {
SWGUserApi::createUsersWithArrayInputCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -142,8 +143,8 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "POST");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "POST");
QJsonArray* bodyArray = new QJsonArray();
@ -153,7 +154,7 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
QByteArray bytes = doc.toJson();
input.request_body.append(bytes);
foreach(QString key, this->defaultHeaders.keys()) {
@ -161,7 +162,7 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::createUsersWithListInputCallback);
@ -169,7 +170,7 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
}
void
SWGUserApi::createUsersWithListInputCallback(HttpRequestWorker * worker) {
SWGUserApi::createUsersWithListInputCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -200,8 +201,8 @@ SWGUserApi::deleteUser(QString* username) {
fullPath.replace(usernamePathParam, stringValue(username));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "DELETE");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "DELETE");
@ -212,7 +213,7 @@ SWGUserApi::deleteUser(QString* username) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::deleteUserCallback);
@ -220,7 +221,7 @@ SWGUserApi::deleteUser(QString* username) {
}
void
SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) {
SWGUserApi::deleteUserCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -251,8 +252,8 @@ SWGUserApi::getUserByName(QString* username) {
fullPath.replace(usernamePathParam, stringValue(username));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "GET");
@ -263,7 +264,7 @@ SWGUserApi::getUserByName(QString* username) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::getUserByNameCallback);
@ -271,7 +272,7 @@ SWGUserApi::getUserByName(QString* username) {
}
void
SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
SWGUserApi::getUserByNameCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -284,6 +285,8 @@ SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
}
QString json(worker->response);
SWGUser* output = static_cast<SWGUser*>(create(json, QString("SWGUser")));
worker->deleteLater();
@ -319,8 +322,8 @@ SWGUserApi::loginUser(QString* username, QString* password) {
.append(QUrl::toPercentEncoding(stringValue(password)));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "GET");
@ -331,7 +334,7 @@ SWGUserApi::loginUser(QString* username, QString* password) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::loginUserCallback);
@ -339,7 +342,7 @@ SWGUserApi::loginUser(QString* username, QString* password) {
}
void
SWGUserApi::loginUserCallback(HttpRequestWorker * worker) {
SWGUserApi::loginUserCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -352,6 +355,8 @@ SWGUserApi::loginUserCallback(HttpRequestWorker * worker) {
}
QString json(worker->response);
QString* output = static_cast<QString*>(create(json, QString("QString")));
worker->deleteLater();
@ -371,8 +376,8 @@ SWGUserApi::logoutUser() {
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "GET");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "GET");
@ -383,7 +388,7 @@ SWGUserApi::logoutUser() {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::logoutUserCallback);
@ -391,7 +396,7 @@ SWGUserApi::logoutUser() {
}
void
SWGUserApi::logoutUserCallback(HttpRequestWorker * worker) {
SWGUserApi::logoutUserCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;
@ -422,10 +427,11 @@ SWGUserApi::updateUser(QString* username, SWGUser body) {
fullPath.replace(usernamePathParam, stringValue(username));
HttpRequestWorker *worker = new HttpRequestWorker();
HttpRequestInput input(fullPath, "PUT");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput input(fullPath, "PUT");
QString output = body.asJson();
input.request_body.append(output);
@ -436,7 +442,7 @@ SWGUserApi::updateUser(QString* username, SWGUser body) {
}
connect(worker,
&HttpRequestWorker::on_execution_finished,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGUserApi::updateUserCallback);
@ -444,7 +450,7 @@ SWGUserApi::updateUser(QString* username, SWGUser body) {
}
void
SWGUserApi::updateUserCallback(HttpRequestWorker * worker) {
SWGUserApi::updateUserCallback(SWGHttpRequestWorker * worker) {
QString msg;
QString error_str = worker->error_str;
QNetworkReply::NetworkError error_type = worker->error_type;

View File

@ -45,14 +45,14 @@ public:
void updateUser(QString* username, SWGUser body);
private:
void createUserCallback (HttpRequestWorker * worker);
void createUsersWithArrayInputCallback (HttpRequestWorker * worker);
void createUsersWithListInputCallback (HttpRequestWorker * worker);
void deleteUserCallback (HttpRequestWorker * worker);
void getUserByNameCallback (HttpRequestWorker * worker);
void loginUserCallback (HttpRequestWorker * worker);
void logoutUserCallback (HttpRequestWorker * worker);
void updateUserCallback (HttpRequestWorker * worker);
void createUserCallback (SWGHttpRequestWorker * worker);
void createUsersWithArrayInputCallback (SWGHttpRequestWorker * worker);
void createUsersWithListInputCallback (SWGHttpRequestWorker * worker);
void deleteUserCallback (SWGHttpRequestWorker * worker);
void getUserByNameCallback (SWGHttpRequestWorker * worker);
void loginUserCallback (SWGHttpRequestWorker * worker);
void logoutUserCallback (SWGHttpRequestWorker * worker);
void updateUserCallback (SWGHttpRequestWorker * worker);
signals:
void createUserSignal();
@ -73,14 +73,14 @@ signals:
void logoutUserSignalE(QNetworkReply::NetworkError error_type, QString& error_str);
void updateUserSignalE(QNetworkReply::NetworkError error_type, QString& error_str);
void createUserSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void createUsersWithArrayInputSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void createUsersWithListInputSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void deleteUserSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void getUserByNameSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void loginUserSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void logoutUserSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void updateUserSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void createUserSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void createUsersWithArrayInputSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void createUsersWithListInputSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void deleteUserSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void getUserByNameSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void loginUserSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void logoutUserSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void updateUserSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
};