forked from loafle/openapi-generator-original
[C++] [Qt5] Add initial version of File upload and download for Qt5 client (#3853)
* Add initial version of File upload and download for Qt5 client * Update after reviews * Remove unused header
This commit is contained in:
@@ -95,7 +95,7 @@ void OAIPetApiHandler::updatePetWithForm(qint64 pet_id, QString name, QString st
|
||||
reqObj->updatePetWithFormResponse();
|
||||
}
|
||||
}
|
||||
void OAIPetApiHandler::uploadFile(qint64 pet_id, QString additional_metadata, QIODevice* file) {
|
||||
void OAIPetApiHandler::uploadFile(qint64 pet_id, QString additional_metadata, OAIHttpFileElement file) {
|
||||
Q_UNUSED(pet_id);
|
||||
Q_UNUSED(additional_metadata);
|
||||
Q_UNUSED(file);
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#include <QObject>
|
||||
|
||||
#include "OAIApiResponse.h"
|
||||
#include "OAIHttpFileElement.h"
|
||||
#include "OAIPet.h"
|
||||
#include <QIODevice>
|
||||
#include <QString>
|
||||
|
||||
namespace OpenAPI {
|
||||
@@ -39,7 +39,7 @@ public slots:
|
||||
virtual void getPetById(qint64 pet_id);
|
||||
virtual void updatePet(OAIPet body);
|
||||
virtual void updatePetWithForm(qint64 pet_id, QString name, QString status);
|
||||
virtual void uploadFile(qint64 pet_id, QString additional_metadata, QIODevice* file);
|
||||
virtual void uploadFile(qint64 pet_id, QString additional_metadata, OAIHttpFileElement file);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
|
||||
#include "OAIApiResponse.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIApiResponse::OAIApiResponse(QString json) {
|
||||
@@ -81,13 +81,13 @@ OAIApiResponse::asJson () const {
|
||||
QJsonObject
|
||||
OAIApiResponse::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_code_isSet){
|
||||
if(m_code_isSet){
|
||||
obj.insert(QString("code"), ::OpenAPI::toJsonValue(code));
|
||||
}
|
||||
if(m_type_isSet){
|
||||
if(m_type_isSet){
|
||||
obj.insert(QString("type"), ::OpenAPI::toJsonValue(type));
|
||||
}
|
||||
if(m_message_isSet){
|
||||
if(m_message_isSet){
|
||||
obj.insert(QString("message"), ::OpenAPI::toJsonValue(message));
|
||||
}
|
||||
return obj;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "OAIObject.h"
|
||||
#include "OAIEnum.h"
|
||||
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIApiResponse: public OAIObject {
|
||||
@@ -53,7 +54,7 @@ public:
|
||||
void setMessage(const QString &message);
|
||||
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
|
||||
#include "OAICategory.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAICategory::OAICategory(QString json) {
|
||||
@@ -75,10 +75,10 @@ OAICategory::asJson () const {
|
||||
QJsonObject
|
||||
OAICategory::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
if(m_id_isSet){
|
||||
obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
|
||||
}
|
||||
if(m_name_isSet){
|
||||
if(m_name_isSet){
|
||||
obj.insert(QString("name"), ::OpenAPI::toJsonValue(name));
|
||||
}
|
||||
return obj;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "OAIObject.h"
|
||||
#include "OAIEnum.h"
|
||||
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAICategory: public OAIObject {
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
void setName(const QString &name);
|
||||
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class OAIEnum {
|
||||
OAIEnum() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
OAIEnum(QString jsonString) {
|
||||
fromJson(jsonString);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class OAIEnum {
|
||||
return true;
|
||||
}
|
||||
private :
|
||||
QString jstr;
|
||||
QString jstr;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -64,11 +64,23 @@ toStringValue(const double &value){
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const OAIObject &value){
|
||||
return value.asJson();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
toStringValue(const OAIEnum &value){
|
||||
return value.asJson();
|
||||
}
|
||||
|
||||
QString
|
||||
toStringValue(const OAIHttpFileElement &value){
|
||||
return value.asJson();
|
||||
}
|
||||
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const QString &value){
|
||||
return QJsonValue(value);
|
||||
@@ -124,6 +136,12 @@ toJsonValue(const OAIEnum &value){
|
||||
return value.asJsonValue();
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
toJsonValue(const OAIHttpFileElement &value){
|
||||
return value.asJsonValue();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, QString &value){
|
||||
value.clear();
|
||||
@@ -218,6 +236,11 @@ fromStringValue(const QString &inStr, OAIEnum &value){
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
fromStringValue(const QString &inStr, OAIHttpFileElement &value){
|
||||
return value.fromStringValue(inStr);
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(QString &value, const QJsonValue &jval){
|
||||
bool ok = true;
|
||||
@@ -229,7 +252,7 @@ fromJsonValue(QString &value, const QJsonValue &jval){
|
||||
} else if(jval.isDouble()){
|
||||
value = QString::number(jval.toDouble());
|
||||
} else {
|
||||
ok = false;
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
ok = false;
|
||||
@@ -239,7 +262,7 @@ fromJsonValue(QString &value, const QJsonValue &jval){
|
||||
|
||||
bool
|
||||
fromJsonValue(QDateTime &value, const QJsonValue &jval){
|
||||
bool ok = true;
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && jval.isString()){
|
||||
value = QDateTime::fromString(jval.toString(), Qt::ISODate);
|
||||
ok = value.isValid();
|
||||
@@ -263,7 +286,7 @@ fromJsonValue(QByteArray &value, const QJsonValue &jval){
|
||||
|
||||
bool
|
||||
fromJsonValue(QDate &value, const QJsonValue &jval){
|
||||
bool ok = true;
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && jval.isString()){
|
||||
value = QDate::fromString(jval.toString(), Qt::ISODate);
|
||||
ok = value.isValid();
|
||||
@@ -275,7 +298,7 @@ fromJsonValue(QDate &value, const QJsonValue &jval){
|
||||
|
||||
bool
|
||||
fromJsonValue(qint32 &value, const QJsonValue &jval){
|
||||
bool ok = true;
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()){
|
||||
value = jval.toInt();
|
||||
} else {
|
||||
@@ -286,7 +309,7 @@ fromJsonValue(qint32 &value, const QJsonValue &jval){
|
||||
|
||||
bool
|
||||
fromJsonValue(qint64 &value, const QJsonValue &jval){
|
||||
bool ok = true;
|
||||
bool ok = true;
|
||||
if(!jval.isUndefined() && !jval.isNull() && !jval.isObject() && !jval.isArray()){
|
||||
value = jval.toVariant().toLongLong();
|
||||
} else {
|
||||
@@ -297,7 +320,7 @@ fromJsonValue(qint64 &value, const QJsonValue &jval){
|
||||
|
||||
bool
|
||||
fromJsonValue(bool &value, const QJsonValue &jval){
|
||||
bool ok = true;
|
||||
bool ok = true;
|
||||
if(jval.isBool()){
|
||||
value = jval.toBool();
|
||||
} else {
|
||||
@@ -308,7 +331,7 @@ fromJsonValue(bool &value, const QJsonValue &jval){
|
||||
|
||||
bool
|
||||
fromJsonValue(float &value, const QJsonValue &jval){
|
||||
bool ok = true;
|
||||
bool ok = true;
|
||||
if(jval.isDouble()){
|
||||
value = static_cast<float>(jval.toDouble());
|
||||
} else {
|
||||
@@ -319,7 +342,7 @@ fromJsonValue(float &value, const QJsonValue &jval){
|
||||
|
||||
bool
|
||||
fromJsonValue(double &value, const QJsonValue &jval){
|
||||
bool ok = true;
|
||||
bool ok = true;
|
||||
if(jval.isDouble()){
|
||||
value = jval.toDouble();
|
||||
} else {
|
||||
@@ -330,7 +353,7 @@ fromJsonValue(double &value, const QJsonValue &jval){
|
||||
|
||||
bool
|
||||
fromJsonValue(OAIObject &value, const QJsonValue &jval){
|
||||
bool ok = true;
|
||||
bool ok = true;
|
||||
if(jval.isObject()){
|
||||
value.fromJsonObject(jval.toObject());
|
||||
ok = value.isValid();
|
||||
@@ -346,4 +369,9 @@ fromJsonValue(OAIEnum &value, const QJsonValue &jval){
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
fromJsonValue(OAIHttpFileElement &value, const QJsonValue &jval){
|
||||
return value.fromJsonValue(jval);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
#include <QByteArray>
|
||||
#include <QDate>
|
||||
#include <QVariant>
|
||||
|
||||
#include "OAIObject.h"
|
||||
#include "OAIEnum.h"
|
||||
#include "OAIHttpFileElement.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
@@ -36,7 +38,9 @@ namespace OpenAPI {
|
||||
QString toStringValue(const bool &value);
|
||||
QString toStringValue(const float &value);
|
||||
QString toStringValue(const double &value);
|
||||
QString toStringValue(const OAIEnum &value);
|
||||
QString toStringValue(const OAIObject &value);
|
||||
QString toStringValue(const OAIEnum &value);
|
||||
QString toStringValue(const OAIHttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
QString toStringValue(const QList<T> &val) {
|
||||
@@ -61,6 +65,7 @@ namespace OpenAPI {
|
||||
QJsonValue toJsonValue(const double &value);
|
||||
QJsonValue toJsonValue(const OAIObject &value);
|
||||
QJsonValue toJsonValue(const OAIEnum &value);
|
||||
QJsonValue toJsonValue(const OAIHttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
QJsonValue toJsonValue(const QList<T> &val) {
|
||||
@@ -89,7 +94,9 @@ namespace OpenAPI {
|
||||
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, OAIEnum &value);
|
||||
bool fromStringValue(const QString &inStr, OAIObject &value);
|
||||
bool fromStringValue(const QString &inStr, OAIEnum &value);
|
||||
bool fromStringValue(const QString &inStr, OAIHttpFileElement &value);
|
||||
|
||||
template <typename T>
|
||||
bool fromStringValue(const QList<QString> &inStr, QList<T> &val) {
|
||||
@@ -124,6 +131,7 @@ namespace OpenAPI {
|
||||
bool fromJsonValue(double &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(OAIObject &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(OAIEnum &value, const QJsonValue &jval);
|
||||
bool fromJsonValue(OAIHttpFileElement &value, const QJsonValue &jval);
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
|
||||
@@ -138,7 +146,7 @@ namespace OpenAPI {
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool fromJsonValue(QMap<QString, T> &val, const QJsonValue &jval) {
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* 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>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "OAIHttpFileElement.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
void
|
||||
OAIHttpFileElement::setMimeType(const QString &mime){
|
||||
mime_type = mime;
|
||||
}
|
||||
|
||||
void
|
||||
OAIHttpFileElement::setFileName(const QString &name){
|
||||
local_filename = name;
|
||||
}
|
||||
|
||||
void
|
||||
OAIHttpFileElement::setVariableName(const QString &name){
|
||||
variable_name = name;
|
||||
}
|
||||
|
||||
void
|
||||
OAIHttpFileElement::setRequestFileName(const QString &name){
|
||||
request_filename = name;
|
||||
}
|
||||
|
||||
bool
|
||||
OAIHttpFileElement::isSet() const {
|
||||
return !local_filename.isEmpty() || !request_filename.isEmpty();
|
||||
}
|
||||
|
||||
QString
|
||||
OAIHttpFileElement::asJson() const{
|
||||
QFile file(local_filename);
|
||||
QByteArray bArray;
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
result = file.open(QIODevice::ReadOnly);
|
||||
bArray = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
if(!result) {
|
||||
qDebug() << "Error opening file " << local_filename;
|
||||
}
|
||||
return QString(bArray);
|
||||
}
|
||||
|
||||
QJsonValue
|
||||
OAIHttpFileElement::asJsonValue() const{
|
||||
QFile file(local_filename);
|
||||
QByteArray bArray;
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
result = file.open(QIODevice::ReadOnly);
|
||||
bArray = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
if(!result) {
|
||||
qDebug() << "Error opening file " << local_filename;
|
||||
}
|
||||
return QJsonDocument::fromBinaryData(bArray.data()).object();
|
||||
}
|
||||
|
||||
bool
|
||||
OAIHttpFileElement::fromStringValue(const QString &instr){
|
||||
QFile file(local_filename);
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
result = file.open(QIODevice::WriteOnly);
|
||||
file.write(instr.toUtf8());
|
||||
file.close();
|
||||
if(!result) {
|
||||
qDebug() << "Error creating file " << local_filename;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
OAIHttpFileElement::fromJsonValue(const QJsonValue &jval) {
|
||||
QFile file(local_filename);
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
file.remove();
|
||||
}
|
||||
result = file.open(QIODevice::WriteOnly);
|
||||
file.write(QJsonDocument(jval.toObject()).toBinaryData());
|
||||
file.close();
|
||||
if(!result) {
|
||||
qDebug() << "Error creating file " << local_filename;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QByteArray
|
||||
OAIHttpFileElement::asByteArray() const {
|
||||
QFile file(local_filename);
|
||||
QByteArray bArray;
|
||||
bool result = false;
|
||||
if(file.exists()) {
|
||||
result = file.open(QIODevice::ReadOnly);
|
||||
bArray = file.readAll();
|
||||
file.close();
|
||||
}
|
||||
if(!result) {
|
||||
qDebug() << "Error opening file " << local_filename;
|
||||
}
|
||||
return bArray;
|
||||
}
|
||||
|
||||
bool
|
||||
OAIHttpFileElement::fromByteArray(const QByteArray& bytes){
|
||||
QFile file(local_filename);
|
||||
bool result = false;
|
||||
if(file.exists()){
|
||||
file.remove();
|
||||
}
|
||||
result = file.open(QIODevice::WriteOnly);
|
||||
file.write(bytes);
|
||||
file.close();
|
||||
if(!result) {
|
||||
qDebug() << "Error creating file " << local_filename;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
OAIHttpFileElement::saveToFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime, const QByteArray& bytes){
|
||||
setMimeType(mime);
|
||||
setFileName(localFName);
|
||||
setVariableName(varName);
|
||||
setRequestFileName(reqFname);
|
||||
return fromByteArray(bytes);
|
||||
}
|
||||
|
||||
QByteArray
|
||||
OAIHttpFileElement::loadFromFile(const QString &varName, const QString &localFName, const QString &reqFname, const QString &mime){
|
||||
setMimeType(mime);
|
||||
setFileName(localFName);
|
||||
setVariableName(varName);
|
||||
setRequestFileName(reqFname);
|
||||
return asByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OAI_HTTP_FILE_ELEMENT_H
|
||||
#define OAI_HTTP_FILE_ELEMENT_H
|
||||
|
||||
#include <QJsonValue>
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIHttpFileElement {
|
||||
|
||||
public:
|
||||
QString variable_name;
|
||||
QString local_filename;
|
||||
QString request_filename;
|
||||
QString mime_type;
|
||||
void setMimeType(const QString &mime);
|
||||
void setFileName(const QString &name);
|
||||
void setVariableName(const QString &name);
|
||||
void setRequestFileName(const QString &name);
|
||||
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);
|
||||
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);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(OpenAPI::OAIHttpFileElement)
|
||||
|
||||
#endif // OAI_HTTP_FILE_ELEMENT_H
|
||||
@@ -24,7 +24,7 @@ class OAIObject {
|
||||
OAIObject() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
OAIObject(QString jsonString) {
|
||||
fromJson(jsonString);
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
|
||||
#include "OAIOrder.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIOrder::OAIOrder(QString json) {
|
||||
@@ -99,22 +99,22 @@ OAIOrder::asJson () const {
|
||||
QJsonObject
|
||||
OAIOrder::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
if(m_id_isSet){
|
||||
obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
|
||||
}
|
||||
if(m_pet_id_isSet){
|
||||
if(m_pet_id_isSet){
|
||||
obj.insert(QString("petId"), ::OpenAPI::toJsonValue(pet_id));
|
||||
}
|
||||
if(m_quantity_isSet){
|
||||
if(m_quantity_isSet){
|
||||
obj.insert(QString("quantity"), ::OpenAPI::toJsonValue(quantity));
|
||||
}
|
||||
if(m_ship_date_isSet){
|
||||
if(m_ship_date_isSet){
|
||||
obj.insert(QString("shipDate"), ::OpenAPI::toJsonValue(ship_date));
|
||||
}
|
||||
if(m_status_isSet){
|
||||
if(m_status_isSet){
|
||||
obj.insert(QString("status"), ::OpenAPI::toJsonValue(status));
|
||||
}
|
||||
if(m_complete_isSet){
|
||||
if(m_complete_isSet){
|
||||
obj.insert(QString("complete"), ::OpenAPI::toJsonValue(complete));
|
||||
}
|
||||
return obj;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "OAIObject.h"
|
||||
#include "OAIEnum.h"
|
||||
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIOrder: public OAIObject {
|
||||
@@ -66,7 +67,7 @@ public:
|
||||
void setComplete(const bool &complete);
|
||||
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
|
||||
#include "OAIPet.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIPet::OAIPet(QString json) {
|
||||
@@ -99,24 +99,24 @@ OAIPet::asJson () const {
|
||||
QJsonObject
|
||||
OAIPet::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
if(m_id_isSet){
|
||||
obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
|
||||
}
|
||||
if(category.isSet()){
|
||||
if(category.isSet()){
|
||||
obj.insert(QString("category"), ::OpenAPI::toJsonValue(category));
|
||||
}
|
||||
if(m_name_isSet){
|
||||
if(m_name_isSet){
|
||||
obj.insert(QString("name"), ::OpenAPI::toJsonValue(name));
|
||||
}
|
||||
|
||||
|
||||
if(photo_urls.size() > 0){
|
||||
obj.insert(QString("photoUrls"), ::OpenAPI::toJsonValue(photo_urls));
|
||||
}
|
||||
|
||||
|
||||
if(tags.size() > 0){
|
||||
obj.insert(QString("tags"), ::OpenAPI::toJsonValue(tags));
|
||||
}
|
||||
if(m_status_isSet){
|
||||
if(m_status_isSet){
|
||||
obj.insert(QString("status"), ::OpenAPI::toJsonValue(status));
|
||||
}
|
||||
return obj;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "OAIObject.h"
|
||||
#include "OAIEnum.h"
|
||||
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIPet: public OAIObject {
|
||||
@@ -68,7 +69,7 @@ public:
|
||||
void setStatus(const QString &status);
|
||||
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
|
||||
#include "OAITag.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAITag::OAITag(QString json) {
|
||||
@@ -75,10 +75,10 @@ OAITag::asJson () const {
|
||||
QJsonObject
|
||||
OAITag::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
if(m_id_isSet){
|
||||
obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
|
||||
}
|
||||
if(m_name_isSet){
|
||||
if(m_name_isSet){
|
||||
obj.insert(QString("name"), ::OpenAPI::toJsonValue(name));
|
||||
}
|
||||
return obj;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "OAIObject.h"
|
||||
#include "OAIEnum.h"
|
||||
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAITag: public OAIObject {
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
void setName(const QString &name);
|
||||
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
|
||||
#include "OAIUser.h"
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
#include "OAIHelpers.h"
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
OAIUser::OAIUser(QString json) {
|
||||
@@ -111,28 +111,28 @@ OAIUser::asJson () const {
|
||||
QJsonObject
|
||||
OAIUser::asJsonObject() const {
|
||||
QJsonObject obj;
|
||||
if(m_id_isSet){
|
||||
if(m_id_isSet){
|
||||
obj.insert(QString("id"), ::OpenAPI::toJsonValue(id));
|
||||
}
|
||||
if(m_username_isSet){
|
||||
if(m_username_isSet){
|
||||
obj.insert(QString("username"), ::OpenAPI::toJsonValue(username));
|
||||
}
|
||||
if(m_first_name_isSet){
|
||||
if(m_first_name_isSet){
|
||||
obj.insert(QString("firstName"), ::OpenAPI::toJsonValue(first_name));
|
||||
}
|
||||
if(m_last_name_isSet){
|
||||
if(m_last_name_isSet){
|
||||
obj.insert(QString("lastName"), ::OpenAPI::toJsonValue(last_name));
|
||||
}
|
||||
if(m_email_isSet){
|
||||
if(m_email_isSet){
|
||||
obj.insert(QString("email"), ::OpenAPI::toJsonValue(email));
|
||||
}
|
||||
if(m_password_isSet){
|
||||
if(m_password_isSet){
|
||||
obj.insert(QString("password"), ::OpenAPI::toJsonValue(password));
|
||||
}
|
||||
if(m_phone_isSet){
|
||||
if(m_phone_isSet){
|
||||
obj.insert(QString("phone"), ::OpenAPI::toJsonValue(phone));
|
||||
}
|
||||
if(m_user_status_isSet){
|
||||
if(m_user_status_isSet){
|
||||
obj.insert(QString("userStatus"), ::OpenAPI::toJsonValue(user_status));
|
||||
}
|
||||
return obj;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "OAIObject.h"
|
||||
#include "OAIEnum.h"
|
||||
|
||||
|
||||
namespace OpenAPI {
|
||||
|
||||
class OAIUser: public OAIObject {
|
||||
@@ -73,7 +74,7 @@ public:
|
||||
void setUserStatus(const qint32 &user_status);
|
||||
|
||||
|
||||
|
||||
|
||||
virtual bool isSet() const override;
|
||||
virtual bool isValid() const override;
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ void OAIPetApiRequest::uploadFileRequest(const QString& pet_idstr){
|
||||
fromStringValue(pet_idstr, pet_id);
|
||||
|
||||
QString additional_metadata;
|
||||
QIODevice* file;
|
||||
OAIHttpFileElement file;
|
||||
|
||||
emit uploadFile(pet_id, additional_metadata, file);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
#include <qhttpengine/socket.h>
|
||||
#include "OAIApiResponse.h"
|
||||
#include "OAIHttpFileElement.h"
|
||||
#include "OAIPet.h"
|
||||
#include <QIODevice>
|
||||
#include <QString>
|
||||
#include "OAIPetApiHandler.h"
|
||||
|
||||
@@ -84,7 +84,7 @@ signals:
|
||||
void getPetById(qint64 pet_id);
|
||||
void updatePet(OAIPet body);
|
||||
void updatePetWithForm(qint64 pet_id, QString name, QString status);
|
||||
void uploadFile(qint64 pet_id, QString additional_metadata, QIODevice* file);
|
||||
void uploadFile(qint64 pet_id, QString additional_metadata, OAIHttpFileElement file);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user