mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 18:45:23 +00:00
[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:
parent
0469975632
commit
c7ff303779
@ -169,6 +169,20 @@ public class Qt5CPPGenerator extends AbstractCppCodegen implements CodegenConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
additionalProperties.put("cppNamespaceDeclarations", cppNamespace.split("\\::"));
|
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
|
@Override
|
||||||
public String toApiFilename(String name) {
|
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
|
@Override
|
||||||
public String toApiName(String type) {
|
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
|
@Override
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
#include "SWGHttpRequest.h"
|
#include "{{prefix}}HttpRequest.h"
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@ -11,28 +11,28 @@
|
|||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
HttpRequestInput::HttpRequestInput() {
|
{{prefix}}HttpRequestInput::{{prefix}}HttpRequestInput() {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequestInput::HttpRequestInput(QString v_url_str, QString v_http_method) {
|
{{prefix}}HttpRequestInput::{{prefix}}HttpRequestInput(QString v_url_str, QString v_http_method) {
|
||||||
initialize();
|
initialize();
|
||||||
url_str = v_url_str;
|
url_str = v_url_str;
|
||||||
http_method = v_http_method;
|
http_method = v_http_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpRequestInput::initialize() {
|
void {{prefix}}HttpRequestInput::initialize() {
|
||||||
var_layout = NOT_SET;
|
var_layout = NOT_SET;
|
||||||
url_str = "";
|
url_str = "";
|
||||||
http_method = "GET";
|
http_method = "GET";
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpRequestInput::add_var(QString key, QString value) {
|
void {{prefix}}HttpRequestInput::add_var(QString key, QString value) {
|
||||||
vars[key] = value;
|
vars[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpRequestInput::add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type) {
|
void {{prefix}}HttpRequestInput::add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type) {
|
||||||
SWGHttpRequestInputFileElement file;
|
{{prefix}}HttpRequestInputFileElement file;
|
||||||
file.variable_name = variable_name;
|
file.variable_name = variable_name;
|
||||||
file.local_filename = local_filename;
|
file.local_filename = local_filename;
|
||||||
file.request_filename = request_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)
|
: QObject(parent), manager(nullptr)
|
||||||
{
|
{
|
||||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||||
@ -50,10 +50,10 @@ HttpRequestWorker::HttpRequestWorker(QObject *parent)
|
|||||||
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(on_manager_finished(QNetworkReply*)));
|
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
|
// result structure follows RFC 5987
|
||||||
bool need_utf_encoding = false;
|
bool need_utf_encoding = false;
|
||||||
QString result = "";
|
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);
|
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
|
// reset variables
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ void HttpRequestWorker::execute(HttpRequestInput *input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add files
|
// 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);
|
QFileInfo fi(file_info->local_filename);
|
||||||
|
|
||||||
// ensure necessary variables are available
|
// ensure necessary variables are available
|
||||||
@ -253,8 +253,8 @@ void HttpRequestWorker::execute(HttpRequestInput *input) {
|
|||||||
// prepare connection
|
// prepare connection
|
||||||
|
|
||||||
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
||||||
if (HttpRequestWorker::sslDefaultConfiguration != nullptr) {
|
if ({{prefix}}HttpRequestWorker::sslDefaultConfiguration != nullptr) {
|
||||||
request.setSslConfiguration(*HttpRequestWorker::sslDefaultConfiguration);
|
request.setSslConfiguration(*{{prefix}}HttpRequestWorker::sslDefaultConfiguration);
|
||||||
}
|
}
|
||||||
request.setRawHeader("User-Agent", "Swagger-Client");
|
request.setRawHeader("User-Agent", "Swagger-Client");
|
||||||
foreach(QString key, input->headers.keys()) {
|
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();
|
error_type = reply->error();
|
||||||
response = reply->readAll();
|
response = reply->readAll();
|
||||||
error_str = reply->errorString();
|
error_str = reply->errorString();
|
||||||
@ -310,7 +310,7 @@ void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
|
|||||||
|
|
||||||
emit on_execution_finished(this);
|
emit on_execution_finished(this);
|
||||||
}
|
}
|
||||||
QSslConfiguration* HttpRequestWorker::sslDefaultConfiguration;
|
QSslConfiguration* {{prefix}}HttpRequestWorker::sslDefaultConfiguration;
|
||||||
|
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef HTTPREQUESTWORKER_H
|
#ifndef {{prefix}}_HTTPREQUESTWORKER_H
|
||||||
#define HTTPREQUESTWORKER_H
|
#define {{prefix}}_HTTPREQUESTWORKER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -14,13 +14,15 @@
|
|||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
|
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
class SWGHttpRequestInputFileElement {
|
enum {{prefix}}HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
|
||||||
|
|
||||||
|
class {{prefix}}HttpRequestInputFileElement {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString variable_name;
|
QString variable_name;
|
||||||
@ -31,19 +33,19 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class HttpRequestInput {
|
class {{prefix}}HttpRequestInput {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString url_str;
|
QString url_str;
|
||||||
QString http_method;
|
QString http_method;
|
||||||
HttpRequestVarLayout var_layout;
|
{{prefix}}HttpRequestVarLayout var_layout;
|
||||||
QMap<QString, QString> vars;
|
QMap<QString, QString> vars;
|
||||||
QMap<QString, QString> headers;
|
QMap<QString, QString> headers;
|
||||||
QList<SWGHttpRequestInputFileElement> files;
|
QList<{{prefix}}HttpRequestInputFileElement> files;
|
||||||
QByteArray request_body;
|
QByteArray request_body;
|
||||||
|
|
||||||
HttpRequestInput();
|
{{prefix}}HttpRequestInput();
|
||||||
HttpRequestInput(QString v_url_str, QString v_http_method);
|
{{prefix}}HttpRequestInput(QString v_url_str, QString v_http_method);
|
||||||
void initialize();
|
void initialize();
|
||||||
void add_var(QString key, QString value);
|
void add_var(QString key, QString value);
|
||||||
void add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type);
|
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
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -59,15 +61,15 @@ public:
|
|||||||
QNetworkReply::NetworkError error_type;
|
QNetworkReply::NetworkError error_type;
|
||||||
QString error_str;
|
QString error_str;
|
||||||
|
|
||||||
explicit HttpRequestWorker(QObject *parent = 0);
|
explicit {{prefix}}HttpRequestWorker(QObject *parent = 0);
|
||||||
virtual ~HttpRequestWorker();
|
virtual ~{{prefix}}HttpRequestWorker();
|
||||||
|
|
||||||
QString http_attribute_encode(QString attribute_name, QString input);
|
QString http_attribute_encode(QString attribute_name, QString input);
|
||||||
void execute(HttpRequestInput *input);
|
void execute({{prefix}}HttpRequestInput *input);
|
||||||
static QSslConfiguration* sslDefaultConfiguration;
|
static QSslConfiguration* sslDefaultConfiguration;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void on_execution_finished(HttpRequestWorker *worker);
|
void on_execution_finished({{prefix}}HttpRequestWorker *worker);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QNetworkAccessManager *manager;
|
QNetworkAccessManager *manager;
|
||||||
@ -81,4 +83,4 @@ private slots:
|
|||||||
}
|
}
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
#endif // HTTPREQUESTWORKER_H
|
#endif // {{prefix}}_HTTPREQUESTWORKER_H
|
||||||
|
@ -87,8 +87,8 @@ void
|
|||||||
{{/collectionFormat}}
|
{{/collectionFormat}}
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
{{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "{{httpMethod}}");
|
{{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}");
|
||||||
|
|
||||||
{{#formParams}}
|
{{#formParams}}
|
||||||
if ({{paramName}} != nullptr) {
|
if ({{paramName}} != nullptr) {
|
||||||
@ -99,15 +99,16 @@ void
|
|||||||
{{#bodyParams}}
|
{{#bodyParams}}
|
||||||
{{#isContainer}}
|
{{#isContainer}}
|
||||||
QJsonArray* {{paramName}}Array = new QJsonArray();
|
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);
|
QJsonDocument doc(*{{paramName}}Array);
|
||||||
QByteArray bytes = doc.toJson();
|
QByteArray bytes = doc.toJson();
|
||||||
|
|
||||||
input.request_body.append(bytes);
|
input.request_body.append(bytes);
|
||||||
{{/isContainer}}
|
{{/isContainer}}
|
||||||
{{^isContainer}}
|
{{^isContainer}}{{#isString}}
|
||||||
QString output = {{paramName}}.asJson();
|
QString output(*{{paramName}});{{/isString}}{{^isString}}
|
||||||
|
QString output = {{paramName}}.asJson();{{/isString}}
|
||||||
input.request_body.append(output);
|
input.request_body.append(output);
|
||||||
{{/isContainer}}{{/bodyParams}}
|
{{/isContainer}}{{/bodyParams}}
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ void
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&{{prefix}}HttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&{{classname}}::{{nickname}}Callback);
|
&{{classname}}::{{nickname}}Callback);
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ void
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
{{classname}}::{{nickname}}Callback(HttpRequestWorker * worker) {
|
{{classname}}::{{nickname}}Callback({{prefix}}HttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -159,10 +160,10 @@ void
|
|||||||
}
|
}
|
||||||
{{/isListContainer}}
|
{{/isListContainer}}
|
||||||
|
|
||||||
{{^isListContainer}}
|
{{^isListContainer}}{{^isMapContainer}}
|
||||||
{{#returnTypeIsPrimitive}}
|
{{#returnTypeIsPrimitive}}
|
||||||
{{{returnType}}} output; // TODO add primitive output support
|
{{{returnType}}} output; // TODO add primitive output support
|
||||||
{{/returnTypeIsPrimitive}}
|
{{/returnTypeIsPrimitive}}{{/isMapContainer}}
|
||||||
{{#isMapContainer}}
|
{{#isMapContainer}}
|
||||||
{{{returnType}}} output = {{{defaultResponse}}};
|
{{{returnType}}} output = {{{defaultResponse}}};
|
||||||
QString json(worker->response);
|
QString json(worker->response);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
#ifndef _SWG_{{classname}}_H_
|
#ifndef _{{prefix}}_{{classname}}_H_
|
||||||
#define _SWG_{{classname}}_H_
|
#define _{{prefix}}_{{classname}}_H_
|
||||||
|
|
||||||
#include "{{prefix}}HttpRequest.h"
|
#include "{{prefix}}HttpRequest.h"
|
||||||
|
|
||||||
@ -28,14 +28,14 @@ public:
|
|||||||
{{#operations}}{{#operation}}void {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
{{#operations}}{{#operation}}void {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||||
{{/operation}}{{/operations}}
|
{{/operation}}{{/operations}}
|
||||||
private:
|
private:
|
||||||
{{#operations}}{{#operation}}void {{nickname}}Callback (HttpRequestWorker * worker);
|
{{#operations}}{{#operation}}void {{nickname}}Callback ({{prefix}}HttpRequestWorker * worker);
|
||||||
{{/operation}}{{/operations}}
|
{{/operation}}{{/operations}}
|
||||||
signals:
|
signals:
|
||||||
{{#operations}}{{#operation}}void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}});
|
{{#operations}}{{#operation}}void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}});
|
||||||
{{/operation}}{{/operations}}
|
{{/operation}}{{/operations}}
|
||||||
{{#operations}}{{#operation}}void {{nickname}}SignalE({{#returnType}}{{{returnType}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, QString& error_str);
|
{{#operations}}{{#operation}}void {{nickname}}SignalE({{#returnType}}{{{returnType}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
{{/operation}}{{/operations}}
|
{{/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}}
|
{{/operation}}{{/operations}}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
#include "SWGHelpers.h"
|
#include "{{prefix}}Helpers.h"
|
||||||
#include "SWGModelFactory.h"
|
#include "{{prefix}}ModelFactory.h"
|
||||||
#include "SWGObject.h"
|
#include "{{prefix}}Object.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonValue>
|
#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";
|
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
|
// complex type
|
||||||
QJsonObject jsonObj = obj.toObject();
|
QJsonObject jsonObj = obj.toObject();
|
||||||
SWGObject * so = (SWGObject*)::{{cppNamespace}}::create(type);
|
{{prefix}}Object * so = ({{prefix}}Object*)::{{cppNamespace}}::create(type);
|
||||||
if(so != nullptr) {
|
if(so != nullptr) {
|
||||||
so->fromJsonObject(jsonObj);
|
so->fromJsonObject(jsonObj);
|
||||||
SWGObject **val = static_cast<SWGObject**>(value);
|
{{prefix}}Object **val = static_cast<{{prefix}}Object**>(value);
|
||||||
delete *val;
|
delete *val;
|
||||||
*val = so;
|
*val = so;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) {
|
else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) {
|
||||||
// list of values
|
// list of values
|
||||||
if(complexType.startsWith("SWG")) {
|
if(complexType.startsWith("{{prefix}}")) {
|
||||||
QList<SWGObject*>* output = new QList<SWGObject*>();
|
QList<{{prefix}}Object*>* output = new QList<{{prefix}}Object*>();
|
||||||
QJsonArray arr = obj.toArray();
|
QJsonArray arr = obj.toArray();
|
||||||
for (const QJsonValue & jval : arr) {
|
for (const QJsonValue & jval : arr) {
|
||||||
// it's an object
|
// it's an object
|
||||||
SWGObject * val = (SWGObject*)create(complexType);
|
{{prefix}}Object * val = ({{prefix}}Object*)create(complexType);
|
||||||
QJsonObject t = jval.toObject();
|
QJsonObject t = jval.toObject();
|
||||||
|
|
||||||
val->fromJsonObject(t);
|
val->fromJsonObject(t);
|
||||||
output->append(val);
|
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) {
|
for (auto item : **val) {
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
@ -247,10 +247,10 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
|
|||||||
if(value == nullptr) {
|
if(value == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(type.startsWith("SWG")) {
|
if(type.startsWith("{{prefix}}")) {
|
||||||
SWGObject *swgObject = reinterpret_cast<SWGObject *>(value);
|
{{prefix}}Object *{{prefix}}object = reinterpret_cast<{{prefix}}Object *>(value);
|
||||||
if(swgObject != nullptr) {
|
if({{prefix}}object != nullptr) {
|
||||||
QJsonObject* o = (*swgObject).asJsonObject();
|
QJsonObject* o = (*{{prefix}}object).asJsonObject();
|
||||||
if(name != nullptr) {
|
if(name != nullptr) {
|
||||||
output->insert(name, *o);
|
output->insert(name, *o);
|
||||||
delete o;
|
delete o;
|
||||||
@ -303,11 +303,11 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
||||||
if(innerType.startsWith("SWG")){
|
if(innerType.startsWith("{{prefix}}")){
|
||||||
for(void* obj : *value) {
|
for(void* obj : *value) {
|
||||||
SWGObject *swgObject = reinterpret_cast<SWGObject *>(obj);
|
{{prefix}}Object *{{prefix}}object = reinterpret_cast<{{prefix}}Object *>(obj);
|
||||||
if(swgObject != nullptr) {
|
if({{prefix}}object != nullptr) {
|
||||||
output->append(*(swgObject->asJsonObject()));
|
output->append(*({{prefix}}object->asJsonObject()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
#ifndef SWGHELPERS_H
|
#ifndef {{prefix}}_HELPERS_H
|
||||||
#define SWGHELPERS_H
|
#define {{prefix}}_HELPERS_H
|
||||||
|
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
|
||||||
@ -21,4 +21,4 @@ namespace {{this}} {
|
|||||||
}
|
}
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
#endif // SWGHELPERS_H
|
#endif // {{prefix}}_HELPERS_H
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{{#models}}{{#model}}
|
{{#models}}{{#model}}
|
||||||
#include "{{classname}}.h"
|
#include "{{classname}}.h"
|
||||||
|
|
||||||
#include "SWGHelpers.h"
|
#include "{{prefix}}Helpers.h"
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
@ -30,6 +30,7 @@ void
|
|||||||
{{classname}}::init() {
|
{{classname}}::init() {
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{name}} = {{{defaultValue}}};
|
{{name}} = {{{defaultValue}}};
|
||||||
|
m_{{name}}_isSet = false;
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +107,18 @@ QJsonObject*
|
|||||||
{{#complexType}}
|
{{#complexType}}
|
||||||
{{^isContainer}}
|
{{^isContainer}}
|
||||||
{{#complexType}}
|
{{#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}}
|
||||||
{{^complexType}}
|
{{^complexType}}
|
||||||
if({{name}} != nullptr && *{{name}} != nullptr) {
|
if({{name}} != nullptr && *{{name}} != nullptr) {
|
||||||
@ -115,33 +127,52 @@ QJsonObject*
|
|||||||
{{/complexType}}
|
{{/complexType}}
|
||||||
{{/isContainer}}
|
{{/isContainer}}
|
||||||
{{#isListContainer}}
|
{{#isListContainer}}
|
||||||
QJsonArray {{name}}JsonArray;
|
if({{name}}->size() > 0){
|
||||||
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{complexType}}");
|
QJsonArray {{name}}JsonArray;
|
||||||
obj->insert("{{baseName}}", {{name}}JsonArray);
|
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{complexType}}");
|
||||||
|
obj->insert("{{baseName}}", {{name}}JsonArray);
|
||||||
|
}
|
||||||
{{/isListContainer}}
|
{{/isListContainer}}
|
||||||
{{#isMapContainer}}
|
{{#isMapContainer}}
|
||||||
QJsonObject {{name}}_jobj;
|
if({{name}}->size() > 0) {
|
||||||
for(auto keyval : {{name}}->keys()){
|
QJsonObject {{name}}_jobj;
|
||||||
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{complexType}}");
|
for(auto keyval : {{name}}->keys()){
|
||||||
}
|
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{complexType}}");
|
||||||
obj->insert("{{baseName}}", {{name}}_jobj);
|
}
|
||||||
|
obj->insert("{{baseName}}", {{name}}_jobj);
|
||||||
|
}
|
||||||
{{/isMapContainer}}
|
{{/isMapContainer}}
|
||||||
{{/complexType}}
|
{{/complexType}}
|
||||||
{{^complexType}}
|
{{^complexType}}
|
||||||
{{^isContainer}}
|
{{^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}}
|
{{/isContainer}}
|
||||||
{{#isListContainer}}
|
{{#isListContainer}}
|
||||||
QJsonArray {{name}}JsonArray;
|
if({{name}}->size() > 0){
|
||||||
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{items.baseType}}");
|
QJsonArray {{name}}JsonArray;
|
||||||
obj->insert("{{baseName}}", {{name}}JsonArray);
|
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{items.baseType}}");
|
||||||
|
obj->insert("{{baseName}}", {{name}}JsonArray);
|
||||||
|
}
|
||||||
{{/isListContainer}}
|
{{/isListContainer}}
|
||||||
{{#isMapContainer}}
|
{{#isMapContainer}}
|
||||||
QJsonObject {{name}}_jobj;
|
if({{name}}->size() > 0){
|
||||||
for(auto keyval : {{name}}->keys()){
|
QJsonObject {{name}}_jobj;
|
||||||
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{items.baseType}}");
|
for(auto keyval : {{name}}->keys()){
|
||||||
}
|
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{items.baseType}}");
|
||||||
obj->insert("{{baseName}}", {{name}}_jobj);
|
}
|
||||||
|
obj->insert("{{baseName}}", {{name}}_jobj);
|
||||||
|
}
|
||||||
{{/isMapContainer}}
|
{{/isMapContainer}}
|
||||||
{{/complexType}}
|
{{/complexType}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
@ -157,10 +188,21 @@ QJsonObject*
|
|||||||
void
|
void
|
||||||
{{classname}}::{{setter}}({{{datatype}}} {{name}}) {
|
{{classname}}::{{setter}}({{{datatype}}} {{name}}) {
|
||||||
this->{{name}} = {{name}};
|
this->{{name}} = {{name}};
|
||||||
|
this->m_{{name}}_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/vars}}
|
{{/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}}
|
||||||
}
|
}
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
{{#imports}}{{{import}}}
|
{{#imports}}{{{import}}}
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
#include "SWGObject.h"
|
#include "{{prefix}}Object.h"
|
||||||
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
@ -22,7 +22,7 @@
|
|||||||
namespace {{this}} {
|
namespace {{this}} {
|
||||||
{{/cppNamespaceDeclarations}}
|
{{/cppNamespaceDeclarations}}
|
||||||
|
|
||||||
class {{classname}}: public SWGObject {
|
class {{classname}}: public {{prefix}}Object {
|
||||||
public:
|
public:
|
||||||
{{classname}}();
|
{{classname}}();
|
||||||
{{classname}}(QString* json);
|
{{classname}}(QString* json);
|
||||||
@ -41,9 +41,13 @@ public:
|
|||||||
|
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
|
virtual bool isSet() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{{datatype}}} {{name}};
|
{{{datatype}}} {{name}};
|
||||||
|
bool m_{{name}}_isSet;
|
||||||
|
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace {{this}} {
|
|||||||
inline void* create(QString json, QString type) {
|
inline void* create(QString json, QString type) {
|
||||||
void* val = create(type);
|
void* val = create(type);
|
||||||
if(val != nullptr) {
|
if(val != nullptr) {
|
||||||
SWGObject* obj = static_cast<SWGObject*>(val);
|
{{prefix}}Object* obj = static_cast<{{prefix}}Object*>(val);
|
||||||
return obj->fromJson(json);
|
return obj->fromJson(json);
|
||||||
}
|
}
|
||||||
if(type.startsWith("QString")) {
|
if(type.startsWith("QString")) {
|
||||||
|
@ -11,12 +11,12 @@ namespace {{this}} {
|
|||||||
class {{prefix}}Object {
|
class {{prefix}}Object {
|
||||||
public:
|
public:
|
||||||
virtual QJsonObject* asJsonObject() {
|
virtual QJsonObject* asJsonObject() {
|
||||||
return nullptr;
|
return new QJsonObject();
|
||||||
}
|
}
|
||||||
virtual ~SWGObject() {}
|
virtual ~{{prefix}}Object() {}
|
||||||
virtual SWGObject* fromJson(QString &jsonString) {
|
virtual {{prefix}}Object* fromJson(QString &jsonString) {
|
||||||
Q_UNUSED(jsonString);
|
Q_UNUSED(jsonString);
|
||||||
return nullptr;
|
return new {{prefix}}Object();
|
||||||
}
|
}
|
||||||
virtual void fromJsonObject(QJsonObject &json) {
|
virtual void fromJsonObject(QJsonObject &json) {
|
||||||
Q_UNUSED(json);
|
Q_UNUSED(json);
|
||||||
@ -24,6 +24,9 @@ class {{prefix}}Object {
|
|||||||
virtual QString asJson() {
|
virtual QString asJson() {
|
||||||
return QString("");
|
return QString("");
|
||||||
}
|
}
|
||||||
|
virtual bool isSet() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
{{#cppNamespaceDeclarations}}
|
{{#cppNamespaceDeclarations}}
|
||||||
|
@ -18,8 +18,8 @@ SWGPetApi* PetApiTests::getApi() {
|
|||||||
return api;
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pet* PetApiTests::createRandomPet() {
|
SWGPet* PetApiTests::createRandomPet() {
|
||||||
Pet* pet = new Pet();
|
SWGPet* pet = new SWGPet();
|
||||||
qint64 id = QDateTime::currentMSecsSinceEpoch();
|
qint64 id = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
|
||||||
pet->setName(new QString("monster"));
|
pet->setName(new QString("monster"));
|
||||||
@ -43,8 +43,8 @@ void PetApiTests::findPetsByStatusTest() {
|
|||||||
timer.setInterval(14000);
|
timer.setInterval(14000);
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
auto validator = [](QList<Pet*>* pets) {
|
auto validator = [](QList<SWGPet*>* pets) {
|
||||||
foreach(Pet* pet, *pets) {
|
foreach(SWGPet* pet, *pets) {
|
||||||
QVERIFY(pet->getStatus()->startsWith("available") || pet->getStatus()->startsWith("sold"));
|
QVERIFY(pet->getStatus()->startsWith("available") || pet->getStatus()->startsWith("sold"));
|
||||||
}
|
}
|
||||||
loop.quit();
|
loop.quit();
|
||||||
@ -79,7 +79,7 @@ void PetApiTests::createAndGetPetTest() {
|
|||||||
connect(api, &SWGPetApi::addPetSignal, this, validator);
|
connect(api, &SWGPetApi::addPetSignal, this, validator);
|
||||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||||
|
|
||||||
Pet* pet = createRandomPet();
|
SWGPet* pet = createRandomPet();
|
||||||
qint64 id = pet->getId();
|
qint64 id = pet->getId();
|
||||||
|
|
||||||
api->addPet(*pet);
|
api->addPet(*pet);
|
||||||
@ -90,7 +90,7 @@ void PetApiTests::createAndGetPetTest() {
|
|||||||
timer.setInterval(1000);
|
timer.setInterval(1000);
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
auto getPetValidator = [](Pet* pet) {
|
auto getPetValidator = [](SWGPet* pet) {
|
||||||
QVERIFY(pet->getId() > 0);
|
QVERIFY(pet->getId() > 0);
|
||||||
QVERIFY(pet->getStatus()->compare("freaky") == 0);
|
QVERIFY(pet->getStatus()->compare("freaky") == 0);
|
||||||
loop.quit();
|
loop.quit();
|
||||||
@ -109,8 +109,8 @@ void PetApiTests::createAndGetPetTest() {
|
|||||||
void PetApiTests::updatePetTest() {
|
void PetApiTests::updatePetTest() {
|
||||||
static SWGPetApi* api = getApi();
|
static SWGPetApi* api = getApi();
|
||||||
|
|
||||||
Pet* pet = createRandomPet();
|
SWGPet* pet = createRandomPet();
|
||||||
static Pet* petToCheck;
|
static SWGPet* petToCheck;
|
||||||
qint64 id = pet->getId();
|
qint64 id = pet->getId();
|
||||||
static QEventLoop loop;
|
static QEventLoop loop;
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
@ -134,7 +134,7 @@ void PetApiTests::updatePetTest() {
|
|||||||
timer.setInterval(1000);
|
timer.setInterval(1000);
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
auto fetchPet = [](Pet* pet) {
|
auto fetchPet = [](SWGPet* pet) {
|
||||||
petToCheck = pet;
|
petToCheck = pet;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
};
|
};
|
||||||
@ -168,7 +168,7 @@ void PetApiTests::updatePetTest() {
|
|||||||
timer.setInterval(1000);
|
timer.setInterval(1000);
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
auto fetchPet2 = [](Pet* pet) {
|
auto fetchPet2 = [](SWGPet* pet) {
|
||||||
QVERIFY(pet->getId() == petToCheck->getId());
|
QVERIFY(pet->getId() == petToCheck->getId());
|
||||||
QVERIFY(pet->getStatus()->compare(petToCheck->getStatus()) == 0);
|
QVERIFY(pet->getStatus()->compare(petToCheck->getStatus()) == 0);
|
||||||
loop.quit();
|
loop.quit();
|
||||||
@ -184,8 +184,8 @@ void PetApiTests::updatePetTest() {
|
|||||||
void PetApiTests::updatePetWithFormTest() {
|
void PetApiTests::updatePetWithFormTest() {
|
||||||
static SWGPetApi* api = getApi();
|
static SWGPetApi* api = getApi();
|
||||||
|
|
||||||
Pet* pet = createRandomPet();
|
SWGPet* pet = createRandomPet();
|
||||||
static Pet* petToCheck;
|
static SWGPet* petToCheck;
|
||||||
qint64 id = pet->getId();
|
qint64 id = pet->getId();
|
||||||
static QEventLoop loop;
|
static QEventLoop loop;
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
@ -209,7 +209,7 @@ void PetApiTests::updatePetWithFormTest() {
|
|||||||
timer.setInterval(1000);
|
timer.setInterval(1000);
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
auto fetchPet = [](Pet* pet) {
|
auto fetchPet = [](SWGPet* pet) {
|
||||||
petToCheck = pet;
|
petToCheck = pet;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
};
|
};
|
||||||
@ -237,7 +237,7 @@ void PetApiTests::updatePetWithFormTest() {
|
|||||||
timer.setInterval(1000);
|
timer.setInterval(1000);
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
|
|
||||||
auto fetchUpdatedPet = [](Pet* pet) {
|
auto fetchUpdatedPet = [](SWGPet* pet) {
|
||||||
QVERIFY(pet->getName()->compare(QString("gorilla")) == 0);
|
QVERIFY(pet->getName()->compare(QString("gorilla")) == 0);
|
||||||
loop.quit();
|
loop.quit();
|
||||||
};
|
};
|
||||||
|
@ -18,7 +18,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SWGPetApi* getApi();
|
SWGPetApi* getApi();
|
||||||
Pet* createRandomPet();
|
SWGPet* createRandomPet();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void quit();
|
void quit();
|
||||||
|
@ -38,8 +38,11 @@ SWGApiResponse::~SWGApiResponse() {
|
|||||||
void
|
void
|
||||||
SWGApiResponse::init() {
|
SWGApiResponse::init() {
|
||||||
code = 0;
|
code = 0;
|
||||||
|
m_code_isSet = false;
|
||||||
type = new QString("");
|
type = new QString("");
|
||||||
|
m_type_isSet = false;
|
||||||
message = new QString("");
|
message = new QString("");
|
||||||
|
m_message_isSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -82,9 +85,15 @@ SWGApiResponse::asJson ()
|
|||||||
QJsonObject*
|
QJsonObject*
|
||||||
SWGApiResponse::asJsonObject() {
|
SWGApiResponse::asJsonObject() {
|
||||||
QJsonObject* obj = new QJsonObject();
|
QJsonObject* obj = new QJsonObject();
|
||||||
obj->insert("code", QJsonValue(code));
|
if(m_code_isSet){
|
||||||
toJsonValue(QString("type"), type, obj, QString("QString"));
|
obj->insert("code", QJsonValue(code));
|
||||||
toJsonValue(QString("message"), message, obj, QString("QString"));
|
}
|
||||||
|
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;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -96,6 +105,7 @@ SWGApiResponse::getCode() {
|
|||||||
void
|
void
|
||||||
SWGApiResponse::setCode(qint32 code) {
|
SWGApiResponse::setCode(qint32 code) {
|
||||||
this->code = code;
|
this->code = code;
|
||||||
|
this->m_code_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -105,6 +115,7 @@ SWGApiResponse::getType() {
|
|||||||
void
|
void
|
||||||
SWGApiResponse::setType(QString* type) {
|
SWGApiResponse::setType(QString* type) {
|
||||||
this->type = type;
|
this->type = type;
|
||||||
|
this->m_type_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -114,8 +125,19 @@ SWGApiResponse::getMessage() {
|
|||||||
void
|
void
|
||||||
SWGApiResponse::setMessage(QString* message) {
|
SWGApiResponse::setMessage(QString* message) {
|
||||||
this->message = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,10 +51,18 @@ public:
|
|||||||
void setMessage(QString* message);
|
void setMessage(QString* message);
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool isSet() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint32 code;
|
qint32 code;
|
||||||
|
bool m_code_isSet;
|
||||||
|
|
||||||
QString* type;
|
QString* type;
|
||||||
|
bool m_type_isSet;
|
||||||
|
|
||||||
QString* message;
|
QString* message;
|
||||||
|
bool m_message_isSet;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,9 @@ SWGCategory::~SWGCategory() {
|
|||||||
void
|
void
|
||||||
SWGCategory::init() {
|
SWGCategory::init() {
|
||||||
id = 0L;
|
id = 0L;
|
||||||
|
m_id_isSet = false;
|
||||||
name = new QString("");
|
name = new QString("");
|
||||||
|
m_name_isSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -77,8 +79,12 @@ SWGCategory::asJson ()
|
|||||||
QJsonObject*
|
QJsonObject*
|
||||||
SWGCategory::asJsonObject() {
|
SWGCategory::asJsonObject() {
|
||||||
QJsonObject* obj = new QJsonObject();
|
QJsonObject* obj = new QJsonObject();
|
||||||
obj->insert("id", QJsonValue(id));
|
if(m_id_isSet){
|
||||||
toJsonValue(QString("name"), name, obj, QString("QString"));
|
obj->insert("id", QJsonValue(id));
|
||||||
|
}
|
||||||
|
if(name != nullptr && *name != QString("")){
|
||||||
|
toJsonValue(QString("name"), name, obj, QString("QString"));
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -90,6 +96,7 @@ SWGCategory::getId() {
|
|||||||
void
|
void
|
||||||
SWGCategory::setId(qint64 id) {
|
SWGCategory::setId(qint64 id) {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
|
this->m_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -99,8 +106,18 @@ SWGCategory::getName() {
|
|||||||
void
|
void
|
||||||
SWGCategory::setName(QString* name) {
|
SWGCategory::setName(QString* name) {
|
||||||
this->name = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,15 @@ public:
|
|||||||
void setName(QString* name);
|
void setName(QString* name);
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool isSet() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint64 id;
|
qint64 id;
|
||||||
|
bool m_id_isSet;
|
||||||
|
|
||||||
QString* name;
|
QString* name;
|
||||||
|
bool m_name_isSet;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -141,10 +141,10 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
|
|||||||
}
|
}
|
||||||
else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) {
|
else if(type.startsWith("QList") && QString("").compare(complexType) != 0 && obj.isArray()) {
|
||||||
// list of values
|
// list of values
|
||||||
QList<void*>* output = new QList<void*>();
|
if(complexType.startsWith("SWG")) {
|
||||||
QJsonArray arr = obj.toArray();
|
QList<SWGObject*>* output = new QList<SWGObject*>();
|
||||||
foreach (const QJsonValue & jval, arr) {
|
QJsonArray arr = obj.toArray();
|
||||||
if(complexType.startsWith("SWG")) {
|
for (const QJsonValue & jval : arr) {
|
||||||
// it's an object
|
// it's an object
|
||||||
SWGObject * val = (SWGObject*)create(complexType);
|
SWGObject * val = (SWGObject*)create(complexType);
|
||||||
QJsonObject t = jval.toObject();
|
QJsonObject t = jval.toObject();
|
||||||
@ -152,53 +152,102 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
|
|||||||
val->fromJsonObject(t);
|
val->fromJsonObject(t);
|
||||||
output->append(val);
|
output->append(val);
|
||||||
}
|
}
|
||||||
else {
|
QList<SWGObject*> **val = static_cast<QList<SWGObject*>**>(value);
|
||||||
// primitives
|
for (auto item : **val) {
|
||||||
if(QStringLiteral("qint32").compare(complexType) == 0) {
|
delete item;
|
||||||
qint32 val;
|
}
|
||||||
setValue(&val, jval, QStringLiteral("qint32"), QStringLiteral(""));
|
delete *val;
|
||||||
output->append((void*)&val);
|
*val = output;
|
||||||
}
|
}
|
||||||
else if(QStringLiteral("qint64").compare(complexType) == 0) {
|
else if(QStringLiteral("qint32").compare(complexType) == 0) {
|
||||||
qint64 val;
|
QList<qint32> **output = reinterpret_cast<QList<qint32> **> (value);
|
||||||
setValue(&val, jval, QStringLiteral("qint64"), QStringLiteral(""));
|
(*output)->clear();
|
||||||
output->append((void*)&val);
|
QJsonArray arr = obj.toArray();
|
||||||
}
|
for (const QJsonValue & jval : arr){
|
||||||
else if(QStringLiteral("bool").compare(complexType) == 0) {
|
qint32 val;
|
||||||
bool val;
|
setValue(&val, jval, QStringLiteral("qint32"), QStringLiteral(""));
|
||||||
setValue(&val, jval, QStringLiteral("bool"), QStringLiteral(""));
|
(*output)->push_back(val);
|
||||||
output->append((void*)&val);
|
}
|
||||||
}
|
}
|
||||||
else if(QStringLiteral("float").compare(complexType) == 0) {
|
else if(QStringLiteral("qint64").compare(complexType) == 0) {
|
||||||
float val;
|
QList<qint64> **output = reinterpret_cast<QList<qint64> **> (value);
|
||||||
setValue(&val, jval, QStringLiteral("float"), QStringLiteral(""));
|
(*output)->clear();
|
||||||
output->append((void*)&val);
|
QJsonArray arr = obj.toArray();
|
||||||
}
|
for (const QJsonValue & jval : arr){
|
||||||
else if(QStringLiteral("double").compare(complexType) == 0) {
|
qint64 val;
|
||||||
double val;
|
setValue(&val, jval, QStringLiteral("qint64"), QStringLiteral(""));
|
||||||
setValue(&val, jval, QStringLiteral("double"), QStringLiteral(""));
|
(*output)->push_back(val);
|
||||||
output->append((void*)&val);
|
}
|
||||||
}
|
}
|
||||||
else if(QStringLiteral("QString").compare(complexType) == 0) {
|
else if(QStringLiteral("bool").compare(complexType) == 0) {
|
||||||
QString * val = new QString();
|
QList<bool> **output = reinterpret_cast<QList<bool> **> (value);
|
||||||
setValue(&val, jval, QStringLiteral("QString"), QStringLiteral(""));
|
(*output)->clear();
|
||||||
output->append((void*)val);
|
QJsonArray arr = obj.toArray();
|
||||||
}
|
for (const QJsonValue & jval : arr){
|
||||||
else if(QStringLiteral("QDate").compare(complexType) == 0) {
|
bool val;
|
||||||
QDate * val = new QDate();
|
setValue(&val, jval, QStringLiteral("bool"), QStringLiteral(""));
|
||||||
setValue(&val, jval, QStringLiteral("QDate"), QStringLiteral(""));
|
(*output)->push_back(val);
|
||||||
output->append((void*)val);
|
}
|
||||||
}
|
}
|
||||||
else if(QStringLiteral("QDateTime").compare(complexType) == 0) {
|
else if(QStringLiteral("float").compare(complexType) == 0) {
|
||||||
QDateTime * val = new QDateTime();
|
QList<float> **output = reinterpret_cast<QList<float> **> (value);
|
||||||
setValue(&val, jval, QStringLiteral("QDateTime"), QStringLiteral(""));
|
(*output)->clear();
|
||||||
output->append((void*)val);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if(type.startsWith("SWG")) {
|
if(type.startsWith("SWG")) {
|
||||||
SWGObject *swgObject = reinterpret_cast<SWGObject *>(value);
|
SWGObject *SWGobject = reinterpret_cast<SWGObject *>(value);
|
||||||
if(swgObject != nullptr) {
|
if(SWGobject != nullptr) {
|
||||||
QJsonObject* o = (*swgObject).asJsonObject();
|
QJsonObject* o = (*SWGobject).asJsonObject();
|
||||||
if(name != nullptr) {
|
if(name != nullptr) {
|
||||||
output->insert(name, *o);
|
output->insert(name, *o);
|
||||||
delete o;
|
delete o;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
output->empty();
|
output->empty();
|
||||||
foreach(QString key, o->keys()) {
|
for(QString key : o->keys()) {
|
||||||
output->insert(key, o->value(key));
|
output->insert(key, o->value(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,11 +312,52 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
toJsonArray(QList<void*>* value, QJsonArray* output, QString innerName, QString innerType) {
|
||||||
foreach(void* obj, *value) {
|
if(innerType.startsWith("SWG")){
|
||||||
QJsonObject element;
|
for(void* obj : *value) {
|
||||||
|
SWGObject *SWGobject = reinterpret_cast<SWGObject *>(obj);
|
||||||
toJsonValue(nullptr, obj, &element, innerType);
|
if(SWGobject != nullptr) {
|
||||||
output->append(element);
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SWGHELPERS_H
|
#ifndef SWG_HELPERS_H
|
||||||
#define SWGHELPERS_H
|
#define SWG_HELPERS_H
|
||||||
|
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
|
||||||
@ -28,4 +28,4 @@ namespace Swagger {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SWGHELPERS_H
|
#endif // SWG_HELPERS_H
|
||||||
|
@ -20,27 +20,27 @@
|
|||||||
|
|
||||||
namespace Swagger {
|
namespace Swagger {
|
||||||
|
|
||||||
HttpRequestInput::HttpRequestInput() {
|
SWGHttpRequestInput::SWGHttpRequestInput() {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequestInput::HttpRequestInput(QString v_url_str, QString v_http_method) {
|
SWGHttpRequestInput::SWGHttpRequestInput(QString v_url_str, QString v_http_method) {
|
||||||
initialize();
|
initialize();
|
||||||
url_str = v_url_str;
|
url_str = v_url_str;
|
||||||
http_method = v_http_method;
|
http_method = v_http_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpRequestInput::initialize() {
|
void SWGHttpRequestInput::initialize() {
|
||||||
var_layout = NOT_SET;
|
var_layout = NOT_SET;
|
||||||
url_str = "";
|
url_str = "";
|
||||||
http_method = "GET";
|
http_method = "GET";
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpRequestInput::add_var(QString key, QString value) {
|
void SWGHttpRequestInput::add_var(QString key, QString value) {
|
||||||
vars[key] = 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;
|
SWGHttpRequestInputFileElement file;
|
||||||
file.variable_name = variable_name;
|
file.variable_name = variable_name;
|
||||||
file.local_filename = local_filename;
|
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)
|
: QObject(parent), manager(nullptr)
|
||||||
{
|
{
|
||||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||||
@ -59,10 +59,10 @@ HttpRequestWorker::HttpRequestWorker(QObject *parent)
|
|||||||
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(on_manager_finished(QNetworkReply*)));
|
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
|
// result structure follows RFC 5987
|
||||||
bool need_utf_encoding = false;
|
bool need_utf_encoding = false;
|
||||||
QString result = "";
|
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);
|
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
|
// reset variables
|
||||||
|
|
||||||
@ -262,8 +262,8 @@ void HttpRequestWorker::execute(HttpRequestInput *input) {
|
|||||||
// prepare connection
|
// prepare connection
|
||||||
|
|
||||||
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
||||||
if (HttpRequestWorker::sslDefaultConfiguration != nullptr) {
|
if (SWGHttpRequestWorker::sslDefaultConfiguration != nullptr) {
|
||||||
request.setSslConfiguration(*HttpRequestWorker::sslDefaultConfiguration);
|
request.setSslConfiguration(*SWGHttpRequestWorker::sslDefaultConfiguration);
|
||||||
}
|
}
|
||||||
request.setRawHeader("User-Agent", "Swagger-Client");
|
request.setRawHeader("User-Agent", "Swagger-Client");
|
||||||
foreach(QString key, input->headers.keys()) {
|
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();
|
error_type = reply->error();
|
||||||
response = reply->readAll();
|
response = reply->readAll();
|
||||||
error_str = reply->errorString();
|
error_str = reply->errorString();
|
||||||
@ -319,7 +319,7 @@ void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
|
|||||||
|
|
||||||
emit on_execution_finished(this);
|
emit on_execution_finished(this);
|
||||||
}
|
}
|
||||||
QSslConfiguration* HttpRequestWorker::sslDefaultConfiguration;
|
QSslConfiguration* SWGHttpRequestWorker::sslDefaultConfiguration;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef HTTPREQUESTWORKER_H
|
#ifndef SWG_HTTPREQUESTWORKER_H
|
||||||
#define HTTPREQUESTWORKER_H
|
#define SWG_HTTPREQUESTWORKER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -25,10 +25,12 @@
|
|||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
|
|
||||||
|
|
||||||
namespace Swagger {
|
namespace Swagger {
|
||||||
|
|
||||||
|
enum SWGHttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
|
||||||
|
|
||||||
class SWGHttpRequestInputFileElement {
|
class SWGHttpRequestInputFileElement {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -40,19 +42,19 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class HttpRequestInput {
|
class SWGHttpRequestInput {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString url_str;
|
QString url_str;
|
||||||
QString http_method;
|
QString http_method;
|
||||||
HttpRequestVarLayout var_layout;
|
SWGHttpRequestVarLayout var_layout;
|
||||||
QMap<QString, QString> vars;
|
QMap<QString, QString> vars;
|
||||||
QMap<QString, QString> headers;
|
QMap<QString, QString> headers;
|
||||||
QList<SWGHttpRequestInputFileElement> files;
|
QList<SWGHttpRequestInputFileElement> files;
|
||||||
QByteArray request_body;
|
QByteArray request_body;
|
||||||
|
|
||||||
HttpRequestInput();
|
SWGHttpRequestInput();
|
||||||
HttpRequestInput(QString v_url_str, QString v_http_method);
|
SWGHttpRequestInput(QString v_url_str, QString v_http_method);
|
||||||
void initialize();
|
void initialize();
|
||||||
void add_var(QString key, QString value);
|
void add_var(QString key, QString value);
|
||||||
void add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type);
|
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
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -68,15 +70,15 @@ public:
|
|||||||
QNetworkReply::NetworkError error_type;
|
QNetworkReply::NetworkError error_type;
|
||||||
QString error_str;
|
QString error_str;
|
||||||
|
|
||||||
explicit HttpRequestWorker(QObject *parent = 0);
|
explicit SWGHttpRequestWorker(QObject *parent = 0);
|
||||||
virtual ~HttpRequestWorker();
|
virtual ~SWGHttpRequestWorker();
|
||||||
|
|
||||||
QString http_attribute_encode(QString attribute_name, QString input);
|
QString http_attribute_encode(QString attribute_name, QString input);
|
||||||
void execute(HttpRequestInput *input);
|
void execute(SWGHttpRequestInput *input);
|
||||||
static QSslConfiguration* sslDefaultConfiguration;
|
static QSslConfiguration* sslDefaultConfiguration;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void on_execution_finished(HttpRequestWorker *worker);
|
void on_execution_finished(SWGHttpRequestWorker *worker);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QNetworkAccessManager *manager;
|
QNetworkAccessManager *manager;
|
||||||
@ -88,4 +90,4 @@ private slots:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HTTPREQUESTWORKER_H
|
#endif // SWG_HTTPREQUESTWORKER_H
|
||||||
|
@ -20,12 +20,12 @@ namespace Swagger {
|
|||||||
class SWGObject {
|
class SWGObject {
|
||||||
public:
|
public:
|
||||||
virtual QJsonObject* asJsonObject() {
|
virtual QJsonObject* asJsonObject() {
|
||||||
return nullptr;
|
return new QJsonObject();
|
||||||
}
|
}
|
||||||
virtual ~SWGObject() {}
|
virtual ~SWGObject() {}
|
||||||
virtual SWGObject* fromJson(QString &jsonString) {
|
virtual SWGObject* fromJson(QString &jsonString) {
|
||||||
Q_UNUSED(jsonString);
|
Q_UNUSED(jsonString);
|
||||||
return nullptr;
|
return new SWGObject();
|
||||||
}
|
}
|
||||||
virtual void fromJsonObject(QJsonObject &json) {
|
virtual void fromJsonObject(QJsonObject &json) {
|
||||||
Q_UNUSED(json);
|
Q_UNUSED(json);
|
||||||
@ -33,6 +33,9 @@ class SWGObject {
|
|||||||
virtual QString asJson() {
|
virtual QString asJson() {
|
||||||
return QString("");
|
return QString("");
|
||||||
}
|
}
|
||||||
|
virtual bool isSet() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,17 @@ SWGOrder::~SWGOrder() {
|
|||||||
void
|
void
|
||||||
SWGOrder::init() {
|
SWGOrder::init() {
|
||||||
id = 0L;
|
id = 0L;
|
||||||
|
m_id_isSet = false;
|
||||||
pet_id = 0L;
|
pet_id = 0L;
|
||||||
|
m_pet_id_isSet = false;
|
||||||
quantity = 0;
|
quantity = 0;
|
||||||
|
m_quantity_isSet = false;
|
||||||
ship_date = NULL;
|
ship_date = NULL;
|
||||||
|
m_ship_date_isSet = false;
|
||||||
status = new QString("");
|
status = new QString("");
|
||||||
|
m_status_isSet = false;
|
||||||
complete = false;
|
complete = false;
|
||||||
|
m_complete_isSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -91,12 +97,21 @@ SWGOrder::asJson ()
|
|||||||
QJsonObject*
|
QJsonObject*
|
||||||
SWGOrder::asJsonObject() {
|
SWGOrder::asJsonObject() {
|
||||||
QJsonObject* obj = new QJsonObject();
|
QJsonObject* obj = new QJsonObject();
|
||||||
obj->insert("id", QJsonValue(id));
|
if(m_id_isSet){
|
||||||
obj->insert("petId", QJsonValue(pet_id));
|
obj->insert("id", QJsonValue(id));
|
||||||
obj->insert("quantity", QJsonValue(quantity));
|
}
|
||||||
toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
|
if(m_pet_id_isSet){
|
||||||
toJsonValue(QString("status"), status, obj, QString("QString"));
|
obj->insert("petId", QJsonValue(pet_id));
|
||||||
obj->insert("complete", QJsonValue(complete));
|
}
|
||||||
|
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;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -108,6 +123,7 @@ SWGOrder::getId() {
|
|||||||
void
|
void
|
||||||
SWGOrder::setId(qint64 id) {
|
SWGOrder::setId(qint64 id) {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
|
this->m_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64
|
qint64
|
||||||
@ -117,6 +133,7 @@ SWGOrder::getPetId() {
|
|||||||
void
|
void
|
||||||
SWGOrder::setPetId(qint64 pet_id) {
|
SWGOrder::setPetId(qint64 pet_id) {
|
||||||
this->pet_id = pet_id;
|
this->pet_id = pet_id;
|
||||||
|
this->m_pet_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32
|
qint32
|
||||||
@ -126,6 +143,7 @@ SWGOrder::getQuantity() {
|
|||||||
void
|
void
|
||||||
SWGOrder::setQuantity(qint32 quantity) {
|
SWGOrder::setQuantity(qint32 quantity) {
|
||||||
this->quantity = quantity;
|
this->quantity = quantity;
|
||||||
|
this->m_quantity_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime*
|
QDateTime*
|
||||||
@ -135,6 +153,7 @@ SWGOrder::getShipDate() {
|
|||||||
void
|
void
|
||||||
SWGOrder::setShipDate(QDateTime* ship_date) {
|
SWGOrder::setShipDate(QDateTime* ship_date) {
|
||||||
this->ship_date = ship_date;
|
this->ship_date = ship_date;
|
||||||
|
this->m_ship_date_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -144,6 +163,7 @@ SWGOrder::getStatus() {
|
|||||||
void
|
void
|
||||||
SWGOrder::setStatus(QString* status) {
|
SWGOrder::setStatus(QString* status) {
|
||||||
this->status = status;
|
this->status = status;
|
||||||
|
this->m_status_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -153,8 +173,22 @@ SWGOrder::isComplete() {
|
|||||||
void
|
void
|
||||||
SWGOrder::setComplete(bool complete) {
|
SWGOrder::setComplete(bool complete) {
|
||||||
this->complete = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +61,27 @@ public:
|
|||||||
void setComplete(bool complete);
|
void setComplete(bool complete);
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool isSet() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint64 id;
|
qint64 id;
|
||||||
|
bool m_id_isSet;
|
||||||
|
|
||||||
qint64 pet_id;
|
qint64 pet_id;
|
||||||
|
bool m_pet_id_isSet;
|
||||||
|
|
||||||
qint32 quantity;
|
qint32 quantity;
|
||||||
|
bool m_quantity_isSet;
|
||||||
|
|
||||||
QDateTime* ship_date;
|
QDateTime* ship_date;
|
||||||
|
bool m_ship_date_isSet;
|
||||||
|
|
||||||
QString* status;
|
QString* status;
|
||||||
|
bool m_status_isSet;
|
||||||
|
|
||||||
bool complete;
|
bool complete;
|
||||||
|
bool m_complete_isSet;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,17 @@ SWGPet::~SWGPet() {
|
|||||||
void
|
void
|
||||||
SWGPet::init() {
|
SWGPet::init() {
|
||||||
id = 0L;
|
id = 0L;
|
||||||
|
m_id_isSet = false;
|
||||||
category = new SWGCategory();
|
category = new SWGCategory();
|
||||||
|
m_category_isSet = false;
|
||||||
name = new QString("");
|
name = new QString("");
|
||||||
|
m_name_isSet = false;
|
||||||
photo_urls = new QList<QString*>();
|
photo_urls = new QList<QString*>();
|
||||||
|
m_photo_urls_isSet = false;
|
||||||
tags = new QList<SWGTag*>();
|
tags = new QList<SWGTag*>();
|
||||||
|
m_tags_isSet = false;
|
||||||
status = new QString("");
|
status = new QString("");
|
||||||
|
m_status_isSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -105,16 +111,28 @@ SWGPet::asJson ()
|
|||||||
QJsonObject*
|
QJsonObject*
|
||||||
SWGPet::asJsonObject() {
|
SWGPet::asJsonObject() {
|
||||||
QJsonObject* obj = new QJsonObject();
|
QJsonObject* obj = new QJsonObject();
|
||||||
obj->insert("id", QJsonValue(id));
|
if(m_id_isSet){
|
||||||
toJsonValue(QString("category"), category, obj, QString("SWGCategory"));
|
obj->insert("id", QJsonValue(id));
|
||||||
toJsonValue(QString("name"), name, obj, QString("QString"));
|
}
|
||||||
QJsonArray photo_urlsJsonArray;
|
if(category->isSet()){
|
||||||
toJsonArray((QList<void*>*)photo_urls, &photo_urlsJsonArray, "photo_urls", "QString");
|
toJsonValue(QString("category"), category, obj, QString("SWGCategory"));
|
||||||
obj->insert("photoUrls", photo_urlsJsonArray);
|
}
|
||||||
QJsonArray tagsJsonArray;
|
if(name != nullptr && *name != QString("")){
|
||||||
toJsonArray((QList<void*>*)tags, &tagsJsonArray, "tags", "SWGTag");
|
toJsonValue(QString("name"), name, obj, QString("QString"));
|
||||||
obj->insert("tags", tagsJsonArray);
|
}
|
||||||
toJsonValue(QString("status"), status, 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;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -126,6 +144,7 @@ SWGPet::getId() {
|
|||||||
void
|
void
|
||||||
SWGPet::setId(qint64 id) {
|
SWGPet::setId(qint64 id) {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
|
this->m_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWGCategory*
|
SWGCategory*
|
||||||
@ -135,6 +154,7 @@ SWGPet::getCategory() {
|
|||||||
void
|
void
|
||||||
SWGPet::setCategory(SWGCategory* category) {
|
SWGPet::setCategory(SWGCategory* category) {
|
||||||
this->category = category;
|
this->category = category;
|
||||||
|
this->m_category_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -144,6 +164,7 @@ SWGPet::getName() {
|
|||||||
void
|
void
|
||||||
SWGPet::setName(QString* name) {
|
SWGPet::setName(QString* name) {
|
||||||
this->name = name;
|
this->name = name;
|
||||||
|
this->m_name_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString*>*
|
QList<QString*>*
|
||||||
@ -153,6 +174,7 @@ SWGPet::getPhotoUrls() {
|
|||||||
void
|
void
|
||||||
SWGPet::setPhotoUrls(QList<QString*>* photo_urls) {
|
SWGPet::setPhotoUrls(QList<QString*>* photo_urls) {
|
||||||
this->photo_urls = photo_urls;
|
this->photo_urls = photo_urls;
|
||||||
|
this->m_photo_urls_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<SWGTag*>*
|
QList<SWGTag*>*
|
||||||
@ -162,6 +184,7 @@ SWGPet::getTags() {
|
|||||||
void
|
void
|
||||||
SWGPet::setTags(QList<SWGTag*>* tags) {
|
SWGPet::setTags(QList<SWGTag*>* tags) {
|
||||||
this->tags = tags;
|
this->tags = tags;
|
||||||
|
this->m_tags_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -171,8 +194,22 @@ SWGPet::getStatus() {
|
|||||||
void
|
void
|
||||||
SWGPet::setStatus(QString* status) {
|
SWGPet::setStatus(QString* status) {
|
||||||
this->status = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,13 +63,27 @@ public:
|
|||||||
void setStatus(QString* status);
|
void setStatus(QString* status);
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool isSet() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint64 id;
|
qint64 id;
|
||||||
|
bool m_id_isSet;
|
||||||
|
|
||||||
SWGCategory* category;
|
SWGCategory* category;
|
||||||
|
bool m_category_isSet;
|
||||||
|
|
||||||
QString* name;
|
QString* name;
|
||||||
|
bool m_name_isSet;
|
||||||
|
|
||||||
QList<QString*>* photo_urls;
|
QList<QString*>* photo_urls;
|
||||||
|
bool m_photo_urls_isSet;
|
||||||
|
|
||||||
QList<SWGTag*>* tags;
|
QList<SWGTag*>* tags;
|
||||||
|
bool m_tags_isSet;
|
||||||
|
|
||||||
QString* status;
|
QString* status;
|
||||||
|
bool m_status_isSet;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,11 @@ SWGPetApi::addPet(SWGPet body) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "POST");
|
SWGHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString output = body.asJson();
|
QString output = body.asJson();
|
||||||
input.request_body.append(output);
|
input.request_body.append(output);
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ SWGPetApi::addPet(SWGPet body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGPetApi::addPetCallback);
|
&SWGPetApi::addPetCallback);
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ SWGPetApi::addPet(SWGPet body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGPetApi::addPetCallback(HttpRequestWorker * worker) {
|
SWGPetApi::addPetCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
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));
|
fullPath.replace(pet_idPathParam, stringValue(pet_id));
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "DELETE");
|
SWGHttpRequestInput input(fullPath, "DELETE");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ SWGPetApi::deletePet(qint64 pet_id, QString* api_key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGPetApi::deletePetCallback);
|
&SWGPetApi::deletePetCallback);
|
||||||
|
|
||||||
@ -111,7 +112,7 @@ SWGPetApi::deletePet(qint64 pet_id, QString* api_key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGPetApi::deletePetCallback(HttpRequestWorker * worker) {
|
SWGPetApi::deletePetCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -182,8 +183,8 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "GET");
|
SWGHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -194,7 +195,7 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGPetApi::findPetsByStatusCallback);
|
&SWGPetApi::findPetsByStatusCallback);
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) {
|
SWGPetApi::findPetsByStatusCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -228,7 +229,7 @@ SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) {
|
|||||||
output->append(o);
|
output->append(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
|
|
||||||
if (worker->error_type == QNetworkReply::NoError) {
|
if (worker->error_type == QNetworkReply::NoError) {
|
||||||
emit findPetsByStatusSignal(output);
|
emit findPetsByStatusSignal(output);
|
||||||
@ -287,8 +288,8 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "GET");
|
SWGHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -299,7 +300,7 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGPetApi::findPetsByTagsCallback);
|
&SWGPetApi::findPetsByTagsCallback);
|
||||||
|
|
||||||
@ -307,7 +308,7 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) {
|
SWGPetApi::findPetsByTagsCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -333,7 +334,7 @@ SWGPetApi::findPetsByTagsCallback(HttpRequestWorker * worker) {
|
|||||||
output->append(o);
|
output->append(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
|
|
||||||
if (worker->error_type == QNetworkReply::NoError) {
|
if (worker->error_type == QNetworkReply::NoError) {
|
||||||
emit findPetsByTagsSignal(output);
|
emit findPetsByTagsSignal(output);
|
||||||
@ -352,8 +353,8 @@ SWGPetApi::getPetById(qint64 pet_id) {
|
|||||||
fullPath.replace(pet_idPathParam, stringValue(pet_id));
|
fullPath.replace(pet_idPathParam, stringValue(pet_id));
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "GET");
|
SWGHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -364,7 +365,7 @@ SWGPetApi::getPetById(qint64 pet_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGPetApi::getPetByIdCallback);
|
&SWGPetApi::getPetByIdCallback);
|
||||||
|
|
||||||
@ -372,7 +373,7 @@ SWGPetApi::getPetById(qint64 pet_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
|
SWGPetApi::getPetByIdCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -385,6 +386,8 @@ SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString json(worker->response);
|
QString json(worker->response);
|
||||||
SWGPet* output = static_cast<SWGPet*>(create(json, QString("SWGPet")));
|
SWGPet* output = static_cast<SWGPet*>(create(json, QString("SWGPet")));
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
@ -404,10 +407,11 @@ SWGPetApi::updatePet(SWGPet body) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "PUT");
|
SWGHttpRequestInput input(fullPath, "PUT");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString output = body.asJson();
|
QString output = body.asJson();
|
||||||
input.request_body.append(output);
|
input.request_body.append(output);
|
||||||
|
|
||||||
@ -418,7 +422,7 @@ SWGPetApi::updatePet(SWGPet body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGPetApi::updatePetCallback);
|
&SWGPetApi::updatePetCallback);
|
||||||
|
|
||||||
@ -426,7 +430,7 @@ SWGPetApi::updatePet(SWGPet body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGPetApi::updatePetCallback(HttpRequestWorker * worker) {
|
SWGPetApi::updatePetCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
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));
|
fullPath.replace(pet_idPathParam, stringValue(pet_id));
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "POST");
|
SWGHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
if (name != nullptr) {
|
if (name != nullptr) {
|
||||||
input.add_var("name", *name);
|
input.add_var("name", *name);
|
||||||
@ -475,7 +479,7 @@ SWGPetApi::updatePetWithForm(qint64 pet_id, QString* name, QString* status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGPetApi::updatePetWithFormCallback);
|
&SWGPetApi::updatePetWithFormCallback);
|
||||||
|
|
||||||
@ -483,7 +487,7 @@ SWGPetApi::updatePetWithForm(qint64 pet_id, QString* name, QString* status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGPetApi::updatePetWithFormCallback(HttpRequestWorker * worker) {
|
SWGPetApi::updatePetWithFormCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
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));
|
fullPath.replace(pet_idPathParam, stringValue(pet_id));
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "POST");
|
SWGHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
if (additional_metadata != nullptr) {
|
if (additional_metadata != nullptr) {
|
||||||
input.add_var("additionalMetadata", *additional_metadata);
|
input.add_var("additionalMetadata", *additional_metadata);
|
||||||
@ -532,7 +536,7 @@ SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpReques
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGPetApi::uploadFileCallback);
|
&SWGPetApi::uploadFileCallback);
|
||||||
|
|
||||||
@ -540,7 +544,7 @@ SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpReques
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
|
SWGPetApi::uploadFileCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -553,6 +557,8 @@ SWGPetApi::uploadFileCallback(HttpRequestWorker * worker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString json(worker->response);
|
QString json(worker->response);
|
||||||
SWGApiResponse* output = static_cast<SWGApiResponse*>(create(json, QString("SWGApiResponse")));
|
SWGApiResponse* output = static_cast<SWGApiResponse*>(create(json, QString("SWGApiResponse")));
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
|
@ -46,14 +46,14 @@ public:
|
|||||||
void uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file);
|
void uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addPetCallback (HttpRequestWorker * worker);
|
void addPetCallback (SWGHttpRequestWorker * worker);
|
||||||
void deletePetCallback (HttpRequestWorker * worker);
|
void deletePetCallback (SWGHttpRequestWorker * worker);
|
||||||
void findPetsByStatusCallback (HttpRequestWorker * worker);
|
void findPetsByStatusCallback (SWGHttpRequestWorker * worker);
|
||||||
void findPetsByTagsCallback (HttpRequestWorker * worker);
|
void findPetsByTagsCallback (SWGHttpRequestWorker * worker);
|
||||||
void getPetByIdCallback (HttpRequestWorker * worker);
|
void getPetByIdCallback (SWGHttpRequestWorker * worker);
|
||||||
void updatePetCallback (HttpRequestWorker * worker);
|
void updatePetCallback (SWGHttpRequestWorker * worker);
|
||||||
void updatePetWithFormCallback (HttpRequestWorker * worker);
|
void updatePetWithFormCallback (SWGHttpRequestWorker * worker);
|
||||||
void uploadFileCallback (HttpRequestWorker * worker);
|
void uploadFileCallback (SWGHttpRequestWorker * worker);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void addPetSignal();
|
void addPetSignal();
|
||||||
@ -74,14 +74,14 @@ signals:
|
|||||||
void updatePetWithFormSignalE(QNetworkReply::NetworkError error_type, QString& error_str);
|
void updatePetWithFormSignalE(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void uploadFileSignalE(SWGApiResponse* summary, 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 addPetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void deletePetSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void deletePetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void findPetsByStatusSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void findPetsByStatusSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void findPetsByTagsSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void findPetsByTagsSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void getPetByIdSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void getPetByIdSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void updatePetSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void updatePetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void updatePetWithFormSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void updatePetWithFormSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void uploadFileSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void uploadFileSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ SWGStoreApi::deleteOrder(QString* order_id) {
|
|||||||
fullPath.replace(order_idPathParam, stringValue(order_id));
|
fullPath.replace(order_idPathParam, stringValue(order_id));
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "DELETE");
|
SWGHttpRequestInput input(fullPath, "DELETE");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ SWGStoreApi::deleteOrder(QString* order_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGStoreApi::deleteOrderCallback);
|
&SWGStoreApi::deleteOrderCallback);
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ SWGStoreApi::deleteOrder(QString* order_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGStoreApi::deleteOrderCallback(HttpRequestWorker * worker) {
|
SWGStoreApi::deleteOrderCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -86,8 +86,8 @@ SWGStoreApi::getInventory() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "GET");
|
SWGHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ SWGStoreApi::getInventory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGStoreApi::getInventoryCallback);
|
&SWGStoreApi::getInventoryCallback);
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ SWGStoreApi::getInventory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) {
|
SWGStoreApi::getInventoryCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
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>();
|
QMap<QString, qint32>* output = new QMap<QString, qint32>();
|
||||||
QString json(worker->response);
|
QString json(worker->response);
|
||||||
QByteArray array (json.toStdString().c_str());
|
QByteArray array (json.toStdString().c_str());
|
||||||
@ -150,8 +150,8 @@ SWGStoreApi::getOrderById(qint64 order_id) {
|
|||||||
fullPath.replace(order_idPathParam, stringValue(order_id));
|
fullPath.replace(order_idPathParam, stringValue(order_id));
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "GET");
|
SWGHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ SWGStoreApi::getOrderById(qint64 order_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGStoreApi::getOrderByIdCallback);
|
&SWGStoreApi::getOrderByIdCallback);
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ SWGStoreApi::getOrderById(qint64 order_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
|
SWGStoreApi::getOrderByIdCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -183,6 +183,8 @@ SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString json(worker->response);
|
QString json(worker->response);
|
||||||
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
|
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
@ -202,10 +204,11 @@ SWGStoreApi::placeOrder(SWGOrder body) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "POST");
|
SWGHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString output = body.asJson();
|
QString output = body.asJson();
|
||||||
input.request_body.append(output);
|
input.request_body.append(output);
|
||||||
|
|
||||||
@ -216,7 +219,7 @@ SWGStoreApi::placeOrder(SWGOrder body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGStoreApi::placeOrderCallback);
|
&SWGStoreApi::placeOrderCallback);
|
||||||
|
|
||||||
@ -224,7 +227,7 @@ SWGStoreApi::placeOrder(SWGOrder body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
|
SWGStoreApi::placeOrderCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -237,6 +240,8 @@ SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString json(worker->response);
|
QString json(worker->response);
|
||||||
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
|
SWGOrder* output = static_cast<SWGOrder*>(create(json, QString("SWGOrder")));
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
|
@ -41,10 +41,10 @@ public:
|
|||||||
void placeOrder(SWGOrder body);
|
void placeOrder(SWGOrder body);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void deleteOrderCallback (HttpRequestWorker * worker);
|
void deleteOrderCallback (SWGHttpRequestWorker * worker);
|
||||||
void getInventoryCallback (HttpRequestWorker * worker);
|
void getInventoryCallback (SWGHttpRequestWorker * worker);
|
||||||
void getOrderByIdCallback (HttpRequestWorker * worker);
|
void getOrderByIdCallback (SWGHttpRequestWorker * worker);
|
||||||
void placeOrderCallback (HttpRequestWorker * worker);
|
void placeOrderCallback (SWGHttpRequestWorker * worker);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deleteOrderSignal();
|
void deleteOrderSignal();
|
||||||
@ -57,10 +57,10 @@ signals:
|
|||||||
void getOrderByIdSignalE(SWGOrder* summary, QNetworkReply::NetworkError error_type, QString& error_str);
|
void getOrderByIdSignalE(SWGOrder* summary, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void placeOrderSignalE(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 deleteOrderSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void getInventorySignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void getInventorySignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void getOrderByIdSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void getOrderByIdSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void placeOrderSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void placeOrderSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,7 +38,9 @@ SWGTag::~SWGTag() {
|
|||||||
void
|
void
|
||||||
SWGTag::init() {
|
SWGTag::init() {
|
||||||
id = 0L;
|
id = 0L;
|
||||||
|
m_id_isSet = false;
|
||||||
name = new QString("");
|
name = new QString("");
|
||||||
|
m_name_isSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -77,8 +79,12 @@ SWGTag::asJson ()
|
|||||||
QJsonObject*
|
QJsonObject*
|
||||||
SWGTag::asJsonObject() {
|
SWGTag::asJsonObject() {
|
||||||
QJsonObject* obj = new QJsonObject();
|
QJsonObject* obj = new QJsonObject();
|
||||||
obj->insert("id", QJsonValue(id));
|
if(m_id_isSet){
|
||||||
toJsonValue(QString("name"), name, obj, QString("QString"));
|
obj->insert("id", QJsonValue(id));
|
||||||
|
}
|
||||||
|
if(name != nullptr && *name != QString("")){
|
||||||
|
toJsonValue(QString("name"), name, obj, QString("QString"));
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -90,6 +96,7 @@ SWGTag::getId() {
|
|||||||
void
|
void
|
||||||
SWGTag::setId(qint64 id) {
|
SWGTag::setId(qint64 id) {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
|
this->m_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -99,8 +106,18 @@ SWGTag::getName() {
|
|||||||
void
|
void
|
||||||
SWGTag::setName(QString* name) {
|
SWGTag::setName(QString* name) {
|
||||||
this->name = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,15 @@ public:
|
|||||||
void setName(QString* name);
|
void setName(QString* name);
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool isSet() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint64 id;
|
qint64 id;
|
||||||
|
bool m_id_isSet;
|
||||||
|
|
||||||
QString* name;
|
QString* name;
|
||||||
|
bool m_name_isSet;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,21 @@ SWGUser::~SWGUser() {
|
|||||||
void
|
void
|
||||||
SWGUser::init() {
|
SWGUser::init() {
|
||||||
id = 0L;
|
id = 0L;
|
||||||
|
m_id_isSet = false;
|
||||||
username = new QString("");
|
username = new QString("");
|
||||||
|
m_username_isSet = false;
|
||||||
first_name = new QString("");
|
first_name = new QString("");
|
||||||
|
m_first_name_isSet = false;
|
||||||
last_name = new QString("");
|
last_name = new QString("");
|
||||||
|
m_last_name_isSet = false;
|
||||||
email = new QString("");
|
email = new QString("");
|
||||||
|
m_email_isSet = false;
|
||||||
password = new QString("");
|
password = new QString("");
|
||||||
|
m_password_isSet = false;
|
||||||
phone = new QString("");
|
phone = new QString("");
|
||||||
|
m_phone_isSet = false;
|
||||||
user_status = 0;
|
user_status = 0;
|
||||||
|
m_user_status_isSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -105,14 +113,30 @@ SWGUser::asJson ()
|
|||||||
QJsonObject*
|
QJsonObject*
|
||||||
SWGUser::asJsonObject() {
|
SWGUser::asJsonObject() {
|
||||||
QJsonObject* obj = new QJsonObject();
|
QJsonObject* obj = new QJsonObject();
|
||||||
obj->insert("id", QJsonValue(id));
|
if(m_id_isSet){
|
||||||
toJsonValue(QString("username"), username, obj, QString("QString"));
|
obj->insert("id", QJsonValue(id));
|
||||||
toJsonValue(QString("firstName"), first_name, obj, QString("QString"));
|
}
|
||||||
toJsonValue(QString("lastName"), last_name, obj, QString("QString"));
|
if(username != nullptr && *username != QString("")){
|
||||||
toJsonValue(QString("email"), email, obj, QString("QString"));
|
toJsonValue(QString("username"), username, obj, QString("QString"));
|
||||||
toJsonValue(QString("password"), password, obj, QString("QString"));
|
}
|
||||||
toJsonValue(QString("phone"), phone, obj, QString("QString"));
|
if(first_name != nullptr && *first_name != QString("")){
|
||||||
obj->insert("userStatus", QJsonValue(user_status));
|
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;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -124,6 +148,7 @@ SWGUser::getId() {
|
|||||||
void
|
void
|
||||||
SWGUser::setId(qint64 id) {
|
SWGUser::setId(qint64 id) {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
|
this->m_id_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -133,6 +158,7 @@ SWGUser::getUsername() {
|
|||||||
void
|
void
|
||||||
SWGUser::setUsername(QString* username) {
|
SWGUser::setUsername(QString* username) {
|
||||||
this->username = username;
|
this->username = username;
|
||||||
|
this->m_username_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -142,6 +168,7 @@ SWGUser::getFirstName() {
|
|||||||
void
|
void
|
||||||
SWGUser::setFirstName(QString* first_name) {
|
SWGUser::setFirstName(QString* first_name) {
|
||||||
this->first_name = first_name;
|
this->first_name = first_name;
|
||||||
|
this->m_first_name_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -151,6 +178,7 @@ SWGUser::getLastName() {
|
|||||||
void
|
void
|
||||||
SWGUser::setLastName(QString* last_name) {
|
SWGUser::setLastName(QString* last_name) {
|
||||||
this->last_name = last_name;
|
this->last_name = last_name;
|
||||||
|
this->m_last_name_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -160,6 +188,7 @@ SWGUser::getEmail() {
|
|||||||
void
|
void
|
||||||
SWGUser::setEmail(QString* email) {
|
SWGUser::setEmail(QString* email) {
|
||||||
this->email = email;
|
this->email = email;
|
||||||
|
this->m_email_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -169,6 +198,7 @@ SWGUser::getPassword() {
|
|||||||
void
|
void
|
||||||
SWGUser::setPassword(QString* password) {
|
SWGUser::setPassword(QString* password) {
|
||||||
this->password = password;
|
this->password = password;
|
||||||
|
this->m_password_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString*
|
QString*
|
||||||
@ -178,6 +208,7 @@ SWGUser::getPhone() {
|
|||||||
void
|
void
|
||||||
SWGUser::setPhone(QString* phone) {
|
SWGUser::setPhone(QString* phone) {
|
||||||
this->phone = phone;
|
this->phone = phone;
|
||||||
|
this->m_phone_isSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32
|
qint32
|
||||||
@ -187,8 +218,24 @@ SWGUser::getUserStatus() {
|
|||||||
void
|
void
|
||||||
SWGUser::setUserStatus(qint32 user_status) {
|
SWGUser::setUserStatus(qint32 user_status) {
|
||||||
this->user_status = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,15 +66,33 @@ public:
|
|||||||
void setUserStatus(qint32 user_status);
|
void setUserStatus(qint32 user_status);
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool isSet() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint64 id;
|
qint64 id;
|
||||||
|
bool m_id_isSet;
|
||||||
|
|
||||||
QString* username;
|
QString* username;
|
||||||
|
bool m_username_isSet;
|
||||||
|
|
||||||
QString* first_name;
|
QString* first_name;
|
||||||
|
bool m_first_name_isSet;
|
||||||
|
|
||||||
QString* last_name;
|
QString* last_name;
|
||||||
|
bool m_last_name_isSet;
|
||||||
|
|
||||||
QString* email;
|
QString* email;
|
||||||
|
bool m_email_isSet;
|
||||||
|
|
||||||
QString* password;
|
QString* password;
|
||||||
|
bool m_password_isSet;
|
||||||
|
|
||||||
QString* phone;
|
QString* phone;
|
||||||
|
bool m_phone_isSet;
|
||||||
|
|
||||||
qint32 user_status;
|
qint32 user_status;
|
||||||
|
bool m_user_status_isSet;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,11 @@ SWGUserApi::createUser(SWGUser body) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "POST");
|
SWGHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString output = body.asJson();
|
QString output = body.asJson();
|
||||||
input.request_body.append(output);
|
input.request_body.append(output);
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ SWGUserApi::createUser(SWGUser body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGUserApi::createUserCallback);
|
&SWGUserApi::createUserCallback);
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ SWGUserApi::createUser(SWGUser body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGUserApi::createUserCallback(HttpRequestWorker * worker) {
|
SWGUserApi::createUserCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -86,8 +87,8 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "POST");
|
SWGHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
|
|
||||||
QJsonArray* bodyArray = new QJsonArray();
|
QJsonArray* bodyArray = new QJsonArray();
|
||||||
@ -97,7 +98,7 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
|
|||||||
QByteArray bytes = doc.toJson();
|
QByteArray bytes = doc.toJson();
|
||||||
|
|
||||||
input.request_body.append(bytes);
|
input.request_body.append(bytes);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach(QString key, this->defaultHeaders.keys()) {
|
foreach(QString key, this->defaultHeaders.keys()) {
|
||||||
@ -105,7 +106,7 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGUserApi::createUsersWithArrayInputCallback);
|
&SWGUserApi::createUsersWithArrayInputCallback);
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGUserApi::createUsersWithArrayInputCallback(HttpRequestWorker * worker) {
|
SWGUserApi::createUsersWithArrayInputCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -142,8 +143,8 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "POST");
|
SWGHttpRequestInput input(fullPath, "POST");
|
||||||
|
|
||||||
|
|
||||||
QJsonArray* bodyArray = new QJsonArray();
|
QJsonArray* bodyArray = new QJsonArray();
|
||||||
@ -153,7 +154,7 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
|
|||||||
QByteArray bytes = doc.toJson();
|
QByteArray bytes = doc.toJson();
|
||||||
|
|
||||||
input.request_body.append(bytes);
|
input.request_body.append(bytes);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach(QString key, this->defaultHeaders.keys()) {
|
foreach(QString key, this->defaultHeaders.keys()) {
|
||||||
@ -161,7 +162,7 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGUserApi::createUsersWithListInputCallback);
|
&SWGUserApi::createUsersWithListInputCallback);
|
||||||
|
|
||||||
@ -169,7 +170,7 @@ SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGUserApi::createUsersWithListInputCallback(HttpRequestWorker * worker) {
|
SWGUserApi::createUsersWithListInputCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -200,8 +201,8 @@ SWGUserApi::deleteUser(QString* username) {
|
|||||||
fullPath.replace(usernamePathParam, stringValue(username));
|
fullPath.replace(usernamePathParam, stringValue(username));
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "DELETE");
|
SWGHttpRequestInput input(fullPath, "DELETE");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -212,7 +213,7 @@ SWGUserApi::deleteUser(QString* username) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGUserApi::deleteUserCallback);
|
&SWGUserApi::deleteUserCallback);
|
||||||
|
|
||||||
@ -220,7 +221,7 @@ SWGUserApi::deleteUser(QString* username) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGUserApi::deleteUserCallback(HttpRequestWorker * worker) {
|
SWGUserApi::deleteUserCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -251,8 +252,8 @@ SWGUserApi::getUserByName(QString* username) {
|
|||||||
fullPath.replace(usernamePathParam, stringValue(username));
|
fullPath.replace(usernamePathParam, stringValue(username));
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "GET");
|
SWGHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -263,7 +264,7 @@ SWGUserApi::getUserByName(QString* username) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGUserApi::getUserByNameCallback);
|
&SWGUserApi::getUserByNameCallback);
|
||||||
|
|
||||||
@ -271,7 +272,7 @@ SWGUserApi::getUserByName(QString* username) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
|
SWGUserApi::getUserByNameCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -284,6 +285,8 @@ SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString json(worker->response);
|
QString json(worker->response);
|
||||||
SWGUser* output = static_cast<SWGUser*>(create(json, QString("SWGUser")));
|
SWGUser* output = static_cast<SWGUser*>(create(json, QString("SWGUser")));
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
@ -319,8 +322,8 @@ SWGUserApi::loginUser(QString* username, QString* password) {
|
|||||||
.append(QUrl::toPercentEncoding(stringValue(password)));
|
.append(QUrl::toPercentEncoding(stringValue(password)));
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "GET");
|
SWGHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -331,7 +334,7 @@ SWGUserApi::loginUser(QString* username, QString* password) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGUserApi::loginUserCallback);
|
&SWGUserApi::loginUserCallback);
|
||||||
|
|
||||||
@ -339,7 +342,7 @@ SWGUserApi::loginUser(QString* username, QString* password) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGUserApi::loginUserCallback(HttpRequestWorker * worker) {
|
SWGUserApi::loginUserCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -352,6 +355,8 @@ SWGUserApi::loginUserCallback(HttpRequestWorker * worker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString json(worker->response);
|
QString json(worker->response);
|
||||||
QString* output = static_cast<QString*>(create(json, QString("QString")));
|
QString* output = static_cast<QString*>(create(json, QString("QString")));
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
@ -371,8 +376,8 @@ SWGUserApi::logoutUser() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "GET");
|
SWGHttpRequestInput input(fullPath, "GET");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -383,7 +388,7 @@ SWGUserApi::logoutUser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGUserApi::logoutUserCallback);
|
&SWGUserApi::logoutUserCallback);
|
||||||
|
|
||||||
@ -391,7 +396,7 @@ SWGUserApi::logoutUser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGUserApi::logoutUserCallback(HttpRequestWorker * worker) {
|
SWGUserApi::logoutUserCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -422,10 +427,11 @@ SWGUserApi::updateUser(QString* username, SWGUser body) {
|
|||||||
fullPath.replace(usernamePathParam, stringValue(username));
|
fullPath.replace(usernamePathParam, stringValue(username));
|
||||||
|
|
||||||
|
|
||||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
|
||||||
HttpRequestInput input(fullPath, "PUT");
|
SWGHttpRequestInput input(fullPath, "PUT");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString output = body.asJson();
|
QString output = body.asJson();
|
||||||
input.request_body.append(output);
|
input.request_body.append(output);
|
||||||
|
|
||||||
@ -436,7 +442,7 @@ SWGUserApi::updateUser(QString* username, SWGUser body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&SWGHttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGUserApi::updateUserCallback);
|
&SWGUserApi::updateUserCallback);
|
||||||
|
|
||||||
@ -444,7 +450,7 @@ SWGUserApi::updateUser(QString* username, SWGUser body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGUserApi::updateUserCallback(HttpRequestWorker * worker) {
|
SWGUserApi::updateUserCallback(SWGHttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
|
@ -45,14 +45,14 @@ public:
|
|||||||
void updateUser(QString* username, SWGUser body);
|
void updateUser(QString* username, SWGUser body);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createUserCallback (HttpRequestWorker * worker);
|
void createUserCallback (SWGHttpRequestWorker * worker);
|
||||||
void createUsersWithArrayInputCallback (HttpRequestWorker * worker);
|
void createUsersWithArrayInputCallback (SWGHttpRequestWorker * worker);
|
||||||
void createUsersWithListInputCallback (HttpRequestWorker * worker);
|
void createUsersWithListInputCallback (SWGHttpRequestWorker * worker);
|
||||||
void deleteUserCallback (HttpRequestWorker * worker);
|
void deleteUserCallback (SWGHttpRequestWorker * worker);
|
||||||
void getUserByNameCallback (HttpRequestWorker * worker);
|
void getUserByNameCallback (SWGHttpRequestWorker * worker);
|
||||||
void loginUserCallback (HttpRequestWorker * worker);
|
void loginUserCallback (SWGHttpRequestWorker * worker);
|
||||||
void logoutUserCallback (HttpRequestWorker * worker);
|
void logoutUserCallback (SWGHttpRequestWorker * worker);
|
||||||
void updateUserCallback (HttpRequestWorker * worker);
|
void updateUserCallback (SWGHttpRequestWorker * worker);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void createUserSignal();
|
void createUserSignal();
|
||||||
@ -73,14 +73,14 @@ signals:
|
|||||||
void logoutUserSignalE(QNetworkReply::NetworkError error_type, QString& error_str);
|
void logoutUserSignalE(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void updateUserSignalE(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 createUserSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void createUsersWithArrayInputSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void createUsersWithArrayInputSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void createUsersWithListInputSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void createUsersWithListInputSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void deleteUserSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void deleteUserSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void getUserByNameSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void getUserByNameSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void loginUserSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void loginUserSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void logoutUserSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void logoutUserSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
void updateUserSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
void updateUserSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user