forked from loafle/openapi-generator-original
[C++] [Qt5] Clang format Code (#4444)
* HttpFileElement * HttpRequest * Add .clang-format * cpp-qt5-client: fix warning reordering member initialization * api * enum * licenseInfo * model * object * helper * test * QString::arg start from %1 (not from %0) * fixup! model
This commit is contained in:
committed by
William Cheng
parent
cd6986d9be
commit
8991168518
@@ -1,5 +1,4 @@
|
||||
{{>licenseInfo}}
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
@@ -11,129 +10,117 @@
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
void
|
||||
{{prefix}}HttpFileElement::setMimeType(const QString &mime){
|
||||
void {{prefix}}HttpFileElement::setMimeType(const QString &mime) {
|
||||
mime_type = mime;
|
||||
}
|
||||
|
||||
void
|
||||
{{prefix}}HttpFileElement::setFileName(const QString &name){
|
||||
void {{prefix}}HttpFileElement::setFileName(const QString &name) {
|
||||
local_filename = name;
|
||||
}
|
||||
|
||||
void
|
||||
{{prefix}}HttpFileElement::setVariableName(const QString &name){
|
||||
void {{prefix}}HttpFileElement::setVariableName(const QString &name) {
|
||||
variable_name = name;
|
||||
}
|
||||
|
||||
void
|
||||
{{prefix}}HttpFileElement::setRequestFileName(const QString &name){
|
||||
void {{prefix}}HttpFileElement::setRequestFileName(const QString &name) {
|
||||
request_filename = name;
|
||||
}
|
||||
|
||||
bool
|
||||
{{prefix}}HttpFileElement::isSet() const {
|
||||
bool {{prefix}}HttpFileElement::isSet() const {
|
||||
return !local_filename.isEmpty() || !request_filename.isEmpty();
|
||||
}
|
||||
|
||||
QString
|
||||
{{prefix}}HttpFileElement::asJson() const{
|
||||
QString {{prefix}}HttpFileElement::asJson() const {
|
||||
QFile file(local_filename);
|
||||
QByteArray bArray;
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
if (file.exists()) {
|
||||
result = file.open(QIODevice::ReadOnly);
|
||||
bArray = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error opening file " << local_filename;
|
||||
}
|
||||
return QString(bArray);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
{{prefix}}HttpFileElement::asJsonValue() const{
|
||||
QJsonValue {{prefix}}HttpFileElement::asJsonValue() const {
|
||||
QFile file(local_filename);
|
||||
QByteArray bArray;
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
bool result = false;
|
||||
if (file.exists()) {
|
||||
result = file.open(QIODevice::ReadOnly);
|
||||
bArray = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error opening file " << local_filename;
|
||||
}
|
||||
return QJsonDocument::fromBinaryData(bArray.data()).object();
|
||||
}
|
||||
|
||||
bool
|
||||
{{prefix}}HttpFileElement::fromStringValue(const QString &instr){
|
||||
bool {{prefix}}HttpFileElement::fromStringValue(const QString &instr) {
|
||||
QFile file(local_filename);
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
if (file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
result = file.open(QIODevice::WriteOnly);
|
||||
file.write(instr.toUtf8());
|
||||
file.close();
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error creating file " << local_filename;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
{{prefix}}HttpFileElement::fromJsonValue(const QJsonValue &jval) {
|
||||
bool {{prefix}}HttpFileElement::fromJsonValue(const QJsonValue &jval) {
|
||||
QFile file(local_filename);
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
if (file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
result = file.open(QIODevice::WriteOnly);
|
||||
file.write(QJsonDocument(jval.toObject()).toBinaryData());
|
||||
file.close();
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error creating file " << local_filename;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QByteArray
|
||||
{{prefix}}HttpFileElement::asByteArray() const {
|
||||
QByteArray {{prefix}}HttpFileElement::asByteArray() const {
|
||||
QFile file(local_filename);
|
||||
QByteArray bArray;
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
if (file.exists()) {
|
||||
result = file.open(QIODevice::ReadOnly);
|
||||
bArray = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error opening file " << local_filename;
|
||||
}
|
||||
}
|
||||
return bArray;
|
||||
}
|
||||
|
||||
bool
|
||||
{{prefix}}HttpFileElement::fromByteArray(const QByteArray& bytes){
|
||||
bool {{prefix}}HttpFileElement::fromByteArray(const QByteArray &bytes) {
|
||||
QFile file(local_filename);
|
||||
bool result = false;
|
||||
if(file.exists()){
|
||||
if (file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
result = file.open(QIODevice::WriteOnly);
|
||||
file.write(bytes);
|
||||
file.close();
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error creating file " << local_filename;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
{{prefix}}HttpFileElement::saveToFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime, const QByteArray& bytes){
|
||||
bool {{prefix}}HttpFileElement::saveToFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime, const QByteArray &bytes) {
|
||||
setMimeType(mime);
|
||||
setFileName(localFName);
|
||||
setVariableName(varName);
|
||||
@@ -141,8 +128,7 @@ bool
|
||||
return fromByteArray(bytes);
|
||||
}
|
||||
|
||||
QByteArray
|
||||
{{prefix}}HttpFileElement::loadFromFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime){
|
||||
QByteArray {{prefix}}HttpFileElement::loadFromFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime) {
|
||||
setMimeType(mime);
|
||||
setFileName(localFName);
|
||||
setVariableName(varName);
|
||||
@@ -151,5 +137,5 @@ QByteArray
|
||||
}
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
@@ -25,8 +24,8 @@ public:
|
||||
bool isSet() const;
|
||||
bool fromStringValue(const QString &instr);
|
||||
bool fromJsonValue(const QJsonValue &jval);
|
||||
bool fromByteArray(const QByteArray& bytes);
|
||||
bool saveToFile(const QString &variable_name, const QString &local_filename, const QString &request_filename, const QString &mime, const QByteArray& bytes);
|
||||
bool fromByteArray(const QByteArray &bytes);
|
||||
bool saveToFile(const QString &variable_name, const QString &local_filename, const QString &request_filename, const QString &mime, const QByteArray &bytes);
|
||||
QString asJson() const;
|
||||
QJsonValue asJsonValue() const;
|
||||
QByteArray asByteArray() const;
|
||||
@@ -34,7 +33,7 @@ public:
|
||||
};
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{prefix}}HttpFileElement)
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
{{>licenseInfo}}
|
||||
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QUuid>
|
||||
#include <QUrl>
|
||||
#include <QFileInfo>
|
||||
#include <QBuffer>
|
||||
#include <QtGlobal>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <QUuid>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "{{prefix}}HttpRequest.h"
|
||||
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
@@ -46,61 +43,58 @@ void {{prefix}}HttpRequestInput::add_file(QString variable_name, QString local_f
|
||||
files.append(file);
|
||||
}
|
||||
|
||||
|
||||
{{prefix}}HttpRequestWorker::{{prefix}}HttpRequestWorker(QObject *parent)
|
||||
: QObject(parent), manager(nullptr), _timeOut(0)
|
||||
{
|
||||
: QObject(parent), manager(nullptr), _timeOut(0) {
|
||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||
manager = new QNetworkAccessManager(this);
|
||||
workingDirectory = QDir::currentPath();
|
||||
workingDirectory = QDir::currentPath();
|
||||
connect(manager, &QNetworkAccessManager::finished, this, &{{prefix}}HttpRequestWorker::on_manager_finished);
|
||||
}
|
||||
|
||||
{{prefix}}HttpRequestWorker::~{{prefix}}HttpRequestWorker() {
|
||||
for (const auto & item: multiPartFields) {
|
||||
if(item != nullptr) {
|
||||
for (const auto &item : multiPartFields) {
|
||||
if (item != nullptr) {
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMap<QString, QString> {{prefix}}HttpRequestWorker::getResponseHeaders() const {
|
||||
return headers;
|
||||
}
|
||||
|
||||
{{prefix}}HttpFileElement {{prefix}}HttpRequestWorker::getHttpFileElement(const QString &fieldname){
|
||||
if(!files.isEmpty()){
|
||||
if(fieldname.isEmpty()){
|
||||
{{prefix}}HttpFileElement {{prefix}}HttpRequestWorker::getHttpFileElement(const QString &fieldname) {
|
||||
if (!files.isEmpty()) {
|
||||
if (fieldname.isEmpty()) {
|
||||
return files.first();
|
||||
}else if (files.contains(fieldname)){
|
||||
} else if (files.contains(fieldname)) {
|
||||
return files[fieldname];
|
||||
}
|
||||
}
|
||||
return {{prefix}}HttpFileElement();
|
||||
}
|
||||
|
||||
QByteArray *{{prefix}}HttpRequestWorker::getMultiPartField(const QString &fieldname){
|
||||
if(!multiPartFields.isEmpty()){
|
||||
if(fieldname.isEmpty()){
|
||||
QByteArray *{{prefix}}HttpRequestWorker::getMultiPartField(const QString &fieldname) {
|
||||
if (!multiPartFields.isEmpty()) {
|
||||
if (fieldname.isEmpty()) {
|
||||
return multiPartFields.first();
|
||||
}else if (multiPartFields.contains(fieldname)){
|
||||
} else if (multiPartFields.contains(fieldname)) {
|
||||
return multiPartFields[fieldname];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void {{prefix}}HttpRequestWorker::setTimeOut(int timeOut){
|
||||
void {{prefix}}HttpRequestWorker::setTimeOut(int timeOut) {
|
||||
_timeOut = timeOut;
|
||||
}
|
||||
|
||||
void {{prefix}}HttpRequestWorker::setWorkingDirectory(const QString &path){
|
||||
if(!path.isEmpty()){
|
||||
void {{prefix}}HttpRequestWorker::setWorkingDirectory(const QString &path) {
|
||||
if (!path.isEmpty()) {
|
||||
workingDirectory = path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString {{prefix}}HttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
|
||||
// result structure follows RFC 5987
|
||||
bool need_utf_encoding = false;
|
||||
@@ -112,11 +106,9 @@ QString {{prefix}}HttpRequestWorker::http_attribute_encode(QString attribute_nam
|
||||
if (c == '\\' || c == '/' || c == '\0' || c < ' ' || c > '~') {
|
||||
// ignore and request utf-8 version
|
||||
need_utf_encoding = true;
|
||||
}
|
||||
else if (c == '"') {
|
||||
} else if (c == '"') {
|
||||
result += "\\\"";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result += c;
|
||||
}
|
||||
}
|
||||
@@ -133,14 +125,9 @@ QString {{prefix}}HttpRequestWorker::http_attribute_encode(QString attribute_nam
|
||||
QString result_utf8 = "";
|
||||
for (int i = 0; i < input_c.length(); i++) {
|
||||
c = input_c.at(i);
|
||||
if (
|
||||
(c >= '0' && c <= '9')
|
||||
|| (c >= 'A' && c <= 'Z')
|
||||
|| (c >= 'a' && c <= 'z')
|
||||
) {
|
||||
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
|
||||
result_utf8 += c;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result_utf8 += "%" + QString::number(static_cast<unsigned char>(input_c.at(i)), 16).toUpper();
|
||||
}
|
||||
}
|
||||
@@ -152,14 +139,13 @@ QString {{prefix}}HttpRequestWorker::http_attribute_encode(QString attribute_nam
|
||||
void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
|
||||
|
||||
// reset variables
|
||||
QNetworkReply* reply = nullptr;
|
||||
QNetworkReply *reply = nullptr;
|
||||
QByteArray request_content = "";
|
||||
response = "";
|
||||
error_type = QNetworkReply::NoError;
|
||||
error_str = "";
|
||||
bool isFormData = false;
|
||||
|
||||
|
||||
// decide on the variable layout
|
||||
|
||||
if (input->files.length() > 0) {
|
||||
@@ -169,7 +155,6 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
|
||||
input->var_layout = input->http_method == "GET" || input->http_method == "HEAD" ? ADDRESS : URL_ENCODED;
|
||||
}
|
||||
|
||||
|
||||
// prepare request content
|
||||
|
||||
QString boundary = "";
|
||||
@@ -196,13 +181,12 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
|
||||
request_content = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// variable layout is MULTIPART
|
||||
|
||||
boundary = "__-----------------------"
|
||||
+ QString::number(QDateTime::currentDateTime().toTime_t())
|
||||
+ QString::number(qrand());
|
||||
boundary = QString("__-----------------------%1%2")
|
||||
.arg(QDateTime::currentDateTime().toTime_t())
|
||||
.arg(qrand());
|
||||
QString boundary_delimiter = "--";
|
||||
QString new_line = "\r\n";
|
||||
|
||||
@@ -233,11 +217,13 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
|
||||
QFileInfo fi(file_info->local_filename);
|
||||
|
||||
// ensure necessary variables are available
|
||||
if (
|
||||
file_info->local_filename == nullptr || file_info->local_filename.isEmpty()
|
||||
|| file_info->variable_name == nullptr || file_info->variable_name.isEmpty()
|
||||
|| !fi.exists() || !fi.isFile() || !fi.isReadable()
|
||||
) {
|
||||
if (file_info->local_filename == nullptr
|
||||
|| file_info->local_filename.isEmpty()
|
||||
|| file_info->variable_name == nullptr
|
||||
|| file_info->variable_name.isEmpty()
|
||||
|| !fi.exists()
|
||||
|| !fi.isFile()
|
||||
|| !fi.isReadable()) {
|
||||
// silent abort for the current file
|
||||
continue;
|
||||
}
|
||||
@@ -262,10 +248,8 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
|
||||
request_content.append(new_line);
|
||||
|
||||
// add header
|
||||
request_content.append(QString("Content-Disposition: form-data; %1; %2").arg(
|
||||
http_attribute_encode("name", file_info->variable_name),
|
||||
http_attribute_encode("filename", file_info->request_filename)
|
||||
));
|
||||
request_content.append(
|
||||
QString("Content-Disposition: form-data; %1; %2").arg(http_attribute_encode("name", file_info->variable_name), http_attribute_encode("filename", file_info->request_filename)));
|
||||
request_content.append(new_line);
|
||||
|
||||
if (file_info->mime_type != nullptr && !file_info->mime_type.isEmpty()) {
|
||||
@@ -293,7 +277,7 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
|
||||
request_content.append(boundary_delimiter);
|
||||
}
|
||||
|
||||
if(input->request_body.size() > 0) {
|
||||
if (input->request_body.size() > 0) {
|
||||
qDebug() << "got a request body";
|
||||
request_content.clear();
|
||||
request_content.append(input->request_body);
|
||||
@@ -305,41 +289,31 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
|
||||
request.setSslConfiguration(*{{prefix}}HttpRequestWorker::sslDefaultConfiguration);
|
||||
}
|
||||
request.setRawHeader("User-Agent", "{{#httpUserAgent}}{{.}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{apiVersion}}/cpp-qt5{{/httpUserAgent}}");
|
||||
foreach(QString key, input->headers.keys()) {
|
||||
request.setRawHeader(key.toStdString().c_str(), input->headers.value(key).toStdString().c_str());
|
||||
}
|
||||
foreach (QString key, input->headers.keys()) { request.setRawHeader(key.toStdString().c_str(), input->headers.value(key).toStdString().c_str()); }
|
||||
|
||||
if (request_content.size() > 0 && !isFormData && (input->var_layout != MULTIPART)) {
|
||||
if(!input->headers.contains("Content-Type")){
|
||||
if (!input->headers.contains("Content-Type")) {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, input->headers.value("Content-Type"));
|
||||
}
|
||||
}
|
||||
else if (input->var_layout == URL_ENCODED) {
|
||||
} else if (input->var_layout == URL_ENCODED) {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
}
|
||||
else if (input->var_layout == MULTIPART) {
|
||||
} else if (input->var_layout == MULTIPART) {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=" + boundary);
|
||||
}
|
||||
|
||||
if (input->http_method == "GET") {
|
||||
reply = manager->get(request);
|
||||
}
|
||||
else if (input->http_method == "POST") {
|
||||
} else if (input->http_method == "POST") {
|
||||
reply = manager->post(request, request_content);
|
||||
}
|
||||
else if (input->http_method == "PUT") {
|
||||
} else if (input->http_method == "PUT") {
|
||||
reply = manager->put(request, request_content);
|
||||
}
|
||||
else if (input->http_method == "HEAD") {
|
||||
} else if (input->http_method == "HEAD") {
|
||||
reply = manager->head(request);
|
||||
}
|
||||
else if (input->http_method == "DELETE") {
|
||||
} else if (input->http_method == "DELETE") {
|
||||
reply = manager->deleteResource(request);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
#if (QT_VERSION >= 0x050800)
|
||||
manager->sendCustomRequest(request, input->http_method.toLatin1(), request_content);
|
||||
#else
|
||||
@@ -351,8 +325,8 @@ void {{prefix}}HttpRequestWorker::execute({{prefix}}HttpRequestInput *input) {
|
||||
buffer->setParent(reply);
|
||||
#endif
|
||||
}
|
||||
if(_timeOut > 0){
|
||||
QTimer::singleShot(_timeOut, [=](){ on_manager_timeout(reply); });
|
||||
if (_timeOut > 0) {
|
||||
QTimer::singleShot(_timeOut, [=]() { on_manager_timeout(reply); });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,8 +334,8 @@ void {{prefix}}HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
|
||||
error_type = reply->error();
|
||||
response = reply->readAll();
|
||||
error_str = reply->errorString();
|
||||
if(reply->rawHeaderPairs().count() > 0){
|
||||
for(const auto& item: reply->rawHeaderPairs()){
|
||||
if (reply->rawHeaderPairs().count() > 0) {
|
||||
for (const auto &item : reply->rawHeaderPairs()) {
|
||||
headers.insert(item.first, item.second);
|
||||
}
|
||||
}
|
||||
@@ -381,36 +355,33 @@ void {{prefix}}HttpRequestWorker::on_manager_timeout(QNetworkReply *reply) {
|
||||
}
|
||||
|
||||
void {{prefix}}HttpRequestWorker::process_form_response() {
|
||||
if(getResponseHeaders().contains(QString("Content-Disposition")) ) {
|
||||
if (getResponseHeaders().contains(QString("Content-Disposition"))) {
|
||||
auto contentDisposition = getResponseHeaders().value(QString("Content-Disposition").toUtf8()).split(QString(";"), QString::SkipEmptyParts);
|
||||
auto contentType = getResponseHeaders().contains(QString("Content-Type")) ? getResponseHeaders().value(QString("Content-Type").toUtf8()).split(QString(";"), QString::SkipEmptyParts).first() : QString();
|
||||
if((contentDisposition.count() > 0) && (contentDisposition.first() == QString("attachment"))){
|
||||
auto contentType =
|
||||
getResponseHeaders().contains(QString("Content-Type")) ? getResponseHeaders().value(QString("Content-Type").toUtf8()).split(QString(";"), QString::SkipEmptyParts).first() : QString();
|
||||
if ((contentDisposition.count() > 0) && (contentDisposition.first() == QString("attachment"))) {
|
||||
QString filename = QUuid::createUuid().toString();
|
||||
for(const auto &file : contentDisposition){
|
||||
if(file.contains(QString("filename"))){
|
||||
for (const auto &file : contentDisposition) {
|
||||
if (file.contains(QString("filename"))) {
|
||||
filename = file.split(QString("="), QString::SkipEmptyParts).at(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
{{prefix}}HttpFileElement felement;
|
||||
felement.saveToFile(QString(), workingDirectory + QDir::separator() + filename, filename, contentType, response.data());
|
||||
files.insert(filename, felement);
|
||||
files.insert(filename, felement);
|
||||
}
|
||||
|
||||
} else if(getResponseHeaders().contains(QString("Content-Type")) ) {
|
||||
} else if (getResponseHeaders().contains(QString("Content-Type"))) {
|
||||
auto contentType = getResponseHeaders().value(QString("Content-Type").toUtf8()).split(QString(";"), QString::SkipEmptyParts);
|
||||
if((contentType.count() > 0) && (contentType.first() == QString("multipart/form-data"))){
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if ((contentType.count() > 0) && (contentType.first() == QString("multipart/form-data"))) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QSslConfiguration* {{prefix}}HttpRequestWorker::sslDefaultConfiguration;
|
||||
|
||||
QSslConfiguration *{{prefix}}HttpRequestWorker::sslDefaultConfiguration;
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#ifndef {{prefix}}_HTTPREQUESTWORKER_H
|
||||
#define {{prefix}}_HTTPREQUESTWORKER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "{{prefix}}HttpFileElement.h"
|
||||
|
||||
@@ -20,8 +20,12 @@
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
enum {{prefix}}HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
|
||||
|
||||
enum {{prefix}}HttpRequestVarLayout {
|
||||
NOT_SET,
|
||||
ADDRESS,
|
||||
URL_ENCODED,
|
||||
MULTIPART
|
||||
};
|
||||
|
||||
class {{prefix}}HttpRequestInput {
|
||||
|
||||
@@ -39,10 +43,8 @@ public:
|
||||
void initialize();
|
||||
void add_var(QString key, QString value);
|
||||
void add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class {{prefix}}HttpRequestWorker : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -56,11 +58,11 @@ public:
|
||||
QMap<QString, QString> getResponseHeaders() const;
|
||||
QString http_attribute_encode(QString attribute_name, QString input);
|
||||
void execute({{prefix}}HttpRequestInput *input);
|
||||
static QSslConfiguration* sslDefaultConfiguration;
|
||||
static QSslConfiguration *sslDefaultConfiguration;
|
||||
void setTimeOut(int tout);
|
||||
void setWorkingDirectory(const QString &path);
|
||||
{{prefix}}HttpFileElement getHttpFileElement(const QString &fieldname = QString());
|
||||
QByteArray* getMultiPartField(const QString &fieldname = QString());
|
||||
QByteArray *getMultiPartField(const QString &fieldname = QString());
|
||||
signals:
|
||||
void on_execution_finished({{prefix}}HttpRequestWorker *worker);
|
||||
|
||||
@@ -68,17 +70,17 @@ private:
|
||||
QNetworkAccessManager *manager;
|
||||
QMap<QString, QString> headers;
|
||||
QMap<QString, {{prefix}}HttpFileElement> files;
|
||||
QMap<QString, QByteArray*> multiPartFields;
|
||||
QMap<QString, QByteArray *> multiPartFields;
|
||||
QString workingDirectory;
|
||||
int _timeOut;
|
||||
void on_manager_timeout(QNetworkReply *reply);
|
||||
void process_form_response();
|
||||
void process_form_response();
|
||||
private slots:
|
||||
void on_manager_finished(QNetworkReply *reply);
|
||||
};
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
#endif // {{prefix}}_HTTPREQUESTWORKER_H
|
||||
|
||||
@@ -9,166 +9,150 @@
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
{{classname}}::{{classname}}(const QString &scheme, const QString &host, int port, const QString& basePath, const int timeOut) :
|
||||
_scheme(scheme),
|
||||
_host(host),
|
||||
_port(port),
|
||||
_basePath(basePath),
|
||||
_timeOut(timeOut) {
|
||||
}
|
||||
{{classname}}::{{classname}}(const QString &scheme, const QString &host, int port, const QString &basePath, const int timeOut)
|
||||
: _scheme(scheme),
|
||||
_host(host),
|
||||
_port(port),
|
||||
_basePath(basePath),
|
||||
_timeOut(timeOut) {}
|
||||
|
||||
{{classname}}::~{{classname}}() {
|
||||
}
|
||||
|
||||
void {{classname}}::setScheme(const QString& scheme){
|
||||
void {{classname}}::setScheme(const QString &scheme) {
|
||||
_scheme = scheme;
|
||||
}
|
||||
|
||||
void {{classname}}::setHost(const QString& host){
|
||||
void {{classname}}::setHost(const QString &host) {
|
||||
_host = host;
|
||||
}
|
||||
|
||||
void {{classname}}::setPort(int port){
|
||||
void {{classname}}::setPort(int port) {
|
||||
_port = port;
|
||||
}
|
||||
|
||||
void {{classname}}::setBasePath(const QString& basePath){
|
||||
void {{classname}}::setBasePath(const QString &basePath) {
|
||||
_basePath = basePath;
|
||||
}
|
||||
|
||||
void {{classname}}::setTimeOut(const int timeOut){
|
||||
void {{classname}}::setTimeOut(const int timeOut) {
|
||||
_timeOut = timeOut;
|
||||
}
|
||||
|
||||
void {{classname}}::setWorkingDirectory(const QString& path){
|
||||
void {{classname}}::setWorkingDirectory(const QString &path) {
|
||||
_workingDirectory = path;
|
||||
}
|
||||
|
||||
void {{classname}}::addHeaders(const QString& key, const QString& value){
|
||||
void {{classname}}::addHeaders(const QString &key, const QString &value) {
|
||||
defaultHeaders.insert(key, value);
|
||||
}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
void
|
||||
{{classname}}::{{nickname}}({{#allParams}}const {{{dataType}}}& {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("{{{path}}}");
|
||||
void {{classname}}::{{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("{{{path}}}");
|
||||
{{#pathParams}}
|
||||
QString {{paramName}}PathParam("{");
|
||||
{{paramName}}PathParam.append("{{baseName}}").append("}");
|
||||
fullPath.replace({{paramName}}PathParam, QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}})));
|
||||
{{/pathParams}}
|
||||
{{#queryParams}}{{^collectionFormat}}
|
||||
{{/pathParams}}
|
||||
{{#queryParams}}{{^collectionFormat}}
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append(QUrl::toPercentEncoding("{{baseName}}"))
|
||||
.append("=")
|
||||
.append(QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}})));
|
||||
{{/collectionFormat}}{{#collectionFormat}}
|
||||
fullPath.append("?");
|
||||
fullPath.append(QUrl::toPercentEncoding("{{baseName}}")).append("=").append(QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}})));
|
||||
{{/collectionFormat}}{{#collectionFormat}}
|
||||
if ({{{paramName}}}.size() > 0) {
|
||||
if (QString("{{collectionFormat}}").indexOf("multi") == 0) {
|
||||
foreach({{{baseType}}} t, {{paramName}}) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("{{{baseName}}}=").append(::{{cppNamespace}}::toStringValue(t));
|
||||
if (QString("{{collectionFormat}}").indexOf("multi") == 0) {
|
||||
foreach ({{{baseType}}} t, {{paramName}}) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("{{{baseName}}}=").append(::{{cppNamespace}}::toStringValue(t));
|
||||
}
|
||||
} else if (QString("{{collectionFormat}}").indexOf("ssv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("{{baseName}}=");
|
||||
qint32 count = 0;
|
||||
foreach ({{{baseType}}} t, {{paramName}}) {
|
||||
if (count > 0) {
|
||||
fullPath.append(" ");
|
||||
}
|
||||
fullPath.append(::{{cppNamespace}}::toStringValue(t));
|
||||
}
|
||||
} else if (QString("{{collectionFormat}}").indexOf("tsv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("{{baseName}}=");
|
||||
qint32 count = 0;
|
||||
foreach ({{{baseType}}} t, {{paramName}}) {
|
||||
if (count > 0) {
|
||||
fullPath.append("\t");
|
||||
}
|
||||
fullPath.append(::{{cppNamespace}}::toStringValue(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (QString("{{collectionFormat}}").indexOf("ssv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("{{baseName}}=");
|
||||
qint32 count = 0;
|
||||
foreach({{{baseType}}} t, {{paramName}}) {
|
||||
if (count > 0) {
|
||||
fullPath.append(" ");
|
||||
}
|
||||
fullPath.append(::{{cppNamespace}}::toStringValue(t));
|
||||
}
|
||||
}
|
||||
else if (QString("{{collectionFormat}}").indexOf("tsv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("{{baseName}}=");
|
||||
qint32 count = 0;
|
||||
foreach({{{baseType}}} t, {{paramName}}) {
|
||||
if (count > 0) {
|
||||
fullPath.append("\t");
|
||||
}
|
||||
fullPath.append(::{{cppNamespace}}::toStringValue(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/collectionFormat}}{{/queryParams}}
|
||||
{{/collectionFormat}}{{/queryParams}}
|
||||
{{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
{{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}");
|
||||
{{#formParams}}{{^isFile}}
|
||||
{{#formParams}}{{^isFile}}
|
||||
input.add_var("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}));{{/isFile}}{{#isFile}}
|
||||
input.add_file("{{baseName}}", {{paramName}}.local_filename, {{paramName}}.request_filename, {{paramName}}.mime_type);{{/isFile}}{{/formParams}}
|
||||
{{#bodyParams}}
|
||||
{{#isContainer}}{{#isListContainer}}
|
||||
input.add_file("{{baseName}}", {{paramName}}.local_filename, {{paramName}}.request_filename, {{paramName}}.mime_type);{{/isFile}}{{/formParams}}{{#bodyParams}}{{#isContainer}}{{#isListContainer}}
|
||||
QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}).toArray());{{/isListContainer}}{{#isMapContainer}}
|
||||
QJsonDocument doc(::{{cppNamespace}}::toJsonValue({{paramName}}).toObject());{{/isMapContainer}}
|
||||
QByteArray bytes = doc.toJson();
|
||||
input.request_body.append(bytes);
|
||||
{{/isContainer}}{{^isContainer}}{{#isString}}
|
||||
{{/isContainer}}{{^isContainer}}{{#isString}}
|
||||
QString output({{paramName}});{{/isString}}{{#isByteArray}}QString output({{paramName}});{{/isByteArray}}{{^isString}}{{^isByteArray}}{{^isFile}}
|
||||
QString output = {{paramName}}.asJson();{{/isFile}}{{/isByteArray}}{{/isString}}{{#isFile}}{{#hasConsumes}}input.headers.insert("Content-Type", {{#consumes}}{{^-first}}, {{/-first}}"{{mediaType}}"{{/consumes}});{{/hasConsumes}}
|
||||
QByteArray output = {{paramName}}.asByteArray();{{/isFile}}
|
||||
input.request_body.append(output);
|
||||
{{/isContainer}}{{/bodyParams}}
|
||||
{{#headerParams}}
|
||||
{{/isContainer}}{{/bodyParams}}{{#headerParams}}
|
||||
if ({{paramName}} != nullptr) {
|
||||
input.headers.insert("{{baseName}}", {{paramName}});
|
||||
}
|
||||
{{/headerParams}}
|
||||
{{/headerParams}}
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
connect(worker,
|
||||
&{{prefix}}HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&{{classname}}::{{nickname}}Callback);
|
||||
connect(worker, &{{prefix}}HttpRequestWorker::on_execution_finished, this, &{{classname}}::{{nickname}}Callback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
{{classname}}::{{nickname}}Callback({{prefix}}HttpRequestWorker * worker) {
|
||||
void {{classname}}::{{nickname}}Callback({{prefix}}HttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
{{#returnType}}
|
||||
{{#isListContainer}}
|
||||
{{{returnType}}} output;
|
||||
QString json(worker->response);
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QByteArray array(json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonArray jsonArray = doc.array();
|
||||
foreach(QJsonValue obj, jsonArray) {
|
||||
foreach (QJsonValue obj, jsonArray) {
|
||||
{{{returnBaseType}}} val;
|
||||
::{{cppNamespace}}::fromJsonValue(val, obj);
|
||||
output.append(val);
|
||||
@@ -184,10 +168,10 @@ void
|
||||
{{#isMapContainer}}
|
||||
{{{returnType}}} output;
|
||||
QString json(worker->response);
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QByteArray array(json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject obj = doc.object();
|
||||
foreach(QString key, obj.keys()) {
|
||||
foreach (QString key, obj.keys()) {
|
||||
{{returnBaseType}} val;
|
||||
::{{cppNamespace}}::fromJsonValue(val, obj[key]);
|
||||
output.insert(key, val);
|
||||
@@ -213,7 +197,6 @@ void
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
@@ -13,23 +13,23 @@
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
class {{classname}}: public QObject {
|
||||
class {{classname}} : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
{{classname}}(const QString &scheme = "{{scheme}}", const QString &host = "{{serverHost}}", int port = {{#serverPort}}{{serverPort}}{{/serverPort}}{{^serverPort}}0{{/serverPort}}, const QString& basePath = "{{basePathWithoutHost}}", const int timeOut = 0);
|
||||
{{classname}}(const QString &scheme = "{{scheme}}", const QString &host = "{{serverHost}}", int port = {{#serverPort}}{{serverPort}}{{/serverPort}}{{^serverPort}}0{{/serverPort}}, const QString &basePath = "{{basePathWithoutHost}}", const int timeOut = 0);
|
||||
~{{classname}}();
|
||||
|
||||
void setScheme(const QString &scheme);
|
||||
void setHost(const QString &host);
|
||||
void setPort(int port);
|
||||
void setBasePath(const QString& basePath);
|
||||
void setBasePath(const QString &basePath);
|
||||
void setTimeOut(const int timeOut);
|
||||
void setWorkingDirectory(const QString& path);
|
||||
void addHeaders(const QString& key, const QString& value);
|
||||
void setWorkingDirectory(const QString &path);
|
||||
void addHeaders(const QString &key, const QString &value);
|
||||
{{#operations}}{{#operation}}
|
||||
void {{nickname}}({{#allParams}}const {{{dataType}}} &{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/operation}}{{/operations}}
|
||||
|
||||
{{#operations}}{{#operation}}void {{nickname}}({{#allParams}}const {{{dataType}}}& {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/operation}}{{/operations}}
|
||||
private:
|
||||
QString _scheme, _host;
|
||||
int _port;
|
||||
@@ -37,20 +37,21 @@ private:
|
||||
int _timeOut;
|
||||
QString _workingDirectory;
|
||||
QMap<QString, QString> defaultHeaders;
|
||||
{{#operations}}{{#operation}}void {{nickname}}Callback ({{prefix}}HttpRequestWorker * worker);
|
||||
{{/operation}}{{/operations}}
|
||||
{{#operations}}{{#operation}}
|
||||
void {{nickname}}Callback({{prefix}}HttpRequestWorker *worker);{{/operation}}{{/operations}}
|
||||
|
||||
signals:
|
||||
{{#operations}}{{#operation}}void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}});
|
||||
{{/operation}}{{/operations}}
|
||||
{{#operations}}{{#operation}}void {{nickname}}SignalFull({{prefix}}HttpRequestWorker* worker{{#returnType}}, {{{returnType}}} summary{{/returnType}});
|
||||
{{/operation}}{{/operations}}
|
||||
{{#operations}}{{#operation}}void {{nickname}}SignalE({{#returnType}}{{{returnType}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, QString error_str);
|
||||
{{/operation}}{{/operations}}
|
||||
{{#operations}}{{#operation}}void {{nickname}}SignalEFull({{prefix}}HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
{{/operation}}{{/operations}}
|
||||
{{#operations}}{{#operation}}
|
||||
void {{nickname}}Signal({{#returnType}}{{{returnType}}} summary{{/returnType}});{{/operation}}{{/operations}}
|
||||
{{#operations}}{{#operation}}
|
||||
void {{nickname}}SignalFull({{prefix}}HttpRequestWorker *worker{{#returnType}}, {{{returnType}}} summary{{/returnType}});{{/operation}}{{/operations}}
|
||||
{{#operations}}{{#operation}}
|
||||
void {{nickname}}SignalE({{#returnType}}{{{returnType}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, QString error_str);{{/operation}}{{/operations}}
|
||||
{{#operations}}{{#operation}}
|
||||
void {{nickname}}SignalEFull({{prefix}}HttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);{{/operation}}{{/operations}}
|
||||
};
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
#endif
|
||||
|
||||
@@ -2,27 +2,23 @@
|
||||
#ifndef {{prefix}}_ENUM_H
|
||||
#define {{prefix}}_ENUM_H
|
||||
|
||||
#include <QString>
|
||||
#include <QJsonValue>
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
class {{prefix}}Enum {
|
||||
public:
|
||||
{{prefix}}Enum() {
|
||||
|
||||
}
|
||||
public:
|
||||
{{prefix}}Enum() {}
|
||||
|
||||
{{prefix}}Enum(QString jsonString) {
|
||||
fromJson(jsonString);
|
||||
}
|
||||
|
||||
virtual ~{{prefix}}Enum(){
|
||||
|
||||
}
|
||||
virtual ~{{prefix}}Enum() {}
|
||||
|
||||
virtual QJsonValue asJsonValue() const {
|
||||
return QJsonValue(jstr);
|
||||
@@ -47,12 +43,13 @@ class {{prefix}}Enum {
|
||||
virtual bool isValid() const {
|
||||
return true;
|
||||
}
|
||||
private :
|
||||
|
||||
private:
|
||||
QString jstr;
|
||||
};
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{prefix}}Enum)
|
||||
|
||||
@@ -1,246 +1,200 @@
|
||||
{{>licenseInfo}}
|
||||
#include <QDebug>
|
||||
#include "{{prefix}}Helpers.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
|
||||
QString
|
||||
toStringValue(const QString &value) {
|
||||
QString toStringValue(const QString &value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const QDateTime &value){
|
||||
QString toStringValue(const QDateTime &value) {
|
||||
// ISO 8601
|
||||
return value.toString("yyyy-MM-ddTHH:mm:ss[Z|[+|-]HH:mm]");
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const QByteArray &value){
|
||||
QString toStringValue(const QByteArray &value) {
|
||||
return QString(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const QDate &value){
|
||||
QString toStringValue(const QDate &value) {
|
||||
// ISO 8601
|
||||
return value.toString(Qt::DateFormat::ISODate);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const qint32 &value) {
|
||||
QString toStringValue(const qint32 &value) {
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const qint64 &value) {
|
||||
QString toStringValue(const qint64 &value) {
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const bool &value) {
|
||||
QString toStringValue(const bool &value) {
|
||||
return QString(value ? "true" : "false");
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const float &value){
|
||||
QString toStringValue(const float &value) {
|
||||
return QString::number(static_cast<double>(value));
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const double &value){
|
||||
QString toStringValue(const double &value) {
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const {{prefix}}Object &value){
|
||||
QString toStringValue(const {{prefix}}Object &value) {
|
||||
return value.asJson();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
toStringValue(const {{prefix}}Enum &value){
|
||||
QString toStringValue(const {{prefix}}Enum &value) {
|
||||
return value.asJson();
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const {{prefix}}HttpFileElement &value){
|
||||
QString toStringValue(const {{prefix}}HttpFileElement &value) {
|
||||
return value.asJson();
|
||||
}
|
||||
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QString &value){
|
||||
return QJsonValue(value);
|
||||
QJsonValue toJsonValue(const QString &value) {
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QDateTime &value){
|
||||
QJsonValue toJsonValue(const QDateTime &value) {
|
||||
return QJsonValue(value.toString(Qt::ISODate));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QByteArray &value){
|
||||
QJsonValue toJsonValue(const QByteArray &value) {
|
||||
return QJsonValue(QString(value.toBase64()));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QDate &value){
|
||||
QJsonValue toJsonValue(const QDate &value) {
|
||||
return QJsonValue(value.toString(Qt::ISODate));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const qint32 &value){
|
||||
QJsonValue toJsonValue(const qint32 &value) {
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const qint64 &value){
|
||||
QJsonValue toJsonValue(const qint64 &value) {
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const bool &value){
|
||||
QJsonValue toJsonValue(const bool &value) {
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const float &value){
|
||||
QJsonValue toJsonValue(const float &value) {
|
||||
return QJsonValue(static_cast<double>(value));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const double &value){
|
||||
QJsonValue toJsonValue(const double &value) {
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const {{prefix}}Object &value){
|
||||
QJsonValue toJsonValue(const {{prefix}}Object &value) {
|
||||
return value.asJsonObject();
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const {{prefix}}Enum &value){
|
||||
QJsonValue toJsonValue(const {{prefix}}Enum &value) {
|
||||
return value.asJsonValue();
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const {{prefix}}HttpFileElement &value){
|
||||
QJsonValue toJsonValue(const {{prefix}}HttpFileElement &value) {
|
||||
return value.asJsonValue();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QString &value){
|
||||
bool fromStringValue(const QString &inStr, QString &value) {
|
||||
value.clear();
|
||||
value.append(inStr);
|
||||
return !inStr.isEmpty();
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QDateTime &value){
|
||||
if(inStr.isEmpty()){
|
||||
bool fromStringValue(const QString &inStr, QDateTime &value) {
|
||||
if (inStr.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
auto dateTime = QDateTime::fromString(inStr, "yyyy-MM-ddTHH:mm:ss[Z|[+|-]HH:mm]");
|
||||
if(dateTime.isValid()){
|
||||
if (dateTime.isValid()) {
|
||||
value.setDate(dateTime.date());
|
||||
value.setTime(dateTime.time());
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
qDebug() << "DateTime is invalid";
|
||||
}
|
||||
return dateTime.isValid();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QByteArray &value){
|
||||
if(inStr.isEmpty()){
|
||||
bool fromStringValue(const QString &inStr, QByteArray &value) {
|
||||
if (inStr.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
value.clear();
|
||||
value.append(inStr.toUtf8());
|
||||
return value.count() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QDate &value){
|
||||
if(inStr.isEmpty()){
|
||||
bool fromStringValue(const QString &inStr, QDate &value) {
|
||||
if (inStr.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
auto date = QDate::fromString(inStr, Qt::DateFormat::ISODate);
|
||||
if(date.isValid()){
|
||||
if (date.isValid()) {
|
||||
value.setDate(date.year(), date.month(), date.day());
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
qDebug() << "Date is invalid";
|
||||
}
|
||||
return date.isValid();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, qint32 &value){
|
||||
bool fromStringValue(const QString &inStr, qint32 &value) {
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toInt(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, qint64 &value){
|
||||
bool fromStringValue(const QString &inStr, qint64 &value) {
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toLongLong(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, bool &value){
|
||||
bool fromStringValue(const QString &inStr, bool &value) {
|
||||
value = QVariant(inStr).toBool();
|
||||
return ((inStr == "true") || (inStr == "false"));
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, float &value){
|
||||
bool fromStringValue(const QString &inStr, float &value) {
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toFloat(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, double &value){
|
||||
bool fromStringValue(const QString &inStr, double &value) {
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toDouble(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, {{prefix}}Enum &value){
|
||||
bool fromStringValue(const QString &inStr, {{prefix}}Enum &value) {
|
||||
value.fromJson(inStr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, {{prefix}}HttpFileElement &value){
|
||||
bool fromStringValue(const QString &inStr, {{prefix}}HttpFileElement &value) {
|
||||
return value.fromStringValue(inStr);
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(QString &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(QString &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull()){
|
||||
if(jval.isString()){
|
||||
if (!jval.isUndefined() && !jval.isNull()) {
|
||||
if (jval.isString()) {
|
||||
value = jval.toString();
|
||||
} else if(jval.isBool()) {
|
||||
value = jval.toBool() ? "true" : "false";
|
||||
} else if(jval.isDouble()){
|
||||
} else if (jval.isBool()) {
|
||||
value = jval.toBool() ? "true" : "false";
|
||||
} else if (jval.isDouble()) {
|
||||
value = QString::number(jval.toDouble());
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -251,10 +205,9 @@ fromJsonValue(QString &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(QDateTime &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(QDateTime &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && jval.isString()){
|
||||
if (!jval.isUndefined() && !jval.isNull() && jval.isString()) {
|
||||
value = QDateTime::fromString(jval.toString(), Qt::ISODate);
|
||||
ok = value.isValid();
|
||||
} else {
|
||||
@@ -263,22 +216,20 @@ fromJsonValue(QDateTime &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(QByteArray &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(QByteArray &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && jval.isString()) {
|
||||
if (!jval.isUndefined() && !jval.isNull() && jval.isString()) {
|
||||
value = QByteArray::fromBase64(QByteArray::fromStdString(jval.toString().toStdString()));
|
||||
ok = value.size() > 0 ;
|
||||
ok = value.size() > 0;
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(QDate &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(QDate &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && jval.isString()){
|
||||
if (!jval.isUndefined() && !jval.isNull() && jval.isString()) {
|
||||
value = QDate::fromString(jval.toString(), Qt::ISODate);
|
||||
ok = value.isValid();
|
||||
} else {
|
||||
@@ -287,10 +238,9 @@ fromJsonValue(QDate &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(qint32 &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(qint32 &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()){
|
||||
if (!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()) {
|
||||
value = jval.toInt();
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -298,10 +248,9 @@ fromJsonValue(qint32 &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(qint64 &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(qint64 &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()){
|
||||
if (!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()) {
|
||||
value = jval.toVariant().toLongLong();
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -309,10 +258,9 @@ fromJsonValue(qint64 &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(bool &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(bool &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isBool()){
|
||||
if (jval.isBool()) {
|
||||
value = jval.toBool();
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -320,10 +268,9 @@ fromJsonValue(bool &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(float &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(float &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isDouble()){
|
||||
if (jval.isDouble()) {
|
||||
value = static_cast<float>(jval.toDouble());
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -331,10 +278,9 @@ fromJsonValue(float &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(double &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(double &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isDouble()){
|
||||
if (jval.isDouble()) {
|
||||
value = jval.toDouble();
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -342,10 +288,9 @@ fromJsonValue(double &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue({{prefix}}Object &value, const QJsonValue &jval){
|
||||
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isObject()){
|
||||
if (jval.isObject()) {
|
||||
value.fromJsonObject(jval.toObject());
|
||||
ok = value.isValid();
|
||||
} else {
|
||||
@@ -354,17 +299,15 @@ fromJsonValue({{prefix}}Object &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval){
|
||||
bool fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval) {
|
||||
value.fromJsonValue(jval);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval){
|
||||
bool fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval) {
|
||||
return value.fromJsonValue(jval);
|
||||
}
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
@@ -2,184 +2,184 @@
|
||||
#ifndef {{prefix}}_HELPERS_H
|
||||
#define {{prefix}}_HELPERS_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonArray>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QDateTime>
|
||||
#include <QByteArray>
|
||||
#include <QDate>
|
||||
#include <QDateTime>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
|
||||
#include "{{prefix}}Object.h"
|
||||
#include "{{prefix}}Enum.h"
|
||||
#include "{{prefix}}HttpFileElement.h"
|
||||
#include "{{prefix}}Object.h"
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
template <typename T> QString
|
||||
toStringValue(const QList<T> &val);
|
||||
template <typename T>
|
||||
QString toStringValue(const QList<T> &val);
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val);
|
||||
template <typename T>
|
||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val);
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QMap<QString, QString> &inStr, QMap<QString, T> &val);
|
||||
template <typename T>
|
||||
bool fromStringValue(const QMap<QString, QString> &inStr, QMap<QString, T> &val);
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QList<T> &val);
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QList<T> &val);
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QMap<QString, T> &val);
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QMap<QString, T> &val);
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval);
|
||||
template <typename T>
|
||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval);
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QMap<QString, T> &val, const QJsonValue &jval);
|
||||
|
||||
QString toStringValue(const QString &value);
|
||||
QString toStringValue(const QDateTime &value);
|
||||
QString toStringValue(const QByteArray &value);
|
||||
QString toStringValue(const QDate &value);
|
||||
QString toStringValue(const qint32 &value);
|
||||
QString toStringValue(const qint64 &value);
|
||||
QString toStringValue(const bool &value);
|
||||
QString toStringValue(const float &value);
|
||||
QString toStringValue(const double &value);
|
||||
QString toStringValue(const {{prefix}}Object &value);
|
||||
QString toStringValue(const {{prefix}}Enum &value);
|
||||
QString toStringValue(const {{prefix}}HttpFileElement &value);
|
||||
template <typename T>
|
||||
bool fromJsonValue(QMap<QString, T> &val, const QJsonValue &jval);
|
||||
|
||||
template <typename T>
|
||||
QString toStringValue(const QList<T> &val) {
|
||||
QString strArray;
|
||||
for(const auto& item : val) {
|
||||
strArray.append(toStringValue(item) + ",");
|
||||
}
|
||||
if(val.count() > 0) {
|
||||
strArray.chop(1);
|
||||
}
|
||||
return strArray;
|
||||
QString toStringValue(const QString &value);
|
||||
QString toStringValue(const QDateTime &value);
|
||||
QString toStringValue(const QByteArray &value);
|
||||
QString toStringValue(const QDate &value);
|
||||
QString toStringValue(const qint32 &value);
|
||||
QString toStringValue(const qint64 &value);
|
||||
QString toStringValue(const bool &value);
|
||||
QString toStringValue(const float &value);
|
||||
QString toStringValue(const double &value);
|
||||
QString toStringValue(const {{prefix}}Object &value);
|
||||
QString toStringValue(const {{prefix}}Enum &value);
|
||||
QString toStringValue(const {{prefix}}HttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
QString toStringValue(const QList<T> &val) {
|
||||
QString strArray;
|
||||
for (const auto &item : val) {
|
||||
strArray.append(toStringValue(item) + ",");
|
||||
}
|
||||
|
||||
QJsonValue toJsonValue(const QString &value);
|
||||
QJsonValue toJsonValue(const QDateTime &value);
|
||||
QJsonValue toJsonValue(const QByteArray &value);
|
||||
QJsonValue toJsonValue(const QDate &value);
|
||||
QJsonValue toJsonValue(const qint32 &value);
|
||||
QJsonValue toJsonValue(const qint64 &value);
|
||||
QJsonValue toJsonValue(const bool &value);
|
||||
QJsonValue toJsonValue(const float &value);
|
||||
QJsonValue toJsonValue(const double &value);
|
||||
QJsonValue toJsonValue(const {{prefix}}Object &value);
|
||||
QJsonValue toJsonValue(const {{prefix}}Enum &value);
|
||||
QJsonValue toJsonValue(const {{prefix}}HttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QList<T> &val) {
|
||||
QJsonArray jArray;
|
||||
for(const auto& item : val) {
|
||||
jArray.append(toJsonValue(item));
|
||||
}
|
||||
return jArray;
|
||||
if (val.count() > 0) {
|
||||
strArray.chop(1);
|
||||
}
|
||||
return strArray;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QMap<QString, T> &val) {
|
||||
QJsonObject jObject;
|
||||
for(const auto& itemkey : val.keys()) {
|
||||
jObject.insert(itemkey, toJsonValue(val.value(itemkey)));
|
||||
}
|
||||
return jObject;
|
||||
QJsonValue toJsonValue(const QString &value);
|
||||
QJsonValue toJsonValue(const QDateTime &value);
|
||||
QJsonValue toJsonValue(const QByteArray &value);
|
||||
QJsonValue toJsonValue(const QDate &value);
|
||||
QJsonValue toJsonValue(const qint32 &value);
|
||||
QJsonValue toJsonValue(const qint64 &value);
|
||||
QJsonValue toJsonValue(const bool &value);
|
||||
QJsonValue toJsonValue(const float &value);
|
||||
QJsonValue toJsonValue(const double &value);
|
||||
QJsonValue toJsonValue(const {{prefix}}Object &value);
|
||||
QJsonValue toJsonValue(const {{prefix}}Enum &value);
|
||||
QJsonValue toJsonValue(const {{prefix}}HttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QList<T> &val) {
|
||||
QJsonArray jArray;
|
||||
for (const auto &item : val) {
|
||||
jArray.append(toJsonValue(item));
|
||||
}
|
||||
return jArray;
|
||||
}
|
||||
|
||||
bool fromStringValue(const QString &inStr, QString &value);
|
||||
bool fromStringValue(const QString &inStr, QDateTime &value);
|
||||
bool fromStringValue(const QString &inStr, QByteArray &value);
|
||||
bool fromStringValue(const QString &inStr, QDate &value);
|
||||
bool fromStringValue(const QString &inStr, qint32 &value);
|
||||
bool fromStringValue(const QString &inStr, qint64 &value);
|
||||
bool fromStringValue(const QString &inStr, bool &value);
|
||||
bool fromStringValue(const QString &inStr, float &value);
|
||||
bool fromStringValue(const QString &inStr, double &value);
|
||||
bool fromStringValue(const QString &inStr, {{prefix}}Object &value);
|
||||
bool fromStringValue(const QString &inStr, {{prefix}}Enum &value);
|
||||
bool fromStringValue(const QString &inStr, {{prefix}}HttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
||||
bool ok = (inStr.count() > 0);
|
||||
for(const auto& item: inStr){
|
||||
T itemVal;
|
||||
ok &= fromStringValue(item, itemVal);
|
||||
val.push_back(itemVal);
|
||||
}
|
||||
return ok;
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QMap<QString, T> &val) {
|
||||
QJsonObject jObject;
|
||||
for (const auto &itemkey : val.keys()) {
|
||||
jObject.insert(itemkey, toJsonValue(val.value(itemkey)));
|
||||
}
|
||||
return jObject;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QMap<QString, QString> &inStr, QMap<QString, T> &val) {
|
||||
bool ok = (inStr.count() > 0);
|
||||
for(const auto& itemkey : inStr.keys()){
|
||||
T itemVal;
|
||||
ok &= fromStringValue(inStr.value(itemkey), itemVal);
|
||||
val.insert(itemkey, itemVal);
|
||||
}
|
||||
return ok;
|
||||
bool fromStringValue(const QString &inStr, QString &value);
|
||||
bool fromStringValue(const QString &inStr, QDateTime &value);
|
||||
bool fromStringValue(const QString &inStr, QByteArray &value);
|
||||
bool fromStringValue(const QString &inStr, QDate &value);
|
||||
bool fromStringValue(const QString &inStr, qint32 &value);
|
||||
bool fromStringValue(const QString &inStr, qint64 &value);
|
||||
bool fromStringValue(const QString &inStr, bool &value);
|
||||
bool fromStringValue(const QString &inStr, float &value);
|
||||
bool fromStringValue(const QString &inStr, double &value);
|
||||
bool fromStringValue(const QString &inStr, {{prefix}}Object &value);
|
||||
bool fromStringValue(const QString &inStr, {{prefix}}Enum &value);
|
||||
bool fromStringValue(const QString &inStr, {{prefix}}HttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
||||
bool ok = (inStr.count() > 0);
|
||||
for (const auto &item : inStr) {
|
||||
T itemVal;
|
||||
ok &= fromStringValue(item, itemVal);
|
||||
val.push_back(itemVal);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool fromJsonValue(QString &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QDateTime &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QByteArray &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QDate &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(qint32 &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(qint64 &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(bool &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(float &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(double &value, const QJsonValue &jval);
|
||||
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval);
|
||||
bool fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval);
|
||||
bool fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval);
|
||||
template <typename T>
|
||||
bool fromStringValue(const QMap<QString, QString> &inStr, QMap<QString, T> &val) {
|
||||
bool ok = (inStr.count() > 0);
|
||||
for (const auto &itemkey : inStr.keys()) {
|
||||
T itemVal;
|
||||
ok &= fromStringValue(inStr.value(itemkey), itemVal);
|
||||
val.insert(itemkey, itemVal);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isArray()){
|
||||
for(const auto jitem : jval.toArray()){
|
||||
T item;
|
||||
ok &= fromJsonValue(item, jitem);
|
||||
val.push_back(item);
|
||||
bool fromJsonValue(QString &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QDateTime &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QByteArray &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QDate &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(qint32 &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(qint64 &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(bool &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(float &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(double &value, const QJsonValue &jval);
|
||||
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval);
|
||||
bool fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval);
|
||||
bool fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval);
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if (jval.isArray()) {
|
||||
for (const auto jitem : jval.toArray()) {
|
||||
T item;
|
||||
ok &= fromJsonValue(item, jitem);
|
||||
val.push_back(item);
|
||||
}
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QMap<QString, T> &val, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if (jval.isObject()) {
|
||||
auto varmap = jval.toObject().toVariantMap();
|
||||
if (varmap.count() > 0) {
|
||||
for (const auto &itemkey : varmap.keys()) {
|
||||
T itemVal;
|
||||
ok &= fromJsonValue(itemVal, QJsonValue::fromVariant(varmap.value(itemkey)));
|
||||
val.insert(itemkey, itemVal);
|
||||
}
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QMap<QString, T> &val, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isObject()){
|
||||
auto varmap = jval.toObject().toVariantMap();
|
||||
if(varmap.count() > 0){
|
||||
for(const auto& itemkey : varmap.keys() ){
|
||||
T itemVal;
|
||||
ok &= fromJsonValue(itemVal, QJsonValue::fromVariant(varmap.value(itemkey)));
|
||||
val.insert(itemkey, itemVal);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
#endif // {{prefix}}_HELPERS_H
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* {{{appDescription}}}
|
||||
*
|
||||
* {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}}
|
||||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||
*
|
||||
*{{#infoEmail}} Contact: {{{infoEmail}}}
|
||||
*{{/infoEmail}}
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
{{>licenseInfo}}
|
||||
{{#models}}{{#model}}
|
||||
{{>licenseInfo}}{{#models}}{{#model}}
|
||||
#include "{{classname}}.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QObject>
|
||||
|
||||
#include "{{prefix}}Helpers.h"
|
||||
|
||||
@@ -22,24 +21,20 @@ namespace {{this}} {
|
||||
this->initializeModel();
|
||||
}
|
||||
|
||||
{{classname}}::~{{classname}}() {
|
||||
{{classname}}::~{{classname}}() {}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
{{classname}}::initializeModel() {
|
||||
{{^isEnum}}{{#vars}}
|
||||
void {{classname}}::initializeModel() {
|
||||
{{^isEnum}}{{#vars}}
|
||||
m_{{name}}_isSet = false;
|
||||
m_{{name}}_isValid = false;
|
||||
{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||
m_{{name}}_isValid = false;{{^-last}}
|
||||
{{/-last}}{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||
m_value_isSet = false;
|
||||
m_value_isValid = false;
|
||||
m_value = e{{classname}}::INVALID_VALUE_OPENAPI_GENERATED;{{/isEnum}}
|
||||
}
|
||||
|
||||
void
|
||||
{{classname}}::fromJson(QString jsonString) {
|
||||
{{^isEnum}}QByteArray array (jsonString.toStdString().c_str());
|
||||
void {{classname}}::fromJson(QString jsonString) {
|
||||
{{^isEnum}}QByteArray array(jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);{{/isEnum}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}
|
||||
@@ -49,9 +44,8 @@ void
|
||||
}{{/enumVars}}{{/allowableValues}}{{/isEnum}}
|
||||
}
|
||||
|
||||
void
|
||||
{{classname}}::fromJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}(QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} json) {
|
||||
{{^isEnum}}{{#vars}}{{^isContainer}}
|
||||
void {{classname}}::fromJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}(QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} json) {
|
||||
{{^isEnum}}{{#vars}}{{^isContainer}}
|
||||
m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);
|
||||
m_{{name}}_isSet = !json[QString("{{baseName}}")].isNull() && m_{{name}}_isValid;{{/isContainer}}{{#isContainer}}{{^items.isContainer}}
|
||||
m_{{name}}_isValid = ::{{cppNamespace}}::fromJsonValue({{name}}, json[QString("{{baseName}}")]);
|
||||
@@ -80,13 +74,12 @@ void
|
||||
{{name}}.insert({{name}}.end(), val, item);
|
||||
}
|
||||
}
|
||||
}{{/isMapContainer}}{{/items.isContainer}}{{/isContainer}}
|
||||
{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||
{{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}fromJson(json.toString());{{/isString}}{{^isString}}m_value = static_cast<e{{classname}}>(json.toInt());{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}{{/isEnum}}
|
||||
}{{/isMapContainer}}{{/items.isContainer}}{{/isContainer}}{{^-last}}
|
||||
{{/-last}}
|
||||
{{/vars}}{{/isEnum}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}{{#-first}}{{#isString}}fromJson(json.toString());{{/isString}}{{^isString}}m_value = static_cast<e{{classname}}>(json.toInt());{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}{{/isEnum}}
|
||||
}
|
||||
|
||||
QString
|
||||
{{classname}}::asJson () const {
|
||||
QString {{classname}}::asJson() const {
|
||||
{{^isEnum}}QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
@@ -105,27 +98,24 @@ QString
|
||||
return val;{{/isEnum}}
|
||||
}
|
||||
|
||||
QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}
|
||||
{{classname}}::asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const {
|
||||
{{^isEnum}}QJsonObject obj;{{#vars}}
|
||||
{{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{
|
||||
QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} {{classname}}::asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const {
|
||||
{{^isEnum}}QJsonObject obj;{{#vars}}{{^isContainer}}{{#complexType}}
|
||||
if ({{name}}.isSet()){{/complexType}}{{^complexType}}
|
||||
if (m_{{name}}_isSet){{/complexType}} {
|
||||
obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));
|
||||
}{{/isContainer}}{{#isContainer}}
|
||||
if({{name}}.size() > 0){
|
||||
if ({{name}}.size() > 0) {
|
||||
{{^items.isContainer}}obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue({{name}}));{{/items.isContainer}}{{#items.isContainer}}
|
||||
obj.insert(QString("{{baseName}}"), toJsonValue({{name}}));{{/items.isContainer}}
|
||||
} {{/isContainer}}{{/vars}}
|
||||
}{{/isContainer}}{{/vars}}
|
||||
return obj;{{/isEnum}}{{#isEnum}}
|
||||
{{#allowableValues}}{{#enumVars}}{{#-first}}{{^isString}}return QJsonValue(static_cast<int>(m_value));{{/isString}}{{#isString}}return QJsonValue(asJson());{{/isString}}{{/-first}}{{/enumVars}}{{/allowableValues}}{{/isEnum}}
|
||||
}
|
||||
|
||||
{{^isEnum}}{{#vars}}
|
||||
{{{dataType}}}
|
||||
{{classname}}::{{getter}}() const {
|
||||
{{^isEnum}}{{#vars}}{{{dataType}}} {{classname}}::{{getter}}() const {
|
||||
return {{name}};
|
||||
}
|
||||
void
|
||||
{{classname}}::{{setter}}(const {{{dataType}}} &{{name}}) {
|
||||
void {{classname}}::{{setter}}(const {{{dataType}}} &{{name}}) {
|
||||
this->{{name}} = {{name}};
|
||||
this->m_{{name}}_isSet = true;
|
||||
}
|
||||
@@ -140,25 +130,27 @@ void {{classname}}::setValue(const {{classname}}::e{{classname}}& value){
|
||||
m_value_isSet = true;
|
||||
}
|
||||
{{/isEnum}}
|
||||
bool
|
||||
{{classname}}::isSet() const {
|
||||
bool {{classname}}::isSet() const {
|
||||
{{^isEnum}}bool isObjectUpdated = false;
|
||||
do{ {{#vars}}
|
||||
{{#isContainer}}if({{name}}.size() > 0){{/isContainer}}{{^isContainer}}{{#complexType}}if({{name}}.isSet()){{/complexType}}{{^complexType}}if(m_{{name}}_isSet){{/complexType}}{{/isContainer}}{ isObjectUpdated = true; break;}
|
||||
{{/vars}}}while(false);
|
||||
do {
|
||||
{{#vars}} {{#isContainer}}if ({{name}}.size() > 0){{/isContainer}}{{^isContainer}}{{#complexType}}if ({{name}}.isSet()){{/complexType}}{{^complexType}}if (m_{{name}}_isSet){{/complexType}}{{/isContainer}} {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}{{^-last}}
|
||||
|
||||
{{/-last}}{{/vars}}
|
||||
} while (false);
|
||||
return isObjectUpdated;{{/isEnum}}{{#isEnum}}
|
||||
return m_value_isSet;{{/isEnum}}
|
||||
}
|
||||
|
||||
bool
|
||||
{{classname}}::isValid() const {
|
||||
bool {{classname}}::isValid() const {
|
||||
// only required properties are required for the object to be considered valid
|
||||
return {{^isEnum}}{{#vars}}{{#required}}m_{{name}}_isValid && {{/required}}{{/vars}}true{{/isEnum}}{{#isEnum}}m_value_isValid{{/isEnum}};
|
||||
}
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
||||
@@ -10,13 +10,11 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
{{/model}}{{/models}}
|
||||
{{#imports}}{{{import}}}
|
||||
{{/model}}{{/models}}{{#imports}}{{{import}}}
|
||||
{{/imports}}
|
||||
|
||||
#include "{{prefix}}Object.h"
|
||||
#include "{{prefix}}Enum.h"
|
||||
|
||||
#include "{{prefix}}Object.h"
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
@@ -24,22 +22,21 @@
|
||||
namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
class {{classname}}: public {{prefix}}{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Enum{{/isEnum}} {
|
||||
class {{classname}} : public {{prefix}}{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Enum{{/isEnum}} {
|
||||
public:
|
||||
{{classname}}();
|
||||
{{classname}}(QString json);
|
||||
~{{classname}}() override;
|
||||
|
||||
QString asJson () const override;
|
||||
QString asJson() const override;
|
||||
QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const override;
|
||||
void fromJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}(QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
{{^isEnum}}{{#vars}}
|
||||
{{^isEnum}}{{#vars}}
|
||||
{{{dataType}}} {{getter}}() const;
|
||||
void {{setter}}(const {{{dataType}}} &{{name}});
|
||||
|
||||
{{/vars}}{{/isEnum}}{{#isEnum}}{{#allowableValues}}
|
||||
{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||
{{#allowableValues}}
|
||||
enum class e{{classname}} {{#enumVars}}{{#-first}}{{^isString}}: int {{/isString}}{{/-first}}{{/enumVars}}{
|
||||
INVALID_VALUE_OPENAPI_GENERATED = 0,
|
||||
{{#enumVars}}
|
||||
@@ -51,28 +48,25 @@ public:
|
||||
{{{name}}}{{^-last}}, {{/-last}}
|
||||
{{/enumVars}}
|
||||
};{{/allowableValues}}
|
||||
|
||||
{{classname}}::e{{classname}} getValue() const;
|
||||
void setValue(const {{classname}}::e{{classname}}& value);{{/isEnum}}
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
private:
|
||||
void initializeModel();
|
||||
{{^isEnum}}{{#vars}}
|
||||
{{^isEnum}}{{#vars}}
|
||||
{{{dataType}}} {{name}};
|
||||
bool m_{{name}}_isSet;
|
||||
bool m_{{name}}_isValid;
|
||||
{{/vars}}{{/isEnum}}
|
||||
{{#isEnum}}e{{classname}} m_value;
|
||||
{{/vars}}{{/isEnum}}{{#isEnum}}
|
||||
e{{classname}} m_value;
|
||||
bool m_value_isSet;
|
||||
bool m_value_isValid;
|
||||
{{/isEnum}}
|
||||
};
|
||||
{{/isEnum}}};
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{classname}})
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#ifndef {{prefix}}_OBJECT_H
|
||||
#define {{prefix}}_OBJECT_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QMetaType>
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
@@ -11,18 +11,14 @@ namespace {{this}} {
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
class {{prefix}}Object {
|
||||
public:
|
||||
{{prefix}}Object() {
|
||||
|
||||
}
|
||||
public:
|
||||
{{prefix}}Object() {}
|
||||
|
||||
{{prefix}}Object(QString jsonString) {
|
||||
fromJson(jsonString);
|
||||
}
|
||||
|
||||
virtual ~{{prefix}}Object(){
|
||||
|
||||
}
|
||||
virtual ~{{prefix}}Object() {}
|
||||
|
||||
virtual QJsonObject asJsonObject() const {
|
||||
return jObj;
|
||||
@@ -49,12 +45,13 @@ class {{prefix}}Object {
|
||||
virtual bool isValid() const {
|
||||
return true;
|
||||
}
|
||||
private :
|
||||
|
||||
private:
|
||||
QJsonObject jObj;
|
||||
};
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
}
|
||||
} // namespace {{this}}
|
||||
{{/cppNamespaceDeclarations}}
|
||||
|
||||
Q_DECLARE_METATYPE({{#cppNamespaceDeclarations}}{{this}}::{{/cppNamespaceDeclarations}}{{prefix}}Object)
|
||||
|
||||
7
samples/client/petstore/cpp-qt5/.clang-format
Normal file
7
samples/client/petstore/cpp-qt5/.clang-format
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
ColumnLimit: 0
|
||||
IndentWidth: 4
|
||||
@@ -19,7 +19,7 @@ void PetApiTests::findPetsByStatusTest() {
|
||||
|
||||
connect(&api, &PFXPetApi::findPetsByStatusSignal, [&](QList<PFXPet> pets) {
|
||||
petFound = true;
|
||||
foreach(PFXPet pet, pets) {
|
||||
foreach (PFXPet pet, pets) {
|
||||
QVERIFY(pet.getStatus().startsWith("available") || pet.getStatus().startsWith("sold"));
|
||||
}
|
||||
loop.quit();
|
||||
@@ -74,7 +74,7 @@ void PetApiTests::updatePetTest() {
|
||||
QEventLoop loop;
|
||||
bool petAdded = false;
|
||||
|
||||
connect(&api, &PFXPetApi::addPetSignal, [&](){
|
||||
connect(&api, &PFXPetApi::addPetSignal, [&]() {
|
||||
petAdded = true;
|
||||
loop.quit();
|
||||
});
|
||||
@@ -89,9 +89,9 @@ void PetApiTests::updatePetTest() {
|
||||
|
||||
bool petFetched = false;
|
||||
connect(&api, &PFXPetApi::getPetByIdSignal, this, [&](PFXPet pet) {
|
||||
petFetched = true;
|
||||
petToCheck = pet;
|
||||
loop.quit();
|
||||
petFetched = true;
|
||||
petToCheck = pet;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
// create pet
|
||||
@@ -138,7 +138,7 @@ void PetApiTests::updatePetWithFormTest() {
|
||||
|
||||
// create pet
|
||||
bool petAdded = false;
|
||||
connect(&api, &PFXPetApi::addPetSignal, [&](){
|
||||
connect(&api, &PFXPetApi::addPetSignal, [&]() {
|
||||
petAdded = true;
|
||||
loop.quit();
|
||||
});
|
||||
@@ -163,7 +163,7 @@ void PetApiTests::updatePetWithFormTest() {
|
||||
|
||||
// update it
|
||||
bool petUpdated = false;
|
||||
connect(&api, &PFXPetApi::updatePetWithFormSignal, [&](){
|
||||
connect(&api, &PFXPetApi::updatePetWithFormSignal, [&]() {
|
||||
petUpdated = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
using namespace test_namespace;
|
||||
|
||||
class PetApiTests: public QObject {
|
||||
class PetApiTests : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
PFXPet createRandomPet();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "StoreApiTests.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTest>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
void StoreApiTests::placeOrderTest() {
|
||||
PFXStoreApi api;
|
||||
@@ -16,7 +16,7 @@ void StoreApiTests::placeOrderTest() {
|
||||
qDebug() << order.getShipDate();
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXStoreApi::placeOrderSignalE, [&](){
|
||||
connect(&api, &PFXStoreApi::placeOrderSignalE, [&]() {
|
||||
QFAIL("shouldn't trigger error");
|
||||
loop.quit();
|
||||
});
|
||||
@@ -60,7 +60,7 @@ void StoreApiTests::getInventoryTest() {
|
||||
|
||||
connect(&api, &PFXStoreApi::getInventorySignal, [&](QMap<QString, qint32> status) {
|
||||
inventoryFetched = true;
|
||||
for(const auto& key : status.keys()) {
|
||||
for (const auto &key : status.keys()) {
|
||||
qDebug() << (key) << " Quantities " << status.value(key);
|
||||
}
|
||||
loop.quit();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
using namespace test_namespace;
|
||||
|
||||
class StoreApiTests: public QObject {
|
||||
class StoreApiTests : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "UserApiTests.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTest>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
PFXUser UserApiTests::createRandomUser() {
|
||||
PFXUser user;
|
||||
@@ -17,14 +17,14 @@ PFXUser UserApiTests::createRandomUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
void UserApiTests::createUserTest(){
|
||||
void UserApiTests::createUserTest() {
|
||||
PFXUserApi api;
|
||||
QEventLoop loop;
|
||||
bool userCreated = false;
|
||||
|
||||
connect(&api, &PFXUserApi::createUserSignal, [&](){
|
||||
userCreated = true;
|
||||
loop.quit();
|
||||
connect(&api, &PFXUserApi::createUserSignal, [&]() {
|
||||
userCreated = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
api.createUser(createRandomUser());
|
||||
@@ -33,14 +33,14 @@ void UserApiTests::createUserTest(){
|
||||
QVERIFY2(userCreated, "didn't finish within timeout");
|
||||
}
|
||||
|
||||
void UserApiTests::createUsersWithArrayInputTest(){
|
||||
void UserApiTests::createUsersWithArrayInputTest() {
|
||||
PFXUserApi api;
|
||||
QEventLoop loop;
|
||||
bool usersCreated = false;
|
||||
|
||||
connect(&api, &PFXUserApi::createUsersWithArrayInputSignal, [&](){
|
||||
usersCreated = true;
|
||||
loop.quit();
|
||||
connect(&api, &PFXUserApi::createUsersWithArrayInputSignal, [&]() {
|
||||
usersCreated = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QList<PFXUser> users;
|
||||
@@ -53,14 +53,14 @@ void UserApiTests::createUsersWithArrayInputTest(){
|
||||
QVERIFY2(usersCreated, "didn't finish within timeout");
|
||||
}
|
||||
|
||||
void UserApiTests::createUsersWithListInputTest(){
|
||||
void UserApiTests::createUsersWithListInputTest() {
|
||||
PFXUserApi api;
|
||||
QEventLoop loop;
|
||||
bool usersCreated = false;
|
||||
|
||||
connect(&api, &PFXUserApi::createUsersWithListInputSignal, [&](){
|
||||
usersCreated = true;
|
||||
loop.quit();
|
||||
connect(&api, &PFXUserApi::createUsersWithListInputSignal, [&]() {
|
||||
usersCreated = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QList<PFXUser> users;
|
||||
@@ -77,14 +77,14 @@ void UserApiTests::createUsersWithListInputTest(){
|
||||
QVERIFY2(usersCreated, "didn't finish within timeout");
|
||||
}
|
||||
|
||||
void UserApiTests::deleteUserTest(){
|
||||
void UserApiTests::deleteUserTest() {
|
||||
PFXUserApi api;
|
||||
QEventLoop loop;
|
||||
bool userDeleted = false;
|
||||
|
||||
connect(&api, &PFXUserApi::deleteUserSignal, [&](){
|
||||
userDeleted = true;
|
||||
loop.quit();
|
||||
connect(&api, &PFXUserApi::deleteUserSignal, [&]() {
|
||||
userDeleted = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
api.deleteUser("rambo");
|
||||
@@ -93,7 +93,7 @@ void UserApiTests::deleteUserTest(){
|
||||
QVERIFY2(userDeleted, "didn't finish within timeout");
|
||||
}
|
||||
|
||||
void UserApiTests::getUserByNameTest(){
|
||||
void UserApiTests::getUserByNameTest() {
|
||||
PFXUserApi api;
|
||||
QEventLoop loop;
|
||||
bool userFetched = false;
|
||||
@@ -111,7 +111,7 @@ void UserApiTests::getUserByNameTest(){
|
||||
QVERIFY2(userFetched, "didn't finish within timeout");
|
||||
}
|
||||
|
||||
void UserApiTests::loginUserTest(){
|
||||
void UserApiTests::loginUserTest() {
|
||||
PFXUserApi api;
|
||||
QEventLoop loop;
|
||||
bool userLogged = false;
|
||||
@@ -128,12 +128,12 @@ void UserApiTests::loginUserTest(){
|
||||
QVERIFY2(userLogged, "didn't finish within timeout");
|
||||
}
|
||||
|
||||
void UserApiTests::logoutUserTest(){
|
||||
void UserApiTests::logoutUserTest() {
|
||||
PFXUserApi api;
|
||||
QEventLoop loop;
|
||||
bool userLoggedOut = false;
|
||||
|
||||
connect(&api, &PFXUserApi::logoutUserSignal, [&](){
|
||||
connect(&api, &PFXUserApi::logoutUserSignal, [&]() {
|
||||
userLoggedOut = true;
|
||||
loop.quit();
|
||||
});
|
||||
@@ -144,14 +144,14 @@ void UserApiTests::logoutUserTest(){
|
||||
QVERIFY2(userLoggedOut, "didn't finish within timeout");
|
||||
}
|
||||
|
||||
void UserApiTests::updateUserTest(){
|
||||
void UserApiTests::updateUserTest() {
|
||||
PFXUserApi api;
|
||||
QEventLoop loop;
|
||||
bool userUpdated = false;
|
||||
|
||||
connect(&api, &PFXUserApi::updateUserSignal, [&]() {
|
||||
userUpdated = true;
|
||||
loop.quit();
|
||||
userUpdated = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
auto johndoe = createRandomUser();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
using namespace test_namespace;
|
||||
|
||||
class UserApiTests: public QObject {
|
||||
class UserApiTests : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
PFXUser createRandomUser();
|
||||
|
||||
@@ -3,20 +3,18 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include "PFXApiResponse.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QObject>
|
||||
|
||||
#include "PFXHelpers.h"
|
||||
|
||||
@@ -31,120 +29,108 @@ PFXApiResponse::PFXApiResponse() {
|
||||
this->initializeModel();
|
||||
}
|
||||
|
||||
PFXApiResponse::~PFXApiResponse() {
|
||||
PFXApiResponse::~PFXApiResponse() {}
|
||||
|
||||
}
|
||||
void PFXApiResponse::initializeModel() {
|
||||
|
||||
void
|
||||
PFXApiResponse::initializeModel() {
|
||||
|
||||
m_code_isSet = false;
|
||||
m_code_isValid = false;
|
||||
|
||||
|
||||
m_type_isSet = false;
|
||||
m_type_isValid = false;
|
||||
|
||||
|
||||
m_message_isSet = false;
|
||||
m_message_isValid = false;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PFXApiResponse::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
void PFXApiResponse::fromJson(QString jsonString) {
|
||||
QByteArray array(jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
PFXApiResponse::fromJsonObject(QJsonObject json) {
|
||||
|
||||
void PFXApiResponse::fromJsonObject(QJsonObject json) {
|
||||
|
||||
m_code_isValid = ::test_namespace::fromJsonValue(code, json[QString("code")]);
|
||||
m_code_isSet = !json[QString("code")].isNull() && m_code_isValid;
|
||||
|
||||
|
||||
m_type_isValid = ::test_namespace::fromJsonValue(type, json[QString("type")]);
|
||||
m_type_isSet = !json[QString("type")].isNull() && m_type_isValid;
|
||||
|
||||
|
||||
m_message_isValid = ::test_namespace::fromJsonValue(message, json[QString("message")]);
|
||||
m_message_isSet = !json[QString("message")].isNull() && m_message_isValid;
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
PFXApiResponse::asJson () const {
|
||||
QString PFXApiResponse::asJson() const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
PFXApiResponse::asJsonObject() const {
|
||||
QJsonObject PFXApiResponse::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_code_isSet){
|
||||
if (m_code_isSet) {
|
||||
obj.insert(QString("code"), ::test_namespace::toJsonValue(code));
|
||||
}
|
||||
if(m_type_isSet){
|
||||
if (m_type_isSet) {
|
||||
obj.insert(QString("type"), ::test_namespace::toJsonValue(type));
|
||||
}
|
||||
if(m_message_isSet){
|
||||
if (m_message_isSet) {
|
||||
obj.insert(QString("message"), ::test_namespace::toJsonValue(message));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
qint32
|
||||
PFXApiResponse::getCode() const {
|
||||
qint32 PFXApiResponse::getCode() const {
|
||||
return code;
|
||||
}
|
||||
void
|
||||
PFXApiResponse::setCode(const qint32 &code) {
|
||||
void PFXApiResponse::setCode(const qint32 &code) {
|
||||
this->code = code;
|
||||
this->m_code_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXApiResponse::getType() const {
|
||||
QString PFXApiResponse::getType() const {
|
||||
return type;
|
||||
}
|
||||
void
|
||||
PFXApiResponse::setType(const QString &type) {
|
||||
void PFXApiResponse::setType(const QString &type) {
|
||||
this->type = type;
|
||||
this->m_type_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXApiResponse::getMessage() const {
|
||||
QString PFXApiResponse::getMessage() const {
|
||||
return message;
|
||||
}
|
||||
void
|
||||
PFXApiResponse::setMessage(const QString &message) {
|
||||
void PFXApiResponse::setMessage(const QString &message) {
|
||||
this->message = message;
|
||||
this->m_message_isSet = true;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXApiResponse::isSet() const {
|
||||
bool PFXApiResponse::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_code_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_type_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_message_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
do {
|
||||
if (m_code_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_type_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_message_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
} while (false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXApiResponse::isValid() const {
|
||||
bool PFXApiResponse::isValid() const {
|
||||
// only required properties are required for the object to be considered valid
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -21,61 +20,53 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "PFXObject.h"
|
||||
#include "PFXEnum.h"
|
||||
|
||||
#include "PFXObject.h"
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXApiResponse: public PFXObject {
|
||||
class PFXApiResponse : public PFXObject {
|
||||
public:
|
||||
PFXApiResponse();
|
||||
PFXApiResponse(QString json);
|
||||
~PFXApiResponse() override;
|
||||
|
||||
QString asJson () const override;
|
||||
QString asJson() const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
|
||||
qint32 getCode() const;
|
||||
void setCode(const qint32 &code);
|
||||
|
||||
|
||||
QString getType() const;
|
||||
void setType(const QString &type);
|
||||
|
||||
|
||||
QString getMessage() const;
|
||||
void setMessage(const QString &message);
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
private:
|
||||
void initializeModel();
|
||||
|
||||
|
||||
qint32 code;
|
||||
bool m_code_isSet;
|
||||
bool m_code_isValid;
|
||||
|
||||
|
||||
QString type;
|
||||
bool m_type_isSet;
|
||||
bool m_type_isValid;
|
||||
|
||||
|
||||
QString message;
|
||||
bool m_message_isSet;
|
||||
bool m_message_isValid;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
Q_DECLARE_METATYPE(test_namespace::PFXApiResponse)
|
||||
|
||||
|
||||
@@ -3,20 +3,18 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include "PFXCategory.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QObject>
|
||||
|
||||
#include "PFXHelpers.h"
|
||||
|
||||
@@ -31,98 +29,86 @@ PFXCategory::PFXCategory() {
|
||||
this->initializeModel();
|
||||
}
|
||||
|
||||
PFXCategory::~PFXCategory() {
|
||||
PFXCategory::~PFXCategory() {}
|
||||
|
||||
}
|
||||
void PFXCategory::initializeModel() {
|
||||
|
||||
void
|
||||
PFXCategory::initializeModel() {
|
||||
|
||||
m_id_isSet = false;
|
||||
m_id_isValid = false;
|
||||
|
||||
|
||||
m_name_isSet = false;
|
||||
m_name_isValid = false;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PFXCategory::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
void PFXCategory::fromJson(QString jsonString) {
|
||||
QByteArray array(jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
PFXCategory::fromJsonObject(QJsonObject json) {
|
||||
|
||||
void PFXCategory::fromJsonObject(QJsonObject json) {
|
||||
|
||||
m_id_isValid = ::test_namespace::fromJsonValue(id, json[QString("id")]);
|
||||
m_id_isSet = !json[QString("id")].isNull() && m_id_isValid;
|
||||
|
||||
|
||||
m_name_isValid = ::test_namespace::fromJsonValue(name, json[QString("name")]);
|
||||
m_name_isSet = !json[QString("name")].isNull() && m_name_isValid;
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
PFXCategory::asJson () const {
|
||||
QString PFXCategory::asJson() const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
PFXCategory::asJsonObject() const {
|
||||
QJsonObject PFXCategory::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
if (m_id_isSet) {
|
||||
obj.insert(QString("id"), ::test_namespace::toJsonValue(id));
|
||||
}
|
||||
if(m_name_isSet){
|
||||
if (m_name_isSet) {
|
||||
obj.insert(QString("name"), ::test_namespace::toJsonValue(name));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
PFXCategory::getId() const {
|
||||
qint64 PFXCategory::getId() const {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
PFXCategory::setId(const qint64 &id) {
|
||||
void PFXCategory::setId(const qint64 &id) {
|
||||
this->id = id;
|
||||
this->m_id_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXCategory::getName() const {
|
||||
QString PFXCategory::getName() const {
|
||||
return name;
|
||||
}
|
||||
void
|
||||
PFXCategory::setName(const QString &name) {
|
||||
void PFXCategory::setName(const QString &name) {
|
||||
this->name = name;
|
||||
this->m_name_isSet = true;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXCategory::isSet() const {
|
||||
bool PFXCategory::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_id_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_name_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
do {
|
||||
if (m_id_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_name_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
} while (false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXCategory::isValid() const {
|
||||
bool PFXCategory::isValid() const {
|
||||
// only required properties are required for the object to be considered valid
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -21,53 +20,46 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "PFXObject.h"
|
||||
#include "PFXEnum.h"
|
||||
|
||||
#include "PFXObject.h"
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXCategory: public PFXObject {
|
||||
class PFXCategory : public PFXObject {
|
||||
public:
|
||||
PFXCategory();
|
||||
PFXCategory(QString json);
|
||||
~PFXCategory() override;
|
||||
|
||||
QString asJson () const override;
|
||||
QString asJson() const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
|
||||
qint64 getId() const;
|
||||
void setId(const qint64 &id);
|
||||
|
||||
|
||||
QString getName() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
private:
|
||||
void initializeModel();
|
||||
|
||||
|
||||
qint64 id;
|
||||
bool m_id_isSet;
|
||||
bool m_id_isValid;
|
||||
|
||||
|
||||
QString name;
|
||||
bool m_name_isSet;
|
||||
bool m_name_isValid;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
Q_DECLARE_METATYPE(test_namespace::PFXCategory)
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -13,25 +12,21 @@
|
||||
#ifndef PFX_ENUM_H
|
||||
#define PFX_ENUM_H
|
||||
|
||||
#include <QString>
|
||||
#include <QJsonValue>
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXEnum {
|
||||
public:
|
||||
PFXEnum() {
|
||||
|
||||
}
|
||||
public:
|
||||
PFXEnum() {}
|
||||
|
||||
PFXEnum(QString jsonString) {
|
||||
fromJson(jsonString);
|
||||
}
|
||||
|
||||
virtual ~PFXEnum(){
|
||||
|
||||
}
|
||||
virtual ~PFXEnum() {}
|
||||
|
||||
virtual QJsonValue asJsonValue() const {
|
||||
return QJsonValue(jstr);
|
||||
@@ -56,11 +51,12 @@ class PFXEnum {
|
||||
virtual bool isValid() const {
|
||||
return true;
|
||||
}
|
||||
private :
|
||||
|
||||
private:
|
||||
QString jstr;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
Q_DECLARE_METATYPE(test_namespace::PFXEnum)
|
||||
|
||||
|
||||
@@ -3,253 +3,206 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include "PFXHelpers.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
|
||||
QString
|
||||
toStringValue(const QString &value) {
|
||||
QString toStringValue(const QString &value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const QDateTime &value){
|
||||
QString toStringValue(const QDateTime &value) {
|
||||
// ISO 8601
|
||||
return value.toString("yyyy-MM-ddTHH:mm:ss[Z|[+|-]HH:mm]");
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const QByteArray &value){
|
||||
QString toStringValue(const QByteArray &value) {
|
||||
return QString(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const QDate &value){
|
||||
QString toStringValue(const QDate &value) {
|
||||
// ISO 8601
|
||||
return value.toString(Qt::DateFormat::ISODate);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const qint32 &value) {
|
||||
QString toStringValue(const qint32 &value) {
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const qint64 &value) {
|
||||
QString toStringValue(const qint64 &value) {
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const bool &value) {
|
||||
QString toStringValue(const bool &value) {
|
||||
return QString(value ? "true" : "false");
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const float &value){
|
||||
QString toStringValue(const float &value) {
|
||||
return QString::number(static_cast<double>(value));
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const double &value){
|
||||
QString toStringValue(const double &value) {
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const PFXObject &value){
|
||||
QString toStringValue(const PFXObject &value) {
|
||||
return value.asJson();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
toStringValue(const PFXEnum &value){
|
||||
QString toStringValue(const PFXEnum &value) {
|
||||
return value.asJson();
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const PFXHttpFileElement &value){
|
||||
QString toStringValue(const PFXHttpFileElement &value) {
|
||||
return value.asJson();
|
||||
}
|
||||
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QString &value){
|
||||
return QJsonValue(value);
|
||||
QJsonValue toJsonValue(const QString &value) {
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QDateTime &value){
|
||||
QJsonValue toJsonValue(const QDateTime &value) {
|
||||
return QJsonValue(value.toString(Qt::ISODate));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QByteArray &value){
|
||||
QJsonValue toJsonValue(const QByteArray &value) {
|
||||
return QJsonValue(QString(value.toBase64()));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QDate &value){
|
||||
QJsonValue toJsonValue(const QDate &value) {
|
||||
return QJsonValue(value.toString(Qt::ISODate));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const qint32 &value){
|
||||
QJsonValue toJsonValue(const qint32 &value) {
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const qint64 &value){
|
||||
QJsonValue toJsonValue(const qint64 &value) {
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const bool &value){
|
||||
QJsonValue toJsonValue(const bool &value) {
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const float &value){
|
||||
QJsonValue toJsonValue(const float &value) {
|
||||
return QJsonValue(static_cast<double>(value));
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const double &value){
|
||||
QJsonValue toJsonValue(const double &value) {
|
||||
return QJsonValue(value);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const PFXObject &value){
|
||||
QJsonValue toJsonValue(const PFXObject &value) {
|
||||
return value.asJsonObject();
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const PFXEnum &value){
|
||||
QJsonValue toJsonValue(const PFXEnum &value) {
|
||||
return value.asJsonValue();
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const PFXHttpFileElement &value){
|
||||
QJsonValue toJsonValue(const PFXHttpFileElement &value) {
|
||||
return value.asJsonValue();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QString &value){
|
||||
bool fromStringValue(const QString &inStr, QString &value) {
|
||||
value.clear();
|
||||
value.append(inStr);
|
||||
return !inStr.isEmpty();
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QDateTime &value){
|
||||
if(inStr.isEmpty()){
|
||||
bool fromStringValue(const QString &inStr, QDateTime &value) {
|
||||
if (inStr.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
auto dateTime = QDateTime::fromString(inStr, "yyyy-MM-ddTHH:mm:ss[Z|[+|-]HH:mm]");
|
||||
if(dateTime.isValid()){
|
||||
if (dateTime.isValid()) {
|
||||
value.setDate(dateTime.date());
|
||||
value.setTime(dateTime.time());
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
qDebug() << "DateTime is invalid";
|
||||
}
|
||||
return dateTime.isValid();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QByteArray &value){
|
||||
if(inStr.isEmpty()){
|
||||
bool fromStringValue(const QString &inStr, QByteArray &value) {
|
||||
if (inStr.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
value.clear();
|
||||
value.append(inStr.toUtf8());
|
||||
return value.count() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QDate &value){
|
||||
if(inStr.isEmpty()){
|
||||
bool fromStringValue(const QString &inStr, QDate &value) {
|
||||
if (inStr.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
auto date = QDate::fromString(inStr, Qt::DateFormat::ISODate);
|
||||
if(date.isValid()){
|
||||
if (date.isValid()) {
|
||||
value.setDate(date.year(), date.month(), date.day());
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
qDebug() << "Date is invalid";
|
||||
}
|
||||
return date.isValid();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, qint32 &value){
|
||||
bool fromStringValue(const QString &inStr, qint32 &value) {
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toInt(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, qint64 &value){
|
||||
bool fromStringValue(const QString &inStr, qint64 &value) {
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toLongLong(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, bool &value){
|
||||
bool fromStringValue(const QString &inStr, bool &value) {
|
||||
value = QVariant(inStr).toBool();
|
||||
return ((inStr == "true") || (inStr == "false"));
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, float &value){
|
||||
bool fromStringValue(const QString &inStr, float &value) {
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toFloat(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, double &value){
|
||||
bool fromStringValue(const QString &inStr, double &value) {
|
||||
bool ok = false;
|
||||
value = QVariant(inStr).toDouble(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, PFXEnum &value){
|
||||
bool fromStringValue(const QString &inStr, PFXEnum &value) {
|
||||
value.fromJson(inStr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, PFXHttpFileElement &value){
|
||||
bool fromStringValue(const QString &inStr, PFXHttpFileElement &value) {
|
||||
return value.fromStringValue(inStr);
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(QString &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(QString &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull()){
|
||||
if(jval.isString()){
|
||||
if (!jval.isUndefined() && !jval.isNull()) {
|
||||
if (jval.isString()) {
|
||||
value = jval.toString();
|
||||
} else if(jval.isBool()) {
|
||||
value = jval.toBool() ? "true" : "false";
|
||||
} else if(jval.isDouble()){
|
||||
} else if (jval.isBool()) {
|
||||
value = jval.toBool() ? "true" : "false";
|
||||
} else if (jval.isDouble()) {
|
||||
value = QString::number(jval.toDouble());
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -260,10 +213,9 @@ fromJsonValue(QString &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(QDateTime &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(QDateTime &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && jval.isString()){
|
||||
if (!jval.isUndefined() && !jval.isNull() && jval.isString()) {
|
||||
value = QDateTime::fromString(jval.toString(), Qt::ISODate);
|
||||
ok = value.isValid();
|
||||
} else {
|
||||
@@ -272,22 +224,20 @@ fromJsonValue(QDateTime &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(QByteArray &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(QByteArray &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && jval.isString()) {
|
||||
if (!jval.isUndefined() && !jval.isNull() && jval.isString()) {
|
||||
value = QByteArray::fromBase64(QByteArray::fromStdString(jval.toString().toStdString()));
|
||||
ok = value.size() > 0 ;
|
||||
ok = value.size() > 0;
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(QDate &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(QDate &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && jval.isString()){
|
||||
if (!jval.isUndefined() && !jval.isNull() && jval.isString()) {
|
||||
value = QDate::fromString(jval.toString(), Qt::ISODate);
|
||||
ok = value.isValid();
|
||||
} else {
|
||||
@@ -296,10 +246,9 @@ fromJsonValue(QDate &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(qint32 &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(qint32 &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()){
|
||||
if (!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()) {
|
||||
value = jval.toInt();
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -307,10 +256,9 @@ fromJsonValue(qint32 &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(qint64 &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(qint64 &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()){
|
||||
if (!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()) {
|
||||
value = jval.toVariant().toLongLong();
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -318,10 +266,9 @@ fromJsonValue(qint64 &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(bool &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(bool &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isBool()){
|
||||
if (jval.isBool()) {
|
||||
value = jval.toBool();
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -329,10 +276,9 @@ fromJsonValue(bool &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(float &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(float &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isDouble()){
|
||||
if (jval.isDouble()) {
|
||||
value = static_cast<float>(jval.toDouble());
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -340,10 +286,9 @@ fromJsonValue(float &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(double &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(double &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isDouble()){
|
||||
if (jval.isDouble()) {
|
||||
value = jval.toDouble();
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -351,10 +296,9 @@ fromJsonValue(double &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(PFXObject &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(PFXObject &value, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isObject()){
|
||||
if (jval.isObject()) {
|
||||
value.fromJsonObject(jval.toObject());
|
||||
ok = value.isValid();
|
||||
} else {
|
||||
@@ -363,15 +307,13 @@ fromJsonValue(PFXObject &value, const QJsonValue &jval){
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(PFXEnum &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(PFXEnum &value, const QJsonValue &jval) {
|
||||
value.fromJsonValue(jval);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(PFXHttpFileElement &value, const QJsonValue &jval){
|
||||
bool fromJsonValue(PFXHttpFileElement &value, const QJsonValue &jval) {
|
||||
return value.fromJsonValue(jval);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -13,180 +12,180 @@
|
||||
#ifndef PFX_HELPERS_H
|
||||
#define PFX_HELPERS_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonArray>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QDateTime>
|
||||
#include <QByteArray>
|
||||
#include <QDate>
|
||||
#include <QDateTime>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
|
||||
#include "PFXObject.h"
|
||||
#include "PFXEnum.h"
|
||||
#include "PFXHttpFileElement.h"
|
||||
#include "PFXObject.h"
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
template <typename T> QString
|
||||
toStringValue(const QList<T> &val);
|
||||
template <typename T>
|
||||
QString toStringValue(const QList<T> &val);
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val);
|
||||
template <typename T>
|
||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val);
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QMap<QString, QString> &inStr, QMap<QString, T> &val);
|
||||
template <typename T>
|
||||
bool fromStringValue(const QMap<QString, QString> &inStr, QMap<QString, T> &val);
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QList<T> &val);
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QList<T> &val);
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QMap<QString, T> &val);
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QMap<QString, T> &val);
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval);
|
||||
template <typename T>
|
||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval);
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QMap<QString, T> &val, const QJsonValue &jval);
|
||||
|
||||
QString toStringValue(const QString &value);
|
||||
QString toStringValue(const QDateTime &value);
|
||||
QString toStringValue(const QByteArray &value);
|
||||
QString toStringValue(const QDate &value);
|
||||
QString toStringValue(const qint32 &value);
|
||||
QString toStringValue(const qint64 &value);
|
||||
QString toStringValue(const bool &value);
|
||||
QString toStringValue(const float &value);
|
||||
QString toStringValue(const double &value);
|
||||
QString toStringValue(const PFXObject &value);
|
||||
QString toStringValue(const PFXEnum &value);
|
||||
QString toStringValue(const PFXHttpFileElement &value);
|
||||
template <typename T>
|
||||
bool fromJsonValue(QMap<QString, T> &val, const QJsonValue &jval);
|
||||
|
||||
template <typename T>
|
||||
QString toStringValue(const QList<T> &val) {
|
||||
QString strArray;
|
||||
for(const auto& item : val) {
|
||||
strArray.append(toStringValue(item) + ",");
|
||||
}
|
||||
if(val.count() > 0) {
|
||||
strArray.chop(1);
|
||||
}
|
||||
return strArray;
|
||||
QString toStringValue(const QString &value);
|
||||
QString toStringValue(const QDateTime &value);
|
||||
QString toStringValue(const QByteArray &value);
|
||||
QString toStringValue(const QDate &value);
|
||||
QString toStringValue(const qint32 &value);
|
||||
QString toStringValue(const qint64 &value);
|
||||
QString toStringValue(const bool &value);
|
||||
QString toStringValue(const float &value);
|
||||
QString toStringValue(const double &value);
|
||||
QString toStringValue(const PFXObject &value);
|
||||
QString toStringValue(const PFXEnum &value);
|
||||
QString toStringValue(const PFXHttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
QString toStringValue(const QList<T> &val) {
|
||||
QString strArray;
|
||||
for (const auto &item : val) {
|
||||
strArray.append(toStringValue(item) + ",");
|
||||
}
|
||||
|
||||
QJsonValue toJsonValue(const QString &value);
|
||||
QJsonValue toJsonValue(const QDateTime &value);
|
||||
QJsonValue toJsonValue(const QByteArray &value);
|
||||
QJsonValue toJsonValue(const QDate &value);
|
||||
QJsonValue toJsonValue(const qint32 &value);
|
||||
QJsonValue toJsonValue(const qint64 &value);
|
||||
QJsonValue toJsonValue(const bool &value);
|
||||
QJsonValue toJsonValue(const float &value);
|
||||
QJsonValue toJsonValue(const double &value);
|
||||
QJsonValue toJsonValue(const PFXObject &value);
|
||||
QJsonValue toJsonValue(const PFXEnum &value);
|
||||
QJsonValue toJsonValue(const PFXHttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QList<T> &val) {
|
||||
QJsonArray jArray;
|
||||
for(const auto& item : val) {
|
||||
jArray.append(toJsonValue(item));
|
||||
}
|
||||
return jArray;
|
||||
if (val.count() > 0) {
|
||||
strArray.chop(1);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QMap<QString, T> &val) {
|
||||
QJsonObject jObject;
|
||||
for(const auto& itemkey : val.keys()) {
|
||||
jObject.insert(itemkey, toJsonValue(val.value(itemkey)));
|
||||
}
|
||||
return jObject;
|
||||
}
|
||||
|
||||
bool fromStringValue(const QString &inStr, QString &value);
|
||||
bool fromStringValue(const QString &inStr, QDateTime &value);
|
||||
bool fromStringValue(const QString &inStr, QByteArray &value);
|
||||
bool fromStringValue(const QString &inStr, QDate &value);
|
||||
bool fromStringValue(const QString &inStr, qint32 &value);
|
||||
bool fromStringValue(const QString &inStr, qint64 &value);
|
||||
bool fromStringValue(const QString &inStr, bool &value);
|
||||
bool fromStringValue(const QString &inStr, float &value);
|
||||
bool fromStringValue(const QString &inStr, double &value);
|
||||
bool fromStringValue(const QString &inStr, PFXObject &value);
|
||||
bool fromStringValue(const QString &inStr, PFXEnum &value);
|
||||
bool fromStringValue(const QString &inStr, PFXHttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
||||
bool ok = (inStr.count() > 0);
|
||||
for(const auto& item: inStr){
|
||||
T itemVal;
|
||||
ok &= fromStringValue(item, itemVal);
|
||||
val.push_back(itemVal);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QMap<QString, QString> &inStr, QMap<QString, T> &val) {
|
||||
bool ok = (inStr.count() > 0);
|
||||
for(const auto& itemkey : inStr.keys()){
|
||||
T itemVal;
|
||||
ok &= fromStringValue(inStr.value(itemkey), itemVal);
|
||||
val.insert(itemkey, itemVal);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool fromJsonValue(QString &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QDateTime &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QByteArray &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QDate &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(qint32 &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(qint64 &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(bool &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(float &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(double &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(PFXObject &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(PFXEnum &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(PFXHttpFileElement &value, const QJsonValue &jval);
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isArray()){
|
||||
for(const auto jitem : jval.toArray()){
|
||||
T item;
|
||||
ok &= fromJsonValue(item, jitem);
|
||||
val.push_back(item);
|
||||
}
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QMap<QString, T> &val, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if(jval.isObject()){
|
||||
auto varmap = jval.toObject().toVariantMap();
|
||||
if(varmap.count() > 0){
|
||||
for(const auto& itemkey : varmap.keys() ){
|
||||
T itemVal;
|
||||
ok &= fromJsonValue(itemVal, QJsonValue::fromVariant(varmap.value(itemkey)));
|
||||
val.insert(itemkey, itemVal);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
return strArray;
|
||||
}
|
||||
|
||||
QJsonValue toJsonValue(const QString &value);
|
||||
QJsonValue toJsonValue(const QDateTime &value);
|
||||
QJsonValue toJsonValue(const QByteArray &value);
|
||||
QJsonValue toJsonValue(const QDate &value);
|
||||
QJsonValue toJsonValue(const qint32 &value);
|
||||
QJsonValue toJsonValue(const qint64 &value);
|
||||
QJsonValue toJsonValue(const bool &value);
|
||||
QJsonValue toJsonValue(const float &value);
|
||||
QJsonValue toJsonValue(const double &value);
|
||||
QJsonValue toJsonValue(const PFXObject &value);
|
||||
QJsonValue toJsonValue(const PFXEnum &value);
|
||||
QJsonValue toJsonValue(const PFXHttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QList<T> &val) {
|
||||
QJsonArray jArray;
|
||||
for (const auto &item : val) {
|
||||
jArray.append(toJsonValue(item));
|
||||
}
|
||||
return jArray;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QMap<QString, T> &val) {
|
||||
QJsonObject jObject;
|
||||
for (const auto &itemkey : val.keys()) {
|
||||
jObject.insert(itemkey, toJsonValue(val.value(itemkey)));
|
||||
}
|
||||
return jObject;
|
||||
}
|
||||
|
||||
bool fromStringValue(const QString &inStr, QString &value);
|
||||
bool fromStringValue(const QString &inStr, QDateTime &value);
|
||||
bool fromStringValue(const QString &inStr, QByteArray &value);
|
||||
bool fromStringValue(const QString &inStr, QDate &value);
|
||||
bool fromStringValue(const QString &inStr, qint32 &value);
|
||||
bool fromStringValue(const QString &inStr, qint64 &value);
|
||||
bool fromStringValue(const QString &inStr, bool &value);
|
||||
bool fromStringValue(const QString &inStr, float &value);
|
||||
bool fromStringValue(const QString &inStr, double &value);
|
||||
bool fromStringValue(const QString &inStr, PFXObject &value);
|
||||
bool fromStringValue(const QString &inStr, PFXEnum &value);
|
||||
bool fromStringValue(const QString &inStr, PFXHttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
||||
bool ok = (inStr.count() > 0);
|
||||
for (const auto &item : inStr) {
|
||||
T itemVal;
|
||||
ok &= fromStringValue(item, itemVal);
|
||||
val.push_back(itemVal);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QMap<QString, QString> &inStr, QMap<QString, T> &val) {
|
||||
bool ok = (inStr.count() > 0);
|
||||
for (const auto &itemkey : inStr.keys()) {
|
||||
T itemVal;
|
||||
ok &= fromStringValue(inStr.value(itemkey), itemVal);
|
||||
val.insert(itemkey, itemVal);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool fromJsonValue(QString &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QDateTime &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QByteArray &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(QDate &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(qint32 &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(qint64 &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(bool &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(float &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(double &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(PFXObject &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(PFXEnum &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(PFXHttpFileElement &value, const QJsonValue &jval);
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if (jval.isArray()) {
|
||||
for (const auto jitem : jval.toArray()) {
|
||||
T item;
|
||||
ok &= fromJsonValue(item, jitem);
|
||||
val.push_back(item);
|
||||
}
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QMap<QString, T> &val, const QJsonValue &jval) {
|
||||
bool ok = true;
|
||||
if (jval.isObject()) {
|
||||
auto varmap = jval.toObject().toVariantMap();
|
||||
if (varmap.count() > 0) {
|
||||
for (const auto &itemkey : varmap.keys()) {
|
||||
T itemVal;
|
||||
ok &= fromJsonValue(itemVal, QJsonValue::fromVariant(varmap.value(itemkey)));
|
||||
val.insert(itemkey, itemVal);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
} // namespace test_namespace
|
||||
|
||||
#endif // PFX_HELPERS_H
|
||||
|
||||
@@ -3,14 +3,12 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
@@ -20,129 +18,117 @@
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
void
|
||||
PFXHttpFileElement::setMimeType(const QString &mime){
|
||||
void PFXHttpFileElement::setMimeType(const QString &mime) {
|
||||
mime_type = mime;
|
||||
}
|
||||
|
||||
void
|
||||
PFXHttpFileElement::setFileName(const QString &name){
|
||||
void PFXHttpFileElement::setFileName(const QString &name) {
|
||||
local_filename = name;
|
||||
}
|
||||
|
||||
void
|
||||
PFXHttpFileElement::setVariableName(const QString &name){
|
||||
void PFXHttpFileElement::setVariableName(const QString &name) {
|
||||
variable_name = name;
|
||||
}
|
||||
|
||||
void
|
||||
PFXHttpFileElement::setRequestFileName(const QString &name){
|
||||
void PFXHttpFileElement::setRequestFileName(const QString &name) {
|
||||
request_filename = name;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXHttpFileElement::isSet() const {
|
||||
bool PFXHttpFileElement::isSet() const {
|
||||
return !local_filename.isEmpty() || !request_filename.isEmpty();
|
||||
}
|
||||
|
||||
QString
|
||||
PFXHttpFileElement::asJson() const{
|
||||
QString PFXHttpFileElement::asJson() const {
|
||||
QFile file(local_filename);
|
||||
QByteArray bArray;
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
if (file.exists()) {
|
||||
result = file.open(QIODevice::ReadOnly);
|
||||
bArray = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error opening file " << local_filename;
|
||||
}
|
||||
return QString(bArray);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
PFXHttpFileElement::asJsonValue() const{
|
||||
QJsonValue PFXHttpFileElement::asJsonValue() const {
|
||||
QFile file(local_filename);
|
||||
QByteArray bArray;
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
bool result = false;
|
||||
if (file.exists()) {
|
||||
result = file.open(QIODevice::ReadOnly);
|
||||
bArray = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error opening file " << local_filename;
|
||||
}
|
||||
return QJsonDocument::fromBinaryData(bArray.data()).object();
|
||||
}
|
||||
|
||||
bool
|
||||
PFXHttpFileElement::fromStringValue(const QString &instr){
|
||||
bool PFXHttpFileElement::fromStringValue(const QString &instr) {
|
||||
QFile file(local_filename);
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
if (file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
result = file.open(QIODevice::WriteOnly);
|
||||
file.write(instr.toUtf8());
|
||||
file.close();
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error creating file " << local_filename;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXHttpFileElement::fromJsonValue(const QJsonValue &jval) {
|
||||
bool PFXHttpFileElement::fromJsonValue(const QJsonValue &jval) {
|
||||
QFile file(local_filename);
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
if (file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
result = file.open(QIODevice::WriteOnly);
|
||||
file.write(QJsonDocument(jval.toObject()).toBinaryData());
|
||||
file.close();
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error creating file " << local_filename;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QByteArray
|
||||
PFXHttpFileElement::asByteArray() const {
|
||||
QByteArray PFXHttpFileElement::asByteArray() const {
|
||||
QFile file(local_filename);
|
||||
QByteArray bArray;
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
if (file.exists()) {
|
||||
result = file.open(QIODevice::ReadOnly);
|
||||
bArray = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error opening file " << local_filename;
|
||||
}
|
||||
}
|
||||
return bArray;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXHttpFileElement::fromByteArray(const QByteArray& bytes){
|
||||
bool PFXHttpFileElement::fromByteArray(const QByteArray &bytes) {
|
||||
QFile file(local_filename);
|
||||
bool result = false;
|
||||
if(file.exists()){
|
||||
if (file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
result = file.open(QIODevice::WriteOnly);
|
||||
file.write(bytes);
|
||||
file.close();
|
||||
if(!result) {
|
||||
if (!result) {
|
||||
qDebug() << "Error creating file " << local_filename;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXHttpFileElement::saveToFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime, const QByteArray& bytes){
|
||||
bool PFXHttpFileElement::saveToFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime, const QByteArray &bytes) {
|
||||
setMimeType(mime);
|
||||
setFileName(localFName);
|
||||
setVariableName(varName);
|
||||
@@ -150,8 +136,7 @@ PFXHttpFileElement::saveToFile(const QString &varName, const QString &localFName
|
||||
return fromByteArray(bytes);
|
||||
}
|
||||
|
||||
QByteArray
|
||||
PFXHttpFileElement::loadFromFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime){
|
||||
QByteArray PFXHttpFileElement::loadFromFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime) {
|
||||
setMimeType(mime);
|
||||
setFileName(localFName);
|
||||
setVariableName(varName);
|
||||
@@ -159,4 +144,4 @@ PFXHttpFileElement::loadFromFile(const QString &varName, const QString &localFNa
|
||||
return asByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -17,7 +16,6 @@
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXHttpFileElement {
|
||||
@@ -34,15 +32,15 @@ public:
|
||||
bool isSet() const;
|
||||
bool fromStringValue(const QString &instr);
|
||||
bool fromJsonValue(const QJsonValue &jval);
|
||||
bool fromByteArray(const QByteArray& bytes);
|
||||
bool saveToFile(const QString &variable_name, const QString &local_filename, const QString &request_filename, const QString &mime, const QByteArray& bytes);
|
||||
bool fromByteArray(const QByteArray &bytes);
|
||||
bool saveToFile(const QString &variable_name, const QString &local_filename, const QString &request_filename, const QString &mime, const QByteArray &bytes);
|
||||
QString asJson() const;
|
||||
QJsonValue asJsonValue() const;
|
||||
QByteArray asByteArray() const;
|
||||
QByteArray loadFromFile(const QString &variable_name, const QString &local_filename, const QString &request_filename, const QString &mime);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
Q_DECLARE_METATYPE(test_namespace::PFXHttpFileElement)
|
||||
|
||||
|
||||
@@ -3,27 +3,23 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QUuid>
|
||||
#include <QUrl>
|
||||
#include <QFileInfo>
|
||||
#include <QBuffer>
|
||||
#include <QtGlobal>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <QUuid>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "PFXHttpRequest.h"
|
||||
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
PFXHttpRequestInput::PFXHttpRequestInput() {
|
||||
@@ -55,61 +51,58 @@ void PFXHttpRequestInput::add_file(QString variable_name, QString local_filename
|
||||
files.append(file);
|
||||
}
|
||||
|
||||
|
||||
PFXHttpRequestWorker::PFXHttpRequestWorker(QObject *parent)
|
||||
: QObject(parent), manager(nullptr), _timeOut(0)
|
||||
{
|
||||
: QObject(parent), manager(nullptr), _timeOut(0) {
|
||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||
manager = new QNetworkAccessManager(this);
|
||||
workingDirectory = QDir::currentPath();
|
||||
workingDirectory = QDir::currentPath();
|
||||
connect(manager, &QNetworkAccessManager::finished, this, &PFXHttpRequestWorker::on_manager_finished);
|
||||
}
|
||||
|
||||
PFXHttpRequestWorker::~PFXHttpRequestWorker() {
|
||||
for (const auto & item: multiPartFields) {
|
||||
if(item != nullptr) {
|
||||
for (const auto &item : multiPartFields) {
|
||||
if (item != nullptr) {
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMap<QString, QString> PFXHttpRequestWorker::getResponseHeaders() const {
|
||||
return headers;
|
||||
}
|
||||
|
||||
PFXHttpFileElement PFXHttpRequestWorker::getHttpFileElement(const QString &fieldname){
|
||||
if(!files.isEmpty()){
|
||||
if(fieldname.isEmpty()){
|
||||
PFXHttpFileElement PFXHttpRequestWorker::getHttpFileElement(const QString &fieldname) {
|
||||
if (!files.isEmpty()) {
|
||||
if (fieldname.isEmpty()) {
|
||||
return files.first();
|
||||
}else if (files.contains(fieldname)){
|
||||
} else if (files.contains(fieldname)) {
|
||||
return files[fieldname];
|
||||
}
|
||||
}
|
||||
return PFXHttpFileElement();
|
||||
}
|
||||
|
||||
QByteArray *PFXHttpRequestWorker::getMultiPartField(const QString &fieldname){
|
||||
if(!multiPartFields.isEmpty()){
|
||||
if(fieldname.isEmpty()){
|
||||
QByteArray *PFXHttpRequestWorker::getMultiPartField(const QString &fieldname) {
|
||||
if (!multiPartFields.isEmpty()) {
|
||||
if (fieldname.isEmpty()) {
|
||||
return multiPartFields.first();
|
||||
}else if (multiPartFields.contains(fieldname)){
|
||||
} else if (multiPartFields.contains(fieldname)) {
|
||||
return multiPartFields[fieldname];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PFXHttpRequestWorker::setTimeOut(int timeOut){
|
||||
void PFXHttpRequestWorker::setTimeOut(int timeOut) {
|
||||
_timeOut = timeOut;
|
||||
}
|
||||
|
||||
void PFXHttpRequestWorker::setWorkingDirectory(const QString &path){
|
||||
if(!path.isEmpty()){
|
||||
void PFXHttpRequestWorker::setWorkingDirectory(const QString &path) {
|
||||
if (!path.isEmpty()) {
|
||||
workingDirectory = path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString PFXHttpRequestWorker::http_attribute_encode(QString attribute_name, QString input) {
|
||||
// result structure follows RFC 5987
|
||||
bool need_utf_encoding = false;
|
||||
@@ -121,11 +114,9 @@ QString PFXHttpRequestWorker::http_attribute_encode(QString attribute_name, QStr
|
||||
if (c == '\\' || c == '/' || c == '\0' || c < ' ' || c > '~') {
|
||||
// ignore and request utf-8 version
|
||||
need_utf_encoding = true;
|
||||
}
|
||||
else if (c == '"') {
|
||||
} else if (c == '"') {
|
||||
result += "\\\"";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result += c;
|
||||
}
|
||||
}
|
||||
@@ -142,14 +133,9 @@ QString PFXHttpRequestWorker::http_attribute_encode(QString attribute_name, QStr
|
||||
QString result_utf8 = "";
|
||||
for (int i = 0; i < input_c.length(); i++) {
|
||||
c = input_c.at(i);
|
||||
if (
|
||||
(c >= '0' && c <= '9')
|
||||
|| (c >= 'A' && c <= 'Z')
|
||||
|| (c >= 'a' && c <= 'z')
|
||||
) {
|
||||
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
|
||||
result_utf8 += c;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result_utf8 += "%" + QString::number(static_cast<unsigned char>(input_c.at(i)), 16).toUpper();
|
||||
}
|
||||
}
|
||||
@@ -161,14 +147,13 @@ QString PFXHttpRequestWorker::http_attribute_encode(QString attribute_name, QStr
|
||||
void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
|
||||
|
||||
// reset variables
|
||||
QNetworkReply* reply = nullptr;
|
||||
QNetworkReply *reply = nullptr;
|
||||
QByteArray request_content = "";
|
||||
response = "";
|
||||
error_type = QNetworkReply::NoError;
|
||||
error_str = "";
|
||||
bool isFormData = false;
|
||||
|
||||
|
||||
// decide on the variable layout
|
||||
|
||||
if (input->files.length() > 0) {
|
||||
@@ -178,7 +163,6 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
|
||||
input->var_layout = input->http_method == "GET" || input->http_method == "HEAD" ? ADDRESS : URL_ENCODED;
|
||||
}
|
||||
|
||||
|
||||
// prepare request content
|
||||
|
||||
QString boundary = "";
|
||||
@@ -205,13 +189,12 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
|
||||
request_content = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// variable layout is MULTIPART
|
||||
|
||||
boundary = "__-----------------------"
|
||||
+ QString::number(QDateTime::currentDateTime().toTime_t())
|
||||
+ QString::number(qrand());
|
||||
boundary = QString("__-----------------------%1%2")
|
||||
.arg(QDateTime::currentDateTime().toTime_t())
|
||||
.arg(qrand());
|
||||
QString boundary_delimiter = "--";
|
||||
QString new_line = "\r\n";
|
||||
|
||||
@@ -242,11 +225,13 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
|
||||
QFileInfo fi(file_info->local_filename);
|
||||
|
||||
// ensure necessary variables are available
|
||||
if (
|
||||
file_info->local_filename == nullptr || file_info->local_filename.isEmpty()
|
||||
|| file_info->variable_name == nullptr || file_info->variable_name.isEmpty()
|
||||
|| !fi.exists() || !fi.isFile() || !fi.isReadable()
|
||||
) {
|
||||
if (file_info->local_filename == nullptr
|
||||
|| file_info->local_filename.isEmpty()
|
||||
|| file_info->variable_name == nullptr
|
||||
|| file_info->variable_name.isEmpty()
|
||||
|| !fi.exists()
|
||||
|| !fi.isFile()
|
||||
|| !fi.isReadable()) {
|
||||
// silent abort for the current file
|
||||
continue;
|
||||
}
|
||||
@@ -271,10 +256,8 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
|
||||
request_content.append(new_line);
|
||||
|
||||
// add header
|
||||
request_content.append(QString("Content-Disposition: form-data; %1; %2").arg(
|
||||
http_attribute_encode("name", file_info->variable_name),
|
||||
http_attribute_encode("filename", file_info->request_filename)
|
||||
));
|
||||
request_content.append(
|
||||
QString("Content-Disposition: form-data; %1; %2").arg(http_attribute_encode("name", file_info->variable_name), http_attribute_encode("filename", file_info->request_filename)));
|
||||
request_content.append(new_line);
|
||||
|
||||
if (file_info->mime_type != nullptr && !file_info->mime_type.isEmpty()) {
|
||||
@@ -302,7 +285,7 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
|
||||
request_content.append(boundary_delimiter);
|
||||
}
|
||||
|
||||
if(input->request_body.size() > 0) {
|
||||
if (input->request_body.size() > 0) {
|
||||
qDebug() << "got a request body";
|
||||
request_content.clear();
|
||||
request_content.append(input->request_body);
|
||||
@@ -314,41 +297,31 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
|
||||
request.setSslConfiguration(*PFXHttpRequestWorker::sslDefaultConfiguration);
|
||||
}
|
||||
request.setRawHeader("User-Agent", "OpenAPI-Generator/1.0.0/cpp-qt5");
|
||||
foreach(QString key, input->headers.keys()) {
|
||||
request.setRawHeader(key.toStdString().c_str(), input->headers.value(key).toStdString().c_str());
|
||||
}
|
||||
foreach (QString key, input->headers.keys()) { request.setRawHeader(key.toStdString().c_str(), input->headers.value(key).toStdString().c_str()); }
|
||||
|
||||
if (request_content.size() > 0 && !isFormData && (input->var_layout != MULTIPART)) {
|
||||
if(!input->headers.contains("Content-Type")){
|
||||
if (!input->headers.contains("Content-Type")) {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, input->headers.value("Content-Type"));
|
||||
}
|
||||
}
|
||||
else if (input->var_layout == URL_ENCODED) {
|
||||
} else if (input->var_layout == URL_ENCODED) {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
}
|
||||
else if (input->var_layout == MULTIPART) {
|
||||
} else if (input->var_layout == MULTIPART) {
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=" + boundary);
|
||||
}
|
||||
|
||||
if (input->http_method == "GET") {
|
||||
reply = manager->get(request);
|
||||
}
|
||||
else if (input->http_method == "POST") {
|
||||
} else if (input->http_method == "POST") {
|
||||
reply = manager->post(request, request_content);
|
||||
}
|
||||
else if (input->http_method == "PUT") {
|
||||
} else if (input->http_method == "PUT") {
|
||||
reply = manager->put(request, request_content);
|
||||
}
|
||||
else if (input->http_method == "HEAD") {
|
||||
} else if (input->http_method == "HEAD") {
|
||||
reply = manager->head(request);
|
||||
}
|
||||
else if (input->http_method == "DELETE") {
|
||||
} else if (input->http_method == "DELETE") {
|
||||
reply = manager->deleteResource(request);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
#if (QT_VERSION >= 0x050800)
|
||||
manager->sendCustomRequest(request, input->http_method.toLatin1(), request_content);
|
||||
#else
|
||||
@@ -360,8 +333,8 @@ void PFXHttpRequestWorker::execute(PFXHttpRequestInput *input) {
|
||||
buffer->setParent(reply);
|
||||
#endif
|
||||
}
|
||||
if(_timeOut > 0){
|
||||
QTimer::singleShot(_timeOut, [=](){ on_manager_timeout(reply); });
|
||||
if (_timeOut > 0) {
|
||||
QTimer::singleShot(_timeOut, [=]() { on_manager_timeout(reply); });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,8 +342,8 @@ void PFXHttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
|
||||
error_type = reply->error();
|
||||
response = reply->readAll();
|
||||
error_str = reply->errorString();
|
||||
if(reply->rawHeaderPairs().count() > 0){
|
||||
for(const auto& item: reply->rawHeaderPairs()){
|
||||
if (reply->rawHeaderPairs().count() > 0) {
|
||||
for (const auto &item : reply->rawHeaderPairs()) {
|
||||
headers.insert(item.first, item.second);
|
||||
}
|
||||
}
|
||||
@@ -390,34 +363,31 @@ void PFXHttpRequestWorker::on_manager_timeout(QNetworkReply *reply) {
|
||||
}
|
||||
|
||||
void PFXHttpRequestWorker::process_form_response() {
|
||||
if(getResponseHeaders().contains(QString("Content-Disposition")) ) {
|
||||
if (getResponseHeaders().contains(QString("Content-Disposition"))) {
|
||||
auto contentDisposition = getResponseHeaders().value(QString("Content-Disposition").toUtf8()).split(QString(";"), QString::SkipEmptyParts);
|
||||
auto contentType = getResponseHeaders().contains(QString("Content-Type")) ? getResponseHeaders().value(QString("Content-Type").toUtf8()).split(QString(";"), QString::SkipEmptyParts).first() : QString();
|
||||
if((contentDisposition.count() > 0) && (contentDisposition.first() == QString("attachment"))){
|
||||
auto contentType =
|
||||
getResponseHeaders().contains(QString("Content-Type")) ? getResponseHeaders().value(QString("Content-Type").toUtf8()).split(QString(";"), QString::SkipEmptyParts).first() : QString();
|
||||
if ((contentDisposition.count() > 0) && (contentDisposition.first() == QString("attachment"))) {
|
||||
QString filename = QUuid::createUuid().toString();
|
||||
for(const auto &file : contentDisposition){
|
||||
if(file.contains(QString("filename"))){
|
||||
for (const auto &file : contentDisposition) {
|
||||
if (file.contains(QString("filename"))) {
|
||||
filename = file.split(QString("="), QString::SkipEmptyParts).at(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
PFXHttpFileElement felement;
|
||||
felement.saveToFile(QString(), workingDirectory + QDir::separator() + filename, filename, contentType, response.data());
|
||||
files.insert(filename, felement);
|
||||
files.insert(filename, felement);
|
||||
}
|
||||
|
||||
} else if(getResponseHeaders().contains(QString("Content-Type")) ) {
|
||||
} else if (getResponseHeaders().contains(QString("Content-Type"))) {
|
||||
auto contentType = getResponseHeaders().value(QString("Content-Type").toUtf8()).split(QString(";"), QString::SkipEmptyParts);
|
||||
if((contentType.count() > 0) && (contentType.first() == QString("multipart/form-data"))){
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if ((contentType.count() > 0) && (contentType.first() == QString("multipart/form-data"))) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QSslConfiguration* PFXHttpRequestWorker::sslDefaultConfiguration;
|
||||
QSslConfiguration *PFXHttpRequestWorker::sslDefaultConfiguration;
|
||||
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -19,18 +18,22 @@
|
||||
#ifndef PFX_HTTPREQUESTWORKER_H
|
||||
#define PFX_HTTPREQUESTWORKER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "PFXHttpFileElement.h"
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
enum PFXHttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART};
|
||||
|
||||
enum PFXHttpRequestVarLayout {
|
||||
NOT_SET,
|
||||
ADDRESS,
|
||||
URL_ENCODED,
|
||||
MULTIPART
|
||||
};
|
||||
|
||||
class PFXHttpRequestInput {
|
||||
|
||||
@@ -48,10 +51,8 @@ public:
|
||||
void initialize();
|
||||
void add_var(QString key, QString value);
|
||||
void add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PFXHttpRequestWorker : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -65,11 +66,11 @@ public:
|
||||
QMap<QString, QString> getResponseHeaders() const;
|
||||
QString http_attribute_encode(QString attribute_name, QString input);
|
||||
void execute(PFXHttpRequestInput *input);
|
||||
static QSslConfiguration* sslDefaultConfiguration;
|
||||
static QSslConfiguration *sslDefaultConfiguration;
|
||||
void setTimeOut(int tout);
|
||||
void setWorkingDirectory(const QString &path);
|
||||
PFXHttpFileElement getHttpFileElement(const QString &fieldname = QString());
|
||||
QByteArray* getMultiPartField(const QString &fieldname = QString());
|
||||
QByteArray *getMultiPartField(const QString &fieldname = QString());
|
||||
signals:
|
||||
void on_execution_finished(PFXHttpRequestWorker *worker);
|
||||
|
||||
@@ -77,15 +78,15 @@ private:
|
||||
QNetworkAccessManager *manager;
|
||||
QMap<QString, QString> headers;
|
||||
QMap<QString, PFXHttpFileElement> files;
|
||||
QMap<QString, QByteArray*> multiPartFields;
|
||||
QMap<QString, QByteArray *> multiPartFields;
|
||||
QString workingDirectory;
|
||||
int _timeOut;
|
||||
void on_manager_timeout(QNetworkReply *reply);
|
||||
void process_form_response();
|
||||
void process_form_response();
|
||||
private slots:
|
||||
void on_manager_finished(QNetworkReply *reply);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
#endif // PFX_HTTPREQUESTWORKER_H
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -13,25 +12,21 @@
|
||||
#ifndef PFX_OBJECT_H
|
||||
#define PFX_OBJECT_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QMetaType>
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXObject {
|
||||
public:
|
||||
PFXObject() {
|
||||
|
||||
}
|
||||
public:
|
||||
PFXObject() {}
|
||||
|
||||
PFXObject(QString jsonString) {
|
||||
fromJson(jsonString);
|
||||
}
|
||||
|
||||
virtual ~PFXObject(){
|
||||
|
||||
}
|
||||
virtual ~PFXObject() {}
|
||||
|
||||
virtual QJsonObject asJsonObject() const {
|
||||
return jObj;
|
||||
@@ -58,11 +53,12 @@ class PFXObject {
|
||||
virtual bool isValid() const {
|
||||
return true;
|
||||
}
|
||||
private :
|
||||
|
||||
private:
|
||||
QJsonObject jObj;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
Q_DECLARE_METATYPE(test_namespace::PFXObject)
|
||||
|
||||
|
||||
@@ -3,20 +3,18 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include "PFXOrder.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QObject>
|
||||
|
||||
#include "PFXHelpers.h"
|
||||
|
||||
@@ -31,186 +29,174 @@ PFXOrder::PFXOrder() {
|
||||
this->initializeModel();
|
||||
}
|
||||
|
||||
PFXOrder::~PFXOrder() {
|
||||
PFXOrder::~PFXOrder() {}
|
||||
|
||||
}
|
||||
void PFXOrder::initializeModel() {
|
||||
|
||||
void
|
||||
PFXOrder::initializeModel() {
|
||||
|
||||
m_id_isSet = false;
|
||||
m_id_isValid = false;
|
||||
|
||||
|
||||
m_pet_id_isSet = false;
|
||||
m_pet_id_isValid = false;
|
||||
|
||||
|
||||
m_quantity_isSet = false;
|
||||
m_quantity_isValid = false;
|
||||
|
||||
|
||||
m_ship_date_isSet = false;
|
||||
m_ship_date_isValid = false;
|
||||
|
||||
|
||||
m_status_isSet = false;
|
||||
m_status_isValid = false;
|
||||
|
||||
|
||||
m_complete_isSet = false;
|
||||
m_complete_isValid = false;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PFXOrder::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
void PFXOrder::fromJson(QString jsonString) {
|
||||
QByteArray array(jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
PFXOrder::fromJsonObject(QJsonObject json) {
|
||||
|
||||
void PFXOrder::fromJsonObject(QJsonObject json) {
|
||||
|
||||
m_id_isValid = ::test_namespace::fromJsonValue(id, json[QString("id")]);
|
||||
m_id_isSet = !json[QString("id")].isNull() && m_id_isValid;
|
||||
|
||||
|
||||
m_pet_id_isValid = ::test_namespace::fromJsonValue(pet_id, json[QString("petId")]);
|
||||
m_pet_id_isSet = !json[QString("petId")].isNull() && m_pet_id_isValid;
|
||||
|
||||
|
||||
m_quantity_isValid = ::test_namespace::fromJsonValue(quantity, json[QString("quantity")]);
|
||||
m_quantity_isSet = !json[QString("quantity")].isNull() && m_quantity_isValid;
|
||||
|
||||
|
||||
m_ship_date_isValid = ::test_namespace::fromJsonValue(ship_date, json[QString("shipDate")]);
|
||||
m_ship_date_isSet = !json[QString("shipDate")].isNull() && m_ship_date_isValid;
|
||||
|
||||
|
||||
m_status_isValid = ::test_namespace::fromJsonValue(status, json[QString("status")]);
|
||||
m_status_isSet = !json[QString("status")].isNull() && m_status_isValid;
|
||||
|
||||
|
||||
m_complete_isValid = ::test_namespace::fromJsonValue(complete, json[QString("complete")]);
|
||||
m_complete_isSet = !json[QString("complete")].isNull() && m_complete_isValid;
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
PFXOrder::asJson () const {
|
||||
QString PFXOrder::asJson() const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
PFXOrder::asJsonObject() const {
|
||||
QJsonObject PFXOrder::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
if (m_id_isSet) {
|
||||
obj.insert(QString("id"), ::test_namespace::toJsonValue(id));
|
||||
}
|
||||
if(m_pet_id_isSet){
|
||||
if (m_pet_id_isSet) {
|
||||
obj.insert(QString("petId"), ::test_namespace::toJsonValue(pet_id));
|
||||
}
|
||||
if(m_quantity_isSet){
|
||||
if (m_quantity_isSet) {
|
||||
obj.insert(QString("quantity"), ::test_namespace::toJsonValue(quantity));
|
||||
}
|
||||
if(m_ship_date_isSet){
|
||||
if (m_ship_date_isSet) {
|
||||
obj.insert(QString("shipDate"), ::test_namespace::toJsonValue(ship_date));
|
||||
}
|
||||
if(m_status_isSet){
|
||||
if (m_status_isSet) {
|
||||
obj.insert(QString("status"), ::test_namespace::toJsonValue(status));
|
||||
}
|
||||
if(m_complete_isSet){
|
||||
if (m_complete_isSet) {
|
||||
obj.insert(QString("complete"), ::test_namespace::toJsonValue(complete));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
PFXOrder::getId() const {
|
||||
qint64 PFXOrder::getId() const {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
PFXOrder::setId(const qint64 &id) {
|
||||
void PFXOrder::setId(const qint64 &id) {
|
||||
this->id = id;
|
||||
this->m_id_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
PFXOrder::getPetId() const {
|
||||
qint64 PFXOrder::getPetId() const {
|
||||
return pet_id;
|
||||
}
|
||||
void
|
||||
PFXOrder::setPetId(const qint64 &pet_id) {
|
||||
void PFXOrder::setPetId(const qint64 &pet_id) {
|
||||
this->pet_id = pet_id;
|
||||
this->m_pet_id_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
qint32
|
||||
PFXOrder::getQuantity() const {
|
||||
qint32 PFXOrder::getQuantity() const {
|
||||
return quantity;
|
||||
}
|
||||
void
|
||||
PFXOrder::setQuantity(const qint32 &quantity) {
|
||||
void PFXOrder::setQuantity(const qint32 &quantity) {
|
||||
this->quantity = quantity;
|
||||
this->m_quantity_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QDateTime
|
||||
PFXOrder::getShipDate() const {
|
||||
QDateTime PFXOrder::getShipDate() const {
|
||||
return ship_date;
|
||||
}
|
||||
void
|
||||
PFXOrder::setShipDate(const QDateTime &ship_date) {
|
||||
void PFXOrder::setShipDate(const QDateTime &ship_date) {
|
||||
this->ship_date = ship_date;
|
||||
this->m_ship_date_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXOrder::getStatus() const {
|
||||
QString PFXOrder::getStatus() const {
|
||||
return status;
|
||||
}
|
||||
void
|
||||
PFXOrder::setStatus(const QString &status) {
|
||||
void PFXOrder::setStatus(const QString &status) {
|
||||
this->status = status;
|
||||
this->m_status_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PFXOrder::isComplete() const {
|
||||
bool PFXOrder::isComplete() const {
|
||||
return complete;
|
||||
}
|
||||
void
|
||||
PFXOrder::setComplete(const bool &complete) {
|
||||
void PFXOrder::setComplete(const bool &complete) {
|
||||
this->complete = complete;
|
||||
this->m_complete_isSet = true;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXOrder::isSet() const {
|
||||
bool PFXOrder::isSet() const {
|
||||
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(m_ship_date_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_status_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_complete_isSet){ isObjectUpdated = true; break;}
|
||||
}while(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 (m_ship_date_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_status_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_complete_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
} while (false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXOrder::isValid() const {
|
||||
bool PFXOrder::isValid() const {
|
||||
// only required properties are required for the object to be considered valid
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -21,86 +20,75 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
|
||||
#include "PFXObject.h"
|
||||
#include "PFXEnum.h"
|
||||
|
||||
#include "PFXObject.h"
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXOrder: public PFXObject {
|
||||
class PFXOrder : public PFXObject {
|
||||
public:
|
||||
PFXOrder();
|
||||
PFXOrder(QString json);
|
||||
~PFXOrder() override;
|
||||
|
||||
QString asJson () const override;
|
||||
QString asJson() const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
|
||||
qint64 getId() const;
|
||||
void setId(const qint64 &id);
|
||||
|
||||
|
||||
qint64 getPetId() const;
|
||||
void setPetId(const qint64 &pet_id);
|
||||
|
||||
|
||||
qint32 getQuantity() const;
|
||||
void setQuantity(const qint32 &quantity);
|
||||
|
||||
|
||||
QDateTime getShipDate() const;
|
||||
void setShipDate(const QDateTime &ship_date);
|
||||
|
||||
|
||||
QString getStatus() const;
|
||||
void setStatus(const QString &status);
|
||||
|
||||
|
||||
bool isComplete() const;
|
||||
void setComplete(const bool &complete);
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
private:
|
||||
void initializeModel();
|
||||
|
||||
|
||||
qint64 id;
|
||||
bool m_id_isSet;
|
||||
bool m_id_isValid;
|
||||
|
||||
|
||||
qint64 pet_id;
|
||||
bool m_pet_id_isSet;
|
||||
bool m_pet_id_isValid;
|
||||
|
||||
|
||||
qint32 quantity;
|
||||
bool m_quantity_isSet;
|
||||
bool m_quantity_isValid;
|
||||
|
||||
|
||||
QDateTime ship_date;
|
||||
bool m_ship_date_isSet;
|
||||
bool m_ship_date_isValid;
|
||||
|
||||
|
||||
QString status;
|
||||
bool m_status_isSet;
|
||||
bool m_status_isValid;
|
||||
|
||||
|
||||
bool complete;
|
||||
bool m_complete_isSet;
|
||||
bool m_complete_isValid;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
Q_DECLARE_METATYPE(test_namespace::PFXOrder)
|
||||
|
||||
|
||||
@@ -3,20 +3,18 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include "PFXPet.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QObject>
|
||||
|
||||
#include "PFXHelpers.h"
|
||||
|
||||
@@ -31,188 +29,174 @@ PFXPet::PFXPet() {
|
||||
this->initializeModel();
|
||||
}
|
||||
|
||||
PFXPet::~PFXPet() {
|
||||
PFXPet::~PFXPet() {}
|
||||
|
||||
}
|
||||
void PFXPet::initializeModel() {
|
||||
|
||||
void
|
||||
PFXPet::initializeModel() {
|
||||
|
||||
m_id_isSet = false;
|
||||
m_id_isValid = false;
|
||||
|
||||
|
||||
m_category_isSet = false;
|
||||
m_category_isValid = false;
|
||||
|
||||
|
||||
m_name_isSet = false;
|
||||
m_name_isValid = false;
|
||||
|
||||
|
||||
m_photo_urls_isSet = false;
|
||||
m_photo_urls_isValid = false;
|
||||
|
||||
|
||||
m_tags_isSet = false;
|
||||
m_tags_isValid = false;
|
||||
|
||||
|
||||
m_status_isSet = false;
|
||||
m_status_isValid = false;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PFXPet::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
void PFXPet::fromJson(QString jsonString) {
|
||||
QByteArray array(jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
PFXPet::fromJsonObject(QJsonObject json) {
|
||||
|
||||
void PFXPet::fromJsonObject(QJsonObject json) {
|
||||
|
||||
m_id_isValid = ::test_namespace::fromJsonValue(id, json[QString("id")]);
|
||||
m_id_isSet = !json[QString("id")].isNull() && m_id_isValid;
|
||||
|
||||
|
||||
m_category_isValid = ::test_namespace::fromJsonValue(category, json[QString("category")]);
|
||||
m_category_isSet = !json[QString("category")].isNull() && m_category_isValid;
|
||||
|
||||
|
||||
m_name_isValid = ::test_namespace::fromJsonValue(name, json[QString("name")]);
|
||||
m_name_isSet = !json[QString("name")].isNull() && m_name_isValid;
|
||||
|
||||
|
||||
m_photo_urls_isValid = ::test_namespace::fromJsonValue(photo_urls, json[QString("photoUrls")]);
|
||||
m_photo_urls_isSet = !json[QString("photoUrls")].isNull() && m_photo_urls_isValid;
|
||||
|
||||
|
||||
m_tags_isValid = ::test_namespace::fromJsonValue(tags, json[QString("tags")]);
|
||||
m_tags_isSet = !json[QString("tags")].isNull() && m_tags_isValid;
|
||||
|
||||
|
||||
m_status_isValid = ::test_namespace::fromJsonValue(status, json[QString("status")]);
|
||||
m_status_isSet = !json[QString("status")].isNull() && m_status_isValid;
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
PFXPet::asJson () const {
|
||||
QString PFXPet::asJson() const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
PFXPet::asJsonObject() const {
|
||||
QJsonObject PFXPet::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
if (m_id_isSet) {
|
||||
obj.insert(QString("id"), ::test_namespace::toJsonValue(id));
|
||||
}
|
||||
if(category.isSet()){
|
||||
if (category.isSet()) {
|
||||
obj.insert(QString("category"), ::test_namespace::toJsonValue(category));
|
||||
}
|
||||
if(m_name_isSet){
|
||||
if (m_name_isSet) {
|
||||
obj.insert(QString("name"), ::test_namespace::toJsonValue(name));
|
||||
}
|
||||
|
||||
if(photo_urls.size() > 0){
|
||||
if (photo_urls.size() > 0) {
|
||||
obj.insert(QString("photoUrls"), ::test_namespace::toJsonValue(photo_urls));
|
||||
}
|
||||
|
||||
if(tags.size() > 0){
|
||||
}
|
||||
if (tags.size() > 0) {
|
||||
obj.insert(QString("tags"), ::test_namespace::toJsonValue(tags));
|
||||
}
|
||||
if(m_status_isSet){
|
||||
}
|
||||
if (m_status_isSet) {
|
||||
obj.insert(QString("status"), ::test_namespace::toJsonValue(status));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
PFXPet::getId() const {
|
||||
qint64 PFXPet::getId() const {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
PFXPet::setId(const qint64 &id) {
|
||||
void PFXPet::setId(const qint64 &id) {
|
||||
this->id = id;
|
||||
this->m_id_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
PFXCategory
|
||||
PFXPet::getCategory() const {
|
||||
PFXCategory PFXPet::getCategory() const {
|
||||
return category;
|
||||
}
|
||||
void
|
||||
PFXPet::setCategory(const PFXCategory &category) {
|
||||
void PFXPet::setCategory(const PFXCategory &category) {
|
||||
this->category = category;
|
||||
this->m_category_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXPet::getName() const {
|
||||
QString PFXPet::getName() const {
|
||||
return name;
|
||||
}
|
||||
void
|
||||
PFXPet::setName(const QString &name) {
|
||||
void PFXPet::setName(const QString &name) {
|
||||
this->name = name;
|
||||
this->m_name_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QList<QString>
|
||||
PFXPet::getPhotoUrls() const {
|
||||
QList<QString> PFXPet::getPhotoUrls() const {
|
||||
return photo_urls;
|
||||
}
|
||||
void
|
||||
PFXPet::setPhotoUrls(const QList<QString> &photo_urls) {
|
||||
void PFXPet::setPhotoUrls(const QList<QString> &photo_urls) {
|
||||
this->photo_urls = photo_urls;
|
||||
this->m_photo_urls_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QList<PFXTag>
|
||||
PFXPet::getTags() const {
|
||||
QList<PFXTag> PFXPet::getTags() const {
|
||||
return tags;
|
||||
}
|
||||
void
|
||||
PFXPet::setTags(const QList<PFXTag> &tags) {
|
||||
void PFXPet::setTags(const QList<PFXTag> &tags) {
|
||||
this->tags = tags;
|
||||
this->m_tags_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXPet::getStatus() const {
|
||||
QString PFXPet::getStatus() const {
|
||||
return status;
|
||||
}
|
||||
void
|
||||
PFXPet::setStatus(const QString &status) {
|
||||
void PFXPet::setStatus(const QString &status) {
|
||||
this->status = status;
|
||||
this->m_status_isSet = true;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXPet::isSet() const {
|
||||
bool PFXPet::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_id_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(category.isSet()){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_name_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(photo_urls.size() > 0){ isObjectUpdated = true; break;}
|
||||
|
||||
if(tags.size() > 0){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_status_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
do {
|
||||
if (m_id_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (category.isSet()) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_name_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (photo_urls.size() > 0) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (tags.size() > 0) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_status_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
} while (false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXPet::isValid() const {
|
||||
bool PFXPet::isValid() const {
|
||||
// only required properties are required for the object to be considered valid
|
||||
return m_name_isValid && m_photo_urls_isValid && true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -21,88 +20,77 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include "PFXCategory.h"
|
||||
#include "PFXTag.h"
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "PFXObject.h"
|
||||
#include "PFXEnum.h"
|
||||
|
||||
#include "PFXObject.h"
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXPet: public PFXObject {
|
||||
class PFXPet : public PFXObject {
|
||||
public:
|
||||
PFXPet();
|
||||
PFXPet(QString json);
|
||||
~PFXPet() override;
|
||||
|
||||
QString asJson () const override;
|
||||
QString asJson() const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
|
||||
qint64 getId() const;
|
||||
void setId(const qint64 &id);
|
||||
|
||||
|
||||
PFXCategory getCategory() const;
|
||||
void setCategory(const PFXCategory &category);
|
||||
|
||||
|
||||
QString getName() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
|
||||
QList<QString> getPhotoUrls() const;
|
||||
void setPhotoUrls(const QList<QString> &photo_urls);
|
||||
|
||||
|
||||
QList<PFXTag> getTags() const;
|
||||
void setTags(const QList<PFXTag> &tags);
|
||||
|
||||
|
||||
QString getStatus() const;
|
||||
void setStatus(const QString &status);
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
private:
|
||||
void initializeModel();
|
||||
|
||||
|
||||
qint64 id;
|
||||
bool m_id_isSet;
|
||||
bool m_id_isValid;
|
||||
|
||||
|
||||
PFXCategory category;
|
||||
bool m_category_isSet;
|
||||
bool m_category_isValid;
|
||||
|
||||
|
||||
QString name;
|
||||
bool m_name_isSet;
|
||||
bool m_name_isValid;
|
||||
|
||||
|
||||
QList<QString> photo_urls;
|
||||
bool m_photo_urls_isSet;
|
||||
bool m_photo_urls_isValid;
|
||||
|
||||
|
||||
QList<PFXTag> tags;
|
||||
bool m_tags_isSet;
|
||||
bool m_tags_isValid;
|
||||
|
||||
|
||||
QString status;
|
||||
bool m_status_isSet;
|
||||
bool m_status_isValid;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
Q_DECLARE_METATYPE(test_namespace::PFXPet)
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -18,86 +17,75 @@
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
PFXPetApi::PFXPetApi(const QString &scheme, const QString &host, int port, const QString& basePath, const int timeOut) :
|
||||
_scheme(scheme),
|
||||
_host(host),
|
||||
_port(port),
|
||||
_basePath(basePath),
|
||||
_timeOut(timeOut) {
|
||||
}
|
||||
PFXPetApi::PFXPetApi(const QString &scheme, const QString &host, int port, const QString &basePath, const int timeOut)
|
||||
: _scheme(scheme),
|
||||
_host(host),
|
||||
_port(port),
|
||||
_basePath(basePath),
|
||||
_timeOut(timeOut) {}
|
||||
|
||||
PFXPetApi::~PFXPetApi() {
|
||||
}
|
||||
|
||||
void PFXPetApi::setScheme(const QString& scheme){
|
||||
void PFXPetApi::setScheme(const QString &scheme) {
|
||||
_scheme = scheme;
|
||||
}
|
||||
|
||||
void PFXPetApi::setHost(const QString& host){
|
||||
void PFXPetApi::setHost(const QString &host) {
|
||||
_host = host;
|
||||
}
|
||||
|
||||
void PFXPetApi::setPort(int port){
|
||||
void PFXPetApi::setPort(int port) {
|
||||
_port = port;
|
||||
}
|
||||
|
||||
void PFXPetApi::setBasePath(const QString& basePath){
|
||||
void PFXPetApi::setBasePath(const QString &basePath) {
|
||||
_basePath = basePath;
|
||||
}
|
||||
|
||||
void PFXPetApi::setTimeOut(const int timeOut){
|
||||
void PFXPetApi::setTimeOut(const int timeOut) {
|
||||
_timeOut = timeOut;
|
||||
}
|
||||
|
||||
void PFXPetApi::setWorkingDirectory(const QString& path){
|
||||
void PFXPetApi::setWorkingDirectory(const QString &path) {
|
||||
_workingDirectory = path;
|
||||
}
|
||||
|
||||
void PFXPetApi::addHeaders(const QString& key, const QString& value){
|
||||
void PFXPetApi::addHeaders(const QString &key, const QString &value) {
|
||||
defaultHeaders.insert(key, value);
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::addPet(const PFXPet& body) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet");
|
||||
|
||||
void PFXPetApi::addPet(const PFXPet &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet");
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXPetApi::addPetCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::addPetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::addPetCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXPetApi::addPetCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -111,50 +99,41 @@ PFXPetApi::addPetCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::deletePet(const qint64& pet_id, const QString& api_key) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}");
|
||||
void PFXPetApi::deletePet(const qint64 &pet_id, const QString &api_key) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "DELETE");
|
||||
|
||||
|
||||
if (api_key != nullptr) {
|
||||
input.headers.insert("api_key", api_key);
|
||||
}
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXPetApi::deletePetCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::deletePetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::deletePetCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXPetApi::deletePetCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -168,92 +147,80 @@ PFXPetApi::deletePetCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::findPetsByStatus(const QList<QString>& status) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/findByStatus");
|
||||
|
||||
void PFXPetApi::findPetsByStatus(const QList<QString> &status) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/findByStatus");
|
||||
|
||||
if (status.size() > 0) {
|
||||
if (QString("csv").indexOf("multi") == 0) {
|
||||
foreach(QString t, status) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("status=").append(::test_namespace::toStringValue(t));
|
||||
if (QString("csv").indexOf("multi") == 0) {
|
||||
foreach (QString t, status) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("status=").append(::test_namespace::toStringValue(t));
|
||||
}
|
||||
} else if (QString("csv").indexOf("ssv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("status=");
|
||||
qint32 count = 0;
|
||||
foreach (QString t, status) {
|
||||
if (count > 0) {
|
||||
fullPath.append(" ");
|
||||
}
|
||||
fullPath.append(::test_namespace::toStringValue(t));
|
||||
}
|
||||
} else if (QString("csv").indexOf("tsv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("status=");
|
||||
qint32 count = 0;
|
||||
foreach (QString t, status) {
|
||||
if (count > 0) {
|
||||
fullPath.append("\t");
|
||||
}
|
||||
fullPath.append(::test_namespace::toStringValue(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (QString("csv").indexOf("ssv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("status=");
|
||||
qint32 count = 0;
|
||||
foreach(QString t, status) {
|
||||
if (count > 0) {
|
||||
fullPath.append(" ");
|
||||
}
|
||||
fullPath.append(::test_namespace::toStringValue(t));
|
||||
}
|
||||
}
|
||||
else if (QString("csv").indexOf("tsv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("status=");
|
||||
qint32 count = 0;
|
||||
foreach(QString t, status) {
|
||||
if (count > 0) {
|
||||
fullPath.append("\t");
|
||||
}
|
||||
fullPath.append(::test_namespace::toStringValue(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXPetApi::findPetsByStatusCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByStatusCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::findPetsByStatusCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXPetApi::findPetsByStatusCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
QList<PFXPet> output;
|
||||
QString json(worker->response);
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QByteArray array(json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonArray jsonArray = doc.array();
|
||||
foreach(QJsonValue obj, jsonArray) {
|
||||
foreach (QJsonValue obj, jsonArray) {
|
||||
PFXPet val;
|
||||
::test_namespace::fromJsonValue(val, obj);
|
||||
output.append(val);
|
||||
@@ -269,92 +236,80 @@ PFXPetApi::findPetsByStatusCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::findPetsByTags(const QList<QString>& tags) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/findByTags");
|
||||
|
||||
void PFXPetApi::findPetsByTags(const QList<QString> &tags) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/findByTags");
|
||||
|
||||
if (tags.size() > 0) {
|
||||
if (QString("csv").indexOf("multi") == 0) {
|
||||
foreach(QString t, tags) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("tags=").append(::test_namespace::toStringValue(t));
|
||||
if (QString("csv").indexOf("multi") == 0) {
|
||||
foreach (QString t, tags) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("tags=").append(::test_namespace::toStringValue(t));
|
||||
}
|
||||
} else if (QString("csv").indexOf("ssv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("tags=");
|
||||
qint32 count = 0;
|
||||
foreach (QString t, tags) {
|
||||
if (count > 0) {
|
||||
fullPath.append(" ");
|
||||
}
|
||||
fullPath.append(::test_namespace::toStringValue(t));
|
||||
}
|
||||
} else if (QString("csv").indexOf("tsv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("tags=");
|
||||
qint32 count = 0;
|
||||
foreach (QString t, tags) {
|
||||
if (count > 0) {
|
||||
fullPath.append("\t");
|
||||
}
|
||||
fullPath.append(::test_namespace::toStringValue(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (QString("csv").indexOf("ssv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("tags=");
|
||||
qint32 count = 0;
|
||||
foreach(QString t, tags) {
|
||||
if (count > 0) {
|
||||
fullPath.append(" ");
|
||||
}
|
||||
fullPath.append(::test_namespace::toStringValue(t));
|
||||
}
|
||||
}
|
||||
else if (QString("csv").indexOf("tsv") == 0) {
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append("tags=");
|
||||
qint32 count = 0;
|
||||
foreach(QString t, tags) {
|
||||
if (count > 0) {
|
||||
fullPath.append("\t");
|
||||
}
|
||||
fullPath.append(::test_namespace::toStringValue(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXPetApi::findPetsByTagsCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::findPetsByTagsCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::findPetsByTagsCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXPetApi::findPetsByTagsCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
QList<PFXPet> output;
|
||||
QString json(worker->response);
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QByteArray array(json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonArray jsonArray = doc.array();
|
||||
foreach(QJsonValue obj, jsonArray) {
|
||||
foreach (QJsonValue obj, jsonArray) {
|
||||
PFXPet val;
|
||||
::test_namespace::fromJsonValue(val, obj);
|
||||
output.append(val);
|
||||
@@ -370,47 +325,37 @@ PFXPetApi::findPetsByTagsCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::getPetById(const qint64& pet_id) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}");
|
||||
void PFXPetApi::getPetById(const qint64 &pet_id) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXPetApi::getPetByIdCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::getPetByIdCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::getPetByIdCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXPetApi::getPetByIdCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
PFXPet output(QString(worker->response));
|
||||
@@ -425,47 +370,37 @@ PFXPetApi::getPetByIdCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::updatePet(const PFXPet& body) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet");
|
||||
|
||||
void PFXPetApi::updatePet(const PFXPet &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet");
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "PUT");
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXPetApi::updatePetCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::updatePetCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXPetApi::updatePetCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -479,49 +414,39 @@ PFXPetApi::updatePetCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::updatePetWithForm(const qint64& pet_id, const QString& name, const QString& status) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}");
|
||||
void PFXPetApi::updatePetWithForm(const qint64 &pet_id, const QString &name, const QString &status) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
input.add_var("name", ::test_namespace::toStringValue(name));
|
||||
input.add_var("status", ::test_namespace::toStringValue(status));
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXPetApi::updatePetWithFormCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::updatePetWithFormCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::updatePetWithFormCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXPetApi::updatePetWithFormCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -535,49 +460,39 @@ PFXPetApi::updatePetWithFormCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::uploadFile(const qint64& pet_id, const QString& additional_metadata, const PFXHttpFileElement& file) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}/uploadImage");
|
||||
void PFXPetApi::uploadFile(const qint64 &pet_id, const QString &additional_metadata, const PFXHttpFileElement &file) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/pet/{petId}/uploadImage");
|
||||
QString pet_idPathParam("{");
|
||||
pet_idPathParam.append("petId").append("}");
|
||||
fullPath.replace(pet_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(pet_id)));
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
input.add_var("additionalMetadata", ::test_namespace::toStringValue(additional_metadata));
|
||||
input.add_file("file", file.local_filename, file.request_filename, file.mime_type);
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXPetApi::uploadFileCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXPetApi::uploadFileCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXPetApi::uploadFileCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXPetApi::uploadFileCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
PFXApiResponse output(QString(worker->response));
|
||||
@@ -592,5 +507,4 @@ PFXPetApi::uploadFileCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -24,30 +23,30 @@
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXPetApi: public QObject {
|
||||
class PFXPetApi : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PFXPetApi(const QString &scheme = "http", const QString &host = "petstore.swagger.io", int port = 0, const QString& basePath = "/v2", const int timeOut = 0);
|
||||
PFXPetApi(const QString &scheme = "http", const QString &host = "petstore.swagger.io", int port = 0, const QString &basePath = "/v2", const int timeOut = 0);
|
||||
~PFXPetApi();
|
||||
|
||||
void setScheme(const QString &scheme);
|
||||
void setHost(const QString &host);
|
||||
void setPort(int port);
|
||||
void setBasePath(const QString& basePath);
|
||||
void setBasePath(const QString &basePath);
|
||||
void setTimeOut(const int timeOut);
|
||||
void setWorkingDirectory(const QString& path);
|
||||
void addHeaders(const QString& key, const QString& value);
|
||||
void setWorkingDirectory(const QString &path);
|
||||
void addHeaders(const QString &key, const QString &value);
|
||||
|
||||
void addPet(const PFXPet &body);
|
||||
void deletePet(const qint64 &pet_id, const QString &api_key);
|
||||
void findPetsByStatus(const QList<QString> &status);
|
||||
void findPetsByTags(const QList<QString> &tags);
|
||||
void getPetById(const qint64 &pet_id);
|
||||
void updatePet(const PFXPet &body);
|
||||
void updatePetWithForm(const qint64 &pet_id, const QString &name, const QString &status);
|
||||
void uploadFile(const qint64 &pet_id, const QString &additional_metadata, const PFXHttpFileElement &file);
|
||||
|
||||
void addPet(const PFXPet& body);
|
||||
void deletePet(const qint64& pet_id, const QString& api_key);
|
||||
void findPetsByStatus(const QList<QString>& status);
|
||||
void findPetsByTags(const QList<QString>& tags);
|
||||
void getPetById(const qint64& pet_id);
|
||||
void updatePet(const PFXPet& body);
|
||||
void updatePetWithForm(const qint64& pet_id, const QString& name, const QString& status);
|
||||
void uploadFile(const qint64& pet_id, const QString& additional_metadata, const PFXHttpFileElement& file);
|
||||
|
||||
private:
|
||||
QString _scheme, _host;
|
||||
int _port;
|
||||
@@ -55,16 +54,18 @@ private:
|
||||
int _timeOut;
|
||||
QString _workingDirectory;
|
||||
QMap<QString, QString> defaultHeaders;
|
||||
void addPetCallback (PFXHttpRequestWorker * worker);
|
||||
void deletePetCallback (PFXHttpRequestWorker * worker);
|
||||
void findPetsByStatusCallback (PFXHttpRequestWorker * worker);
|
||||
void findPetsByTagsCallback (PFXHttpRequestWorker * worker);
|
||||
void getPetByIdCallback (PFXHttpRequestWorker * worker);
|
||||
void updatePetCallback (PFXHttpRequestWorker * worker);
|
||||
void updatePetWithFormCallback (PFXHttpRequestWorker * worker);
|
||||
void uploadFileCallback (PFXHttpRequestWorker * worker);
|
||||
|
||||
|
||||
void addPetCallback(PFXHttpRequestWorker *worker);
|
||||
void deletePetCallback(PFXHttpRequestWorker *worker);
|
||||
void findPetsByStatusCallback(PFXHttpRequestWorker *worker);
|
||||
void findPetsByTagsCallback(PFXHttpRequestWorker *worker);
|
||||
void getPetByIdCallback(PFXHttpRequestWorker *worker);
|
||||
void updatePetCallback(PFXHttpRequestWorker *worker);
|
||||
void updatePetWithFormCallback(PFXHttpRequestWorker *worker);
|
||||
void uploadFileCallback(PFXHttpRequestWorker *worker);
|
||||
|
||||
signals:
|
||||
|
||||
void addPetSignal();
|
||||
void deletePetSignal();
|
||||
void findPetsByStatusSignal(QList<PFXPet> summary);
|
||||
@@ -73,16 +74,16 @@ signals:
|
||||
void updatePetSignal();
|
||||
void updatePetWithFormSignal();
|
||||
void uploadFileSignal(PFXApiResponse summary);
|
||||
|
||||
void addPetSignalFull(PFXHttpRequestWorker* worker);
|
||||
void deletePetSignalFull(PFXHttpRequestWorker* worker);
|
||||
void findPetsByStatusSignalFull(PFXHttpRequestWorker* worker, QList<PFXPet> summary);
|
||||
void findPetsByTagsSignalFull(PFXHttpRequestWorker* worker, QList<PFXPet> summary);
|
||||
void getPetByIdSignalFull(PFXHttpRequestWorker* worker, PFXPet summary);
|
||||
void updatePetSignalFull(PFXHttpRequestWorker* worker);
|
||||
void updatePetWithFormSignalFull(PFXHttpRequestWorker* worker);
|
||||
void uploadFileSignalFull(PFXHttpRequestWorker* worker, PFXApiResponse summary);
|
||||
|
||||
|
||||
void addPetSignalFull(PFXHttpRequestWorker *worker);
|
||||
void deletePetSignalFull(PFXHttpRequestWorker *worker);
|
||||
void findPetsByStatusSignalFull(PFXHttpRequestWorker *worker, QList<PFXPet> summary);
|
||||
void findPetsByTagsSignalFull(PFXHttpRequestWorker *worker, QList<PFXPet> summary);
|
||||
void getPetByIdSignalFull(PFXHttpRequestWorker *worker, PFXPet summary);
|
||||
void updatePetSignalFull(PFXHttpRequestWorker *worker);
|
||||
void updatePetWithFormSignalFull(PFXHttpRequestWorker *worker);
|
||||
void uploadFileSignalFull(PFXHttpRequestWorker *worker, PFXApiResponse summary);
|
||||
|
||||
void addPetSignalE(QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void deletePetSignalE(QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void findPetsByStatusSignalE(QList<PFXPet> summary, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
@@ -91,17 +92,16 @@ signals:
|
||||
void updatePetSignalE(QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void updatePetWithFormSignalE(QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void uploadFileSignalE(PFXApiResponse summary, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
|
||||
void addPetSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void deletePetSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void findPetsByStatusSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void findPetsByTagsSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void getPetByIdSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void updatePetSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void updatePetWithFormSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void uploadFileSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
|
||||
|
||||
void addPetSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void deletePetSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void findPetsByStatusSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void findPetsByTagsSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void getPetByIdSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void updatePetSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void updatePetWithFormSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void uploadFileSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -18,86 +17,75 @@
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
PFXStoreApi::PFXStoreApi(const QString &scheme, const QString &host, int port, const QString& basePath, const int timeOut) :
|
||||
_scheme(scheme),
|
||||
_host(host),
|
||||
_port(port),
|
||||
_basePath(basePath),
|
||||
_timeOut(timeOut) {
|
||||
}
|
||||
PFXStoreApi::PFXStoreApi(const QString &scheme, const QString &host, int port, const QString &basePath, const int timeOut)
|
||||
: _scheme(scheme),
|
||||
_host(host),
|
||||
_port(port),
|
||||
_basePath(basePath),
|
||||
_timeOut(timeOut) {}
|
||||
|
||||
PFXStoreApi::~PFXStoreApi() {
|
||||
}
|
||||
|
||||
void PFXStoreApi::setScheme(const QString& scheme){
|
||||
void PFXStoreApi::setScheme(const QString &scheme) {
|
||||
_scheme = scheme;
|
||||
}
|
||||
|
||||
void PFXStoreApi::setHost(const QString& host){
|
||||
void PFXStoreApi::setHost(const QString &host) {
|
||||
_host = host;
|
||||
}
|
||||
|
||||
void PFXStoreApi::setPort(int port){
|
||||
void PFXStoreApi::setPort(int port) {
|
||||
_port = port;
|
||||
}
|
||||
|
||||
void PFXStoreApi::setBasePath(const QString& basePath){
|
||||
void PFXStoreApi::setBasePath(const QString &basePath) {
|
||||
_basePath = basePath;
|
||||
}
|
||||
|
||||
void PFXStoreApi::setTimeOut(const int timeOut){
|
||||
void PFXStoreApi::setTimeOut(const int timeOut) {
|
||||
_timeOut = timeOut;
|
||||
}
|
||||
|
||||
void PFXStoreApi::setWorkingDirectory(const QString& path){
|
||||
void PFXStoreApi::setWorkingDirectory(const QString &path) {
|
||||
_workingDirectory = path;
|
||||
}
|
||||
|
||||
void PFXStoreApi::addHeaders(const QString& key, const QString& value){
|
||||
void PFXStoreApi::addHeaders(const QString &key, const QString &value) {
|
||||
defaultHeaders.insert(key, value);
|
||||
}
|
||||
|
||||
void
|
||||
PFXStoreApi::deleteOrder(const QString& order_id) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/order/{orderId}");
|
||||
void PFXStoreApi::deleteOrder(const QString &order_id) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/order/{orderId}");
|
||||
QString order_idPathParam("{");
|
||||
order_idPathParam.append("orderId").append("}");
|
||||
fullPath.replace(order_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(order_id)));
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "DELETE");
|
||||
|
||||
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXStoreApi::deleteOrderCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::deleteOrderCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXStoreApi::deleteOrderCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXStoreApi::deleteOrderCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -111,52 +99,42 @@ PFXStoreApi::deleteOrderCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXStoreApi::getInventory() {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/inventory");
|
||||
|
||||
void PFXStoreApi::getInventory() {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/inventory");
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXStoreApi::getInventoryCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getInventoryCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXStoreApi::getInventoryCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXStoreApi::getInventoryCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
QMap<QString, qint32> output;
|
||||
QString json(worker->response);
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QByteArray array(json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject obj = doc.object();
|
||||
foreach(QString key, obj.keys()) {
|
||||
foreach (QString key, obj.keys()) {
|
||||
qint32 val;
|
||||
::test_namespace::fromJsonValue(val, obj[key]);
|
||||
output.insert(key, val);
|
||||
@@ -172,47 +150,37 @@ PFXStoreApi::getInventoryCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXStoreApi::getOrderById(const qint64& order_id) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/order/{orderId}");
|
||||
void PFXStoreApi::getOrderById(const qint64 &order_id) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/order/{orderId}");
|
||||
QString order_idPathParam("{");
|
||||
order_idPathParam.append("orderId").append("}");
|
||||
fullPath.replace(order_idPathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(order_id)));
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXStoreApi::getOrderByIdCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::getOrderByIdCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXStoreApi::getOrderByIdCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXStoreApi::getOrderByIdCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
PFXOrder output(QString(worker->response));
|
||||
@@ -227,47 +195,37 @@ PFXStoreApi::getOrderByIdCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXStoreApi::placeOrder(const PFXOrder& body) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/order");
|
||||
|
||||
void PFXStoreApi::placeOrder(const PFXOrder &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/store/order");
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXStoreApi::placeOrderCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXStoreApi::placeOrderCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXStoreApi::placeOrderCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXStoreApi::placeOrderCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
PFXOrder output(QString(worker->response));
|
||||
@@ -282,5 +240,4 @@ PFXStoreApi::placeOrderCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -23,26 +22,26 @@
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXStoreApi: public QObject {
|
||||
class PFXStoreApi : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PFXStoreApi(const QString &scheme = "http", const QString &host = "petstore.swagger.io", int port = 0, const QString& basePath = "/v2", const int timeOut = 0);
|
||||
PFXStoreApi(const QString &scheme = "http", const QString &host = "petstore.swagger.io", int port = 0, const QString &basePath = "/v2", const int timeOut = 0);
|
||||
~PFXStoreApi();
|
||||
|
||||
void setScheme(const QString &scheme);
|
||||
void setHost(const QString &host);
|
||||
void setPort(int port);
|
||||
void setBasePath(const QString& basePath);
|
||||
void setBasePath(const QString &basePath);
|
||||
void setTimeOut(const int timeOut);
|
||||
void setWorkingDirectory(const QString& path);
|
||||
void addHeaders(const QString& key, const QString& value);
|
||||
void setWorkingDirectory(const QString &path);
|
||||
void addHeaders(const QString &key, const QString &value);
|
||||
|
||||
void deleteOrder(const QString& order_id);
|
||||
void deleteOrder(const QString &order_id);
|
||||
void getInventory();
|
||||
void getOrderById(const qint64& order_id);
|
||||
void placeOrder(const PFXOrder& body);
|
||||
|
||||
void getOrderById(const qint64 &order_id);
|
||||
void placeOrder(const PFXOrder &body);
|
||||
|
||||
private:
|
||||
QString _scheme, _host;
|
||||
int _port;
|
||||
@@ -50,33 +49,34 @@ private:
|
||||
int _timeOut;
|
||||
QString _workingDirectory;
|
||||
QMap<QString, QString> defaultHeaders;
|
||||
void deleteOrderCallback (PFXHttpRequestWorker * worker);
|
||||
void getInventoryCallback (PFXHttpRequestWorker * worker);
|
||||
void getOrderByIdCallback (PFXHttpRequestWorker * worker);
|
||||
void placeOrderCallback (PFXHttpRequestWorker * worker);
|
||||
|
||||
|
||||
void deleteOrderCallback(PFXHttpRequestWorker *worker);
|
||||
void getInventoryCallback(PFXHttpRequestWorker *worker);
|
||||
void getOrderByIdCallback(PFXHttpRequestWorker *worker);
|
||||
void placeOrderCallback(PFXHttpRequestWorker *worker);
|
||||
|
||||
signals:
|
||||
|
||||
void deleteOrderSignal();
|
||||
void getInventorySignal(QMap<QString, qint32> summary);
|
||||
void getOrderByIdSignal(PFXOrder summary);
|
||||
void placeOrderSignal(PFXOrder summary);
|
||||
|
||||
void deleteOrderSignalFull(PFXHttpRequestWorker* worker);
|
||||
void getInventorySignalFull(PFXHttpRequestWorker* worker, QMap<QString, qint32> summary);
|
||||
void getOrderByIdSignalFull(PFXHttpRequestWorker* worker, PFXOrder summary);
|
||||
void placeOrderSignalFull(PFXHttpRequestWorker* worker, PFXOrder summary);
|
||||
|
||||
|
||||
void deleteOrderSignalFull(PFXHttpRequestWorker *worker);
|
||||
void getInventorySignalFull(PFXHttpRequestWorker *worker, QMap<QString, qint32> summary);
|
||||
void getOrderByIdSignalFull(PFXHttpRequestWorker *worker, PFXOrder summary);
|
||||
void placeOrderSignalFull(PFXHttpRequestWorker *worker, PFXOrder summary);
|
||||
|
||||
void deleteOrderSignalE(QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void getInventorySignalE(QMap<QString, qint32> summary, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void getOrderByIdSignalE(PFXOrder summary, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void placeOrderSignalE(PFXOrder summary, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
|
||||
void deleteOrderSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void getInventorySignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void getOrderByIdSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void placeOrderSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
|
||||
|
||||
void deleteOrderSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void getInventorySignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void getOrderByIdSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void placeOrderSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
#endif
|
||||
|
||||
@@ -3,20 +3,18 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include "PFXTag.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QObject>
|
||||
|
||||
#include "PFXHelpers.h"
|
||||
|
||||
@@ -31,98 +29,86 @@ PFXTag::PFXTag() {
|
||||
this->initializeModel();
|
||||
}
|
||||
|
||||
PFXTag::~PFXTag() {
|
||||
PFXTag::~PFXTag() {}
|
||||
|
||||
}
|
||||
void PFXTag::initializeModel() {
|
||||
|
||||
void
|
||||
PFXTag::initializeModel() {
|
||||
|
||||
m_id_isSet = false;
|
||||
m_id_isValid = false;
|
||||
|
||||
|
||||
m_name_isSet = false;
|
||||
m_name_isValid = false;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PFXTag::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
void PFXTag::fromJson(QString jsonString) {
|
||||
QByteArray array(jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
PFXTag::fromJsonObject(QJsonObject json) {
|
||||
|
||||
void PFXTag::fromJsonObject(QJsonObject json) {
|
||||
|
||||
m_id_isValid = ::test_namespace::fromJsonValue(id, json[QString("id")]);
|
||||
m_id_isSet = !json[QString("id")].isNull() && m_id_isValid;
|
||||
|
||||
|
||||
m_name_isValid = ::test_namespace::fromJsonValue(name, json[QString("name")]);
|
||||
m_name_isSet = !json[QString("name")].isNull() && m_name_isValid;
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
PFXTag::asJson () const {
|
||||
QString PFXTag::asJson() const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
PFXTag::asJsonObject() const {
|
||||
QJsonObject PFXTag::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
if (m_id_isSet) {
|
||||
obj.insert(QString("id"), ::test_namespace::toJsonValue(id));
|
||||
}
|
||||
if(m_name_isSet){
|
||||
if (m_name_isSet) {
|
||||
obj.insert(QString("name"), ::test_namespace::toJsonValue(name));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
PFXTag::getId() const {
|
||||
qint64 PFXTag::getId() const {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
PFXTag::setId(const qint64 &id) {
|
||||
void PFXTag::setId(const qint64 &id) {
|
||||
this->id = id;
|
||||
this->m_id_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXTag::getName() const {
|
||||
QString PFXTag::getName() const {
|
||||
return name;
|
||||
}
|
||||
void
|
||||
PFXTag::setName(const QString &name) {
|
||||
void PFXTag::setName(const QString &name) {
|
||||
this->name = name;
|
||||
this->m_name_isSet = true;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXTag::isSet() const {
|
||||
bool PFXTag::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_id_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_name_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
do {
|
||||
if (m_id_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_name_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
} while (false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXTag::isValid() const {
|
||||
bool PFXTag::isValid() const {
|
||||
// only required properties are required for the object to be considered valid
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -21,53 +20,46 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "PFXObject.h"
|
||||
#include "PFXEnum.h"
|
||||
|
||||
#include "PFXObject.h"
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXTag: public PFXObject {
|
||||
class PFXTag : public PFXObject {
|
||||
public:
|
||||
PFXTag();
|
||||
PFXTag(QString json);
|
||||
~PFXTag() override;
|
||||
|
||||
QString asJson () const override;
|
||||
QString asJson() const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
|
||||
qint64 getId() const;
|
||||
void setId(const qint64 &id);
|
||||
|
||||
|
||||
QString getName() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
private:
|
||||
void initializeModel();
|
||||
|
||||
|
||||
qint64 id;
|
||||
bool m_id_isSet;
|
||||
bool m_id_isValid;
|
||||
|
||||
|
||||
QString name;
|
||||
bool m_name_isSet;
|
||||
bool m_name_isValid;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
Q_DECLARE_METATYPE(test_namespace::PFXTag)
|
||||
|
||||
|
||||
@@ -3,20 +3,18 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include "PFXUser.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QObject>
|
||||
|
||||
#include "PFXHelpers.h"
|
||||
|
||||
@@ -31,230 +29,218 @@ PFXUser::PFXUser() {
|
||||
this->initializeModel();
|
||||
}
|
||||
|
||||
PFXUser::~PFXUser() {
|
||||
PFXUser::~PFXUser() {}
|
||||
|
||||
}
|
||||
void PFXUser::initializeModel() {
|
||||
|
||||
void
|
||||
PFXUser::initializeModel() {
|
||||
|
||||
m_id_isSet = false;
|
||||
m_id_isValid = false;
|
||||
|
||||
|
||||
m_username_isSet = false;
|
||||
m_username_isValid = false;
|
||||
|
||||
|
||||
m_first_name_isSet = false;
|
||||
m_first_name_isValid = false;
|
||||
|
||||
|
||||
m_last_name_isSet = false;
|
||||
m_last_name_isValid = false;
|
||||
|
||||
|
||||
m_email_isSet = false;
|
||||
m_email_isValid = false;
|
||||
|
||||
|
||||
m_password_isSet = false;
|
||||
m_password_isValid = false;
|
||||
|
||||
|
||||
m_phone_isSet = false;
|
||||
m_phone_isValid = false;
|
||||
|
||||
|
||||
m_user_status_isSet = false;
|
||||
m_user_status_isValid = false;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
PFXUser::fromJson(QString jsonString) {
|
||||
QByteArray array (jsonString.toStdString().c_str());
|
||||
void PFXUser::fromJson(QString jsonString) {
|
||||
QByteArray array(jsonString.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
}
|
||||
|
||||
void
|
||||
PFXUser::fromJsonObject(QJsonObject json) {
|
||||
|
||||
void PFXUser::fromJsonObject(QJsonObject json) {
|
||||
|
||||
m_id_isValid = ::test_namespace::fromJsonValue(id, json[QString("id")]);
|
||||
m_id_isSet = !json[QString("id")].isNull() && m_id_isValid;
|
||||
|
||||
|
||||
m_username_isValid = ::test_namespace::fromJsonValue(username, json[QString("username")]);
|
||||
m_username_isSet = !json[QString("username")].isNull() && m_username_isValid;
|
||||
|
||||
|
||||
m_first_name_isValid = ::test_namespace::fromJsonValue(first_name, json[QString("firstName")]);
|
||||
m_first_name_isSet = !json[QString("firstName")].isNull() && m_first_name_isValid;
|
||||
|
||||
|
||||
m_last_name_isValid = ::test_namespace::fromJsonValue(last_name, json[QString("lastName")]);
|
||||
m_last_name_isSet = !json[QString("lastName")].isNull() && m_last_name_isValid;
|
||||
|
||||
|
||||
m_email_isValid = ::test_namespace::fromJsonValue(email, json[QString("email")]);
|
||||
m_email_isSet = !json[QString("email")].isNull() && m_email_isValid;
|
||||
|
||||
|
||||
m_password_isValid = ::test_namespace::fromJsonValue(password, json[QString("password")]);
|
||||
m_password_isSet = !json[QString("password")].isNull() && m_password_isValid;
|
||||
|
||||
|
||||
m_phone_isValid = ::test_namespace::fromJsonValue(phone, json[QString("phone")]);
|
||||
m_phone_isSet = !json[QString("phone")].isNull() && m_phone_isValid;
|
||||
|
||||
|
||||
m_user_status_isValid = ::test_namespace::fromJsonValue(user_status, json[QString("userStatus")]);
|
||||
m_user_status_isSet = !json[QString("userStatus")].isNull() && m_user_status_isValid;
|
||||
|
||||
}
|
||||
|
||||
QString
|
||||
PFXUser::asJson () const {
|
||||
QString PFXUser::asJson() const {
|
||||
QJsonObject obj = this->asJsonObject();
|
||||
QJsonDocument doc(obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject
|
||||
PFXUser::asJsonObject() const {
|
||||
QJsonObject PFXUser::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
if (m_id_isSet) {
|
||||
obj.insert(QString("id"), ::test_namespace::toJsonValue(id));
|
||||
}
|
||||
if(m_username_isSet){
|
||||
if (m_username_isSet) {
|
||||
obj.insert(QString("username"), ::test_namespace::toJsonValue(username));
|
||||
}
|
||||
if(m_first_name_isSet){
|
||||
if (m_first_name_isSet) {
|
||||
obj.insert(QString("firstName"), ::test_namespace::toJsonValue(first_name));
|
||||
}
|
||||
if(m_last_name_isSet){
|
||||
if (m_last_name_isSet) {
|
||||
obj.insert(QString("lastName"), ::test_namespace::toJsonValue(last_name));
|
||||
}
|
||||
if(m_email_isSet){
|
||||
if (m_email_isSet) {
|
||||
obj.insert(QString("email"), ::test_namespace::toJsonValue(email));
|
||||
}
|
||||
if(m_password_isSet){
|
||||
if (m_password_isSet) {
|
||||
obj.insert(QString("password"), ::test_namespace::toJsonValue(password));
|
||||
}
|
||||
if(m_phone_isSet){
|
||||
if (m_phone_isSet) {
|
||||
obj.insert(QString("phone"), ::test_namespace::toJsonValue(phone));
|
||||
}
|
||||
if(m_user_status_isSet){
|
||||
if (m_user_status_isSet) {
|
||||
obj.insert(QString("userStatus"), ::test_namespace::toJsonValue(user_status));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
qint64
|
||||
PFXUser::getId() const {
|
||||
qint64 PFXUser::getId() const {
|
||||
return id;
|
||||
}
|
||||
void
|
||||
PFXUser::setId(const qint64 &id) {
|
||||
void PFXUser::setId(const qint64 &id) {
|
||||
this->id = id;
|
||||
this->m_id_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXUser::getUsername() const {
|
||||
QString PFXUser::getUsername() const {
|
||||
return username;
|
||||
}
|
||||
void
|
||||
PFXUser::setUsername(const QString &username) {
|
||||
void PFXUser::setUsername(const QString &username) {
|
||||
this->username = username;
|
||||
this->m_username_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXUser::getFirstName() const {
|
||||
QString PFXUser::getFirstName() const {
|
||||
return first_name;
|
||||
}
|
||||
void
|
||||
PFXUser::setFirstName(const QString &first_name) {
|
||||
void PFXUser::setFirstName(const QString &first_name) {
|
||||
this->first_name = first_name;
|
||||
this->m_first_name_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXUser::getLastName() const {
|
||||
QString PFXUser::getLastName() const {
|
||||
return last_name;
|
||||
}
|
||||
void
|
||||
PFXUser::setLastName(const QString &last_name) {
|
||||
void PFXUser::setLastName(const QString &last_name) {
|
||||
this->last_name = last_name;
|
||||
this->m_last_name_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXUser::getEmail() const {
|
||||
QString PFXUser::getEmail() const {
|
||||
return email;
|
||||
}
|
||||
void
|
||||
PFXUser::setEmail(const QString &email) {
|
||||
void PFXUser::setEmail(const QString &email) {
|
||||
this->email = email;
|
||||
this->m_email_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXUser::getPassword() const {
|
||||
QString PFXUser::getPassword() const {
|
||||
return password;
|
||||
}
|
||||
void
|
||||
PFXUser::setPassword(const QString &password) {
|
||||
void PFXUser::setPassword(const QString &password) {
|
||||
this->password = password;
|
||||
this->m_password_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PFXUser::getPhone() const {
|
||||
QString PFXUser::getPhone() const {
|
||||
return phone;
|
||||
}
|
||||
void
|
||||
PFXUser::setPhone(const QString &phone) {
|
||||
void PFXUser::setPhone(const QString &phone) {
|
||||
this->phone = phone;
|
||||
this->m_phone_isSet = true;
|
||||
}
|
||||
|
||||
|
||||
qint32
|
||||
PFXUser::getUserStatus() const {
|
||||
qint32 PFXUser::getUserStatus() const {
|
||||
return user_status;
|
||||
}
|
||||
void
|
||||
PFXUser::setUserStatus(const qint32 &user_status) {
|
||||
void PFXUser::setUserStatus(const qint32 &user_status) {
|
||||
this->user_status = user_status;
|
||||
this->m_user_status_isSet = true;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXUser::isSet() const {
|
||||
bool PFXUser::isSet() const {
|
||||
bool isObjectUpdated = false;
|
||||
do{
|
||||
if(m_id_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_username_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_first_name_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_last_name_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_email_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_password_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_phone_isSet){ isObjectUpdated = true; break;}
|
||||
|
||||
if(m_user_status_isSet){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
do {
|
||||
if (m_id_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_username_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_first_name_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_last_name_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_email_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_password_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_phone_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_user_status_isSet) {
|
||||
isObjectUpdated = true;
|
||||
break;
|
||||
}
|
||||
} while (false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
||||
bool
|
||||
PFXUser::isValid() const {
|
||||
bool PFXUser::isValid() const {
|
||||
// only required properties are required for the object to be considered valid
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -21,101 +20,88 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "PFXObject.h"
|
||||
#include "PFXEnum.h"
|
||||
|
||||
#include "PFXObject.h"
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXUser: public PFXObject {
|
||||
class PFXUser : public PFXObject {
|
||||
public:
|
||||
PFXUser();
|
||||
PFXUser(QString json);
|
||||
~PFXUser() override;
|
||||
|
||||
QString asJson () const override;
|
||||
QString asJson() const override;
|
||||
QJsonObject asJsonObject() const override;
|
||||
void fromJsonObject(QJsonObject json) override;
|
||||
void fromJson(QString jsonString) override;
|
||||
|
||||
|
||||
qint64 getId() const;
|
||||
void setId(const qint64 &id);
|
||||
|
||||
|
||||
QString getUsername() const;
|
||||
void setUsername(const QString &username);
|
||||
|
||||
|
||||
QString getFirstName() const;
|
||||
void setFirstName(const QString &first_name);
|
||||
|
||||
|
||||
QString getLastName() const;
|
||||
void setLastName(const QString &last_name);
|
||||
|
||||
|
||||
QString getEmail() const;
|
||||
void setEmail(const QString &email);
|
||||
|
||||
|
||||
QString getPassword() const;
|
||||
void setPassword(const QString &password);
|
||||
|
||||
|
||||
QString getPhone() const;
|
||||
void setPhone(const QString &phone);
|
||||
|
||||
|
||||
qint32 getUserStatus() const;
|
||||
void setUserStatus(const qint32 &user_status);
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
private:
|
||||
void initializeModel();
|
||||
|
||||
|
||||
qint64 id;
|
||||
bool m_id_isSet;
|
||||
bool m_id_isValid;
|
||||
|
||||
|
||||
QString username;
|
||||
bool m_username_isSet;
|
||||
bool m_username_isValid;
|
||||
|
||||
|
||||
QString first_name;
|
||||
bool m_first_name_isSet;
|
||||
bool m_first_name_isValid;
|
||||
|
||||
|
||||
QString last_name;
|
||||
bool m_last_name_isSet;
|
||||
bool m_last_name_isValid;
|
||||
|
||||
|
||||
QString email;
|
||||
bool m_email_isSet;
|
||||
bool m_email_isValid;
|
||||
|
||||
|
||||
QString password;
|
||||
bool m_password_isSet;
|
||||
bool m_password_isValid;
|
||||
|
||||
|
||||
QString phone;
|
||||
bool m_phone_isSet;
|
||||
bool m_phone_isValid;
|
||||
|
||||
|
||||
qint32 user_status;
|
||||
bool m_user_status_isSet;
|
||||
bool m_user_status_isValid;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
Q_DECLARE_METATYPE(test_namespace::PFXUser)
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -18,86 +17,75 @@
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
PFXUserApi::PFXUserApi(const QString &scheme, const QString &host, int port, const QString& basePath, const int timeOut) :
|
||||
_scheme(scheme),
|
||||
_host(host),
|
||||
_port(port),
|
||||
_basePath(basePath),
|
||||
_timeOut(timeOut) {
|
||||
}
|
||||
PFXUserApi::PFXUserApi(const QString &scheme, const QString &host, int port, const QString &basePath, const int timeOut)
|
||||
: _scheme(scheme),
|
||||
_host(host),
|
||||
_port(port),
|
||||
_basePath(basePath),
|
||||
_timeOut(timeOut) {}
|
||||
|
||||
PFXUserApi::~PFXUserApi() {
|
||||
}
|
||||
|
||||
void PFXUserApi::setScheme(const QString& scheme){
|
||||
void PFXUserApi::setScheme(const QString &scheme) {
|
||||
_scheme = scheme;
|
||||
}
|
||||
|
||||
void PFXUserApi::setHost(const QString& host){
|
||||
void PFXUserApi::setHost(const QString &host) {
|
||||
_host = host;
|
||||
}
|
||||
|
||||
void PFXUserApi::setPort(int port){
|
||||
void PFXUserApi::setPort(int port) {
|
||||
_port = port;
|
||||
}
|
||||
|
||||
void PFXUserApi::setBasePath(const QString& basePath){
|
||||
void PFXUserApi::setBasePath(const QString &basePath) {
|
||||
_basePath = basePath;
|
||||
}
|
||||
|
||||
void PFXUserApi::setTimeOut(const int timeOut){
|
||||
void PFXUserApi::setTimeOut(const int timeOut) {
|
||||
_timeOut = timeOut;
|
||||
}
|
||||
|
||||
void PFXUserApi::setWorkingDirectory(const QString& path){
|
||||
void PFXUserApi::setWorkingDirectory(const QString &path) {
|
||||
_workingDirectory = path;
|
||||
}
|
||||
|
||||
void PFXUserApi::addHeaders(const QString& key, const QString& value){
|
||||
void PFXUserApi::addHeaders(const QString &key, const QString &value) {
|
||||
defaultHeaders.insert(key, value);
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::createUser(const PFXUser& body) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user");
|
||||
|
||||
void PFXUserApi::createUser(const PFXUser &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user");
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXUserApi::createUserCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::createUserCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXUserApi::createUserCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -111,48 +99,38 @@ PFXUserApi::createUserCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::createUsersWithArrayInput(const QList<PFXUser>& body) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/createWithArray");
|
||||
|
||||
void PFXUserApi::createUsersWithArrayInput(const QList<PFXUser> &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/createWithArray");
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
|
||||
QByteArray bytes = doc.toJson();
|
||||
input.request_body.append(bytes);
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXUserApi::createUsersWithArrayInputCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithArrayInputCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::createUsersWithArrayInputCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXUserApi::createUsersWithArrayInputCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -166,48 +144,38 @@ PFXUserApi::createUsersWithArrayInputCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::createUsersWithListInput(const QList<PFXUser>& body) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/createWithList");
|
||||
|
||||
void PFXUserApi::createUsersWithListInput(const QList<PFXUser> &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/createWithList");
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
QJsonDocument doc(::test_namespace::toJsonValue(body).toArray());
|
||||
QByteArray bytes = doc.toJson();
|
||||
input.request_body.append(bytes);
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXUserApi::createUsersWithListInputCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::createUsersWithListInputCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::createUsersWithListInputCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXUserApi::createUsersWithListInputCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -221,47 +189,37 @@ PFXUserApi::createUsersWithListInputCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::deleteUser(const QString& username) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/{username}");
|
||||
void PFXUserApi::deleteUser(const QString &username) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/{username}");
|
||||
QString usernamePathParam("{");
|
||||
usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "DELETE");
|
||||
|
||||
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXUserApi::deleteUserCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::deleteUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::deleteUserCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXUserApi::deleteUserCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -275,47 +233,37 @@ PFXUserApi::deleteUserCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::getUserByName(const QString& username) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/{username}");
|
||||
void PFXUserApi::getUserByName(const QString &username) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/{username}");
|
||||
QString usernamePathParam("{");
|
||||
usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXUserApi::getUserByNameCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::getUserByNameCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::getUserByNameCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXUserApi::getUserByNameCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
PFXUser output(QString(worker->response));
|
||||
@@ -330,60 +278,46 @@ PFXUserApi::getUserByNameCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::loginUser(const QString& username, const QString& password) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/login");
|
||||
|
||||
void PFXUserApi::loginUser(const QString &username, const QString &password) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/login");
|
||||
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append(QUrl::toPercentEncoding("username"))
|
||||
.append("=")
|
||||
.append(QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
|
||||
|
||||
fullPath.append("?");
|
||||
fullPath.append(QUrl::toPercentEncoding("username")).append("=").append(QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
|
||||
|
||||
if (fullPath.indexOf("?") > 0)
|
||||
fullPath.append("&");
|
||||
fullPath.append("&");
|
||||
else
|
||||
fullPath.append("?");
|
||||
fullPath.append(QUrl::toPercentEncoding("password"))
|
||||
.append("=")
|
||||
.append(QUrl::toPercentEncoding(::test_namespace::toStringValue(password)));
|
||||
|
||||
fullPath.append("?");
|
||||
fullPath.append(QUrl::toPercentEncoding("password")).append("=").append(QUrl::toPercentEncoding(::test_namespace::toStringValue(password)));
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXUserApi::loginUserCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::loginUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::loginUserCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXUserApi::loginUserCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
QString output;
|
||||
@@ -399,44 +333,34 @@ PFXUserApi::loginUserCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::logoutUser() {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/logout");
|
||||
|
||||
void PFXUserApi::logoutUser() {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/logout");
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXUserApi::logoutUserCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::logoutUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::logoutUserCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXUserApi::logoutUserCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -450,50 +374,40 @@ PFXUserApi::logoutUserCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::updateUser(const QString& username, const PFXUser& body) {
|
||||
QString fullPath = QString("%0://%1%2%3%4")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/{username}");
|
||||
void PFXUserApi::updateUser(const QString &username, const PFXUser &body) {
|
||||
QString fullPath = QString("%1://%2%3%4%5")
|
||||
.arg(_scheme)
|
||||
.arg(_host)
|
||||
.arg(_port ? ":" + QString::number(_port) : "")
|
||||
.arg(_basePath)
|
||||
.arg("/user/{username}");
|
||||
QString usernamePathParam("{");
|
||||
usernamePathParam.append("username").append("}");
|
||||
fullPath.replace(usernamePathParam, QUrl::toPercentEncoding(::test_namespace::toStringValue(username)));
|
||||
|
||||
|
||||
PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this);
|
||||
worker->setTimeOut(_timeOut);
|
||||
worker->setWorkingDirectory(_workingDirectory);
|
||||
PFXHttpRequestInput input(fullPath, "PUT");
|
||||
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
foreach (QString key, this->defaultHeaders.keys()) { input.headers.insert(key, this->defaultHeaders.value(key)); }
|
||||
|
||||
connect(worker,
|
||||
&PFXHttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&PFXUserApi::updateUserCallback);
|
||||
connect(worker, &PFXHttpRequestWorker::on_execution_finished, this, &PFXUserApi::updateUserCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
PFXUserApi::updateUserCallback(PFXHttpRequestWorker * worker) {
|
||||
void PFXUserApi::updateUserCallback(PFXHttpRequestWorker *worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
worker->deleteLater();
|
||||
@@ -507,5 +421,4 @@ PFXUserApi::updateUserCallback(PFXHttpRequestWorker * worker) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -23,30 +22,30 @@
|
||||
|
||||
namespace test_namespace {
|
||||
|
||||
class PFXUserApi: public QObject {
|
||||
class PFXUserApi : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PFXUserApi(const QString &scheme = "http", const QString &host = "petstore.swagger.io", int port = 0, const QString& basePath = "/v2", const int timeOut = 0);
|
||||
PFXUserApi(const QString &scheme = "http", const QString &host = "petstore.swagger.io", int port = 0, const QString &basePath = "/v2", const int timeOut = 0);
|
||||
~PFXUserApi();
|
||||
|
||||
void setScheme(const QString &scheme);
|
||||
void setHost(const QString &host);
|
||||
void setPort(int port);
|
||||
void setBasePath(const QString& basePath);
|
||||
void setBasePath(const QString &basePath);
|
||||
void setTimeOut(const int timeOut);
|
||||
void setWorkingDirectory(const QString& path);
|
||||
void addHeaders(const QString& key, const QString& value);
|
||||
void setWorkingDirectory(const QString &path);
|
||||
void addHeaders(const QString &key, const QString &value);
|
||||
|
||||
void createUser(const PFXUser& body);
|
||||
void createUsersWithArrayInput(const QList<PFXUser>& body);
|
||||
void createUsersWithListInput(const QList<PFXUser>& body);
|
||||
void deleteUser(const QString& username);
|
||||
void getUserByName(const QString& username);
|
||||
void loginUser(const QString& username, const QString& password);
|
||||
void createUser(const PFXUser &body);
|
||||
void createUsersWithArrayInput(const QList<PFXUser> &body);
|
||||
void createUsersWithListInput(const QList<PFXUser> &body);
|
||||
void deleteUser(const QString &username);
|
||||
void getUserByName(const QString &username);
|
||||
void loginUser(const QString &username, const QString &password);
|
||||
void logoutUser();
|
||||
void updateUser(const QString& username, const PFXUser& body);
|
||||
|
||||
void updateUser(const QString &username, const PFXUser &body);
|
||||
|
||||
private:
|
||||
QString _scheme, _host;
|
||||
int _port;
|
||||
@@ -54,16 +53,18 @@ private:
|
||||
int _timeOut;
|
||||
QString _workingDirectory;
|
||||
QMap<QString, QString> defaultHeaders;
|
||||
void createUserCallback (PFXHttpRequestWorker * worker);
|
||||
void createUsersWithArrayInputCallback (PFXHttpRequestWorker * worker);
|
||||
void createUsersWithListInputCallback (PFXHttpRequestWorker * worker);
|
||||
void deleteUserCallback (PFXHttpRequestWorker * worker);
|
||||
void getUserByNameCallback (PFXHttpRequestWorker * worker);
|
||||
void loginUserCallback (PFXHttpRequestWorker * worker);
|
||||
void logoutUserCallback (PFXHttpRequestWorker * worker);
|
||||
void updateUserCallback (PFXHttpRequestWorker * worker);
|
||||
|
||||
|
||||
void createUserCallback(PFXHttpRequestWorker *worker);
|
||||
void createUsersWithArrayInputCallback(PFXHttpRequestWorker *worker);
|
||||
void createUsersWithListInputCallback(PFXHttpRequestWorker *worker);
|
||||
void deleteUserCallback(PFXHttpRequestWorker *worker);
|
||||
void getUserByNameCallback(PFXHttpRequestWorker *worker);
|
||||
void loginUserCallback(PFXHttpRequestWorker *worker);
|
||||
void logoutUserCallback(PFXHttpRequestWorker *worker);
|
||||
void updateUserCallback(PFXHttpRequestWorker *worker);
|
||||
|
||||
signals:
|
||||
|
||||
void createUserSignal();
|
||||
void createUsersWithArrayInputSignal();
|
||||
void createUsersWithListInputSignal();
|
||||
@@ -72,16 +73,16 @@ signals:
|
||||
void loginUserSignal(QString summary);
|
||||
void logoutUserSignal();
|
||||
void updateUserSignal();
|
||||
|
||||
void createUserSignalFull(PFXHttpRequestWorker* worker);
|
||||
void createUsersWithArrayInputSignalFull(PFXHttpRequestWorker* worker);
|
||||
void createUsersWithListInputSignalFull(PFXHttpRequestWorker* worker);
|
||||
void deleteUserSignalFull(PFXHttpRequestWorker* worker);
|
||||
void getUserByNameSignalFull(PFXHttpRequestWorker* worker, PFXUser summary);
|
||||
void loginUserSignalFull(PFXHttpRequestWorker* worker, QString summary);
|
||||
void logoutUserSignalFull(PFXHttpRequestWorker* worker);
|
||||
void updateUserSignalFull(PFXHttpRequestWorker* worker);
|
||||
|
||||
|
||||
void createUserSignalFull(PFXHttpRequestWorker *worker);
|
||||
void createUsersWithArrayInputSignalFull(PFXHttpRequestWorker *worker);
|
||||
void createUsersWithListInputSignalFull(PFXHttpRequestWorker *worker);
|
||||
void deleteUserSignalFull(PFXHttpRequestWorker *worker);
|
||||
void getUserByNameSignalFull(PFXHttpRequestWorker *worker, PFXUser summary);
|
||||
void loginUserSignalFull(PFXHttpRequestWorker *worker, QString summary);
|
||||
void logoutUserSignalFull(PFXHttpRequestWorker *worker);
|
||||
void updateUserSignalFull(PFXHttpRequestWorker *worker);
|
||||
|
||||
void createUserSignalE(QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void createUsersWithArrayInputSignalE(QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void createUsersWithListInputSignalE(QNetworkReply::NetworkError error_type, QString error_str);
|
||||
@@ -90,17 +91,16 @@ signals:
|
||||
void loginUserSignalE(QString summary, 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 createUserSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void createUsersWithArrayInputSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void createUsersWithListInputSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void deleteUserSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void getUserByNameSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void loginUserSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void logoutUserSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void updateUserSignalEFull(PFXHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
|
||||
|
||||
void createUserSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void createUsersWithArrayInputSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void createUsersWithListInputSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void deleteUserSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void getUserByNameSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void loginUserSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void logoutUserSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
void updateUserSignalEFull(PFXHttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace test_namespace
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user