Skip to content

Commit

Permalink
[qt] update Qt client
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinDelille committed Mar 30, 2018
1 parent 2740489 commit ee2eb74
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 122 deletions.
2 changes: 1 addition & 1 deletion samples/client/petstore/qt5cpp/.swagger-codegen/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.0-SNAPSHOT
3.0.0-SNAPSHOT
5 changes: 4 additions & 1 deletion samples/client/petstore/qt5cpp/client/SWGOrder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ SWGOrder::asJsonObject() {
if(m_quantity_isSet){
obj.insert("quantity", QJsonValue(quantity));
}
if(ship_date != nullptr && *ship_date != QString("")){
toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
}
if(ship_date != nullptr) {
toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
}
Expand Down Expand Up @@ -192,7 +195,7 @@ SWGOrder::isSet(){
if(m_id_isSet){ isObjectUpdated = true; break;}
if(m_pet_id_isSet){ isObjectUpdated = true; break;}
if(m_quantity_isSet){ isObjectUpdated = true; break;}

if(ship_date != nullptr && *ship_date != QString("")){ isObjectUpdated = true; break;}
if(status != nullptr && *status != QString("")){ isObjectUpdated = true; break;}
if(m_complete_isSet){ isObjectUpdated = true; break;}
}while(false);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/qt5cpp/client/SWGPet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void
SWGPet::init() {
id = 0L;
m_id_isSet = false;
category = new SWGCategory();
category = new SWG#/components/schemas/Category();
m_category_isSet = false;
name = new QString("");
m_name_isSet = false;
Expand Down
114 changes: 23 additions & 91 deletions samples/client/petstore/qt5cpp/client/SWGPetApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SWGPetApi::SWGPetApi(QString host, QString basePath) {
}

void
SWGPetApi::addPet(SWGPet& body) {
SWGPetApi::addPet(SWGPet& pet) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet");

Expand All @@ -40,7 +40,7 @@ SWGPetApi::addPet(SWGPet& body) {



QString output = body.asJson();
QString output = pet.asJson();
input.request_body.append(output);


Expand Down Expand Up @@ -81,7 +81,7 @@ SWGPetApi::addPetCallback(SWGHttpRequestWorker * worker) {
}

void
SWGPetApi::deletePet(qint64 pet_id, QString* api_key) {
SWGPetApi::deletePet(qint32 pet_id, QString* api_key) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");

Expand Down Expand Up @@ -140,47 +140,13 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) {
fullPath.append(this->host).append(this->basePath).append("/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(stringValue(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(stringValue(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(stringValue(t));
}
}
}
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append(QUrl::toPercentEncoding("status"))
.append("=")
.append(QUrl::toPercentEncoding(stringValue(status)));


SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
Expand Down Expand Up @@ -245,47 +211,13 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) {
fullPath.append(this->host).append(this->basePath).append("/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(stringValue(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(stringValue(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(stringValue(t));
}
}
}
if (fullPath.indexOf("?") > 0)
fullPath.append("&");
else
fullPath.append("?");
fullPath.append(QUrl::toPercentEncoding("tags"))
.append("=")
.append(QUrl::toPercentEncoding(stringValue(tags)));


SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
Expand Down Expand Up @@ -345,7 +277,7 @@ SWGPetApi::findPetsByTagsCallback(SWGHttpRequestWorker * worker) {
}

void
SWGPetApi::getPetById(qint64 pet_id) {
SWGPetApi::getPetById(qint32 pet_id) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");

Expand Down Expand Up @@ -399,7 +331,7 @@ SWGPetApi::getPetByIdCallback(SWGHttpRequestWorker * worker) {
}

void
SWGPetApi::updatePet(SWGPet& body) {
SWGPetApi::updatePet(SWGPet& pet) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet");

Expand All @@ -410,7 +342,7 @@ SWGPetApi::updatePet(SWGPet& body) {



QString output = body.asJson();
QString output = pet.asJson();
input.request_body.append(output);


Expand Down Expand Up @@ -451,7 +383,7 @@ SWGPetApi::updatePetCallback(SWGHttpRequestWorker * worker) {
}

void
SWGPetApi::updatePetWithForm(qint64 pet_id, QString* name, QString* status) {
SWGPetApi::updatePetWithForm(qint32 pet_id, QString* name, QString* status) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}");

Expand Down Expand Up @@ -508,7 +440,7 @@ SWGPetApi::updatePetWithFormCallback(SWGHttpRequestWorker * worker) {
}

void
SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file) {
SWGPetApi::uploadFile(qint32 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage");

Expand All @@ -523,7 +455,7 @@ SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpReques
input.add_var("additionalMetadata", *additional_metadata);
}
if (file != nullptr) {
input.add_file("file", (*file).local_filename, (*file).request_filename, (*file).mime_type);
input.add_var("file", *file);
}


Expand Down
12 changes: 6 additions & 6 deletions samples/client/petstore/qt5cpp/client/SWGPetApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class SWGPetApi: public QObject {
QString basePath;
QMap<QString, QString> defaultHeaders;

void addPet(SWGPet& body);
void deletePet(qint64 pet_id, QString* api_key);
void addPet(SWGPet& pet);
void deletePet(qint32 pet_id, QString* api_key);
void findPetsByStatus(QList<QString*>* status);
void findPetsByTags(QList<QString*>* tags);
void getPetById(qint64 pet_id);
void updatePet(SWGPet& body);
void updatePetWithForm(qint64 pet_id, QString* name, QString* status);
void uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file);
void getPetById(qint32 pet_id);
void updatePet(SWGPet& pet);
void updatePetWithForm(qint32 pet_id, QString* name, QString* status);
void uploadFile(qint32 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file);

private:
void addPetCallback (SWGHttpRequestWorker * worker);
Expand Down
35 changes: 35 additions & 0 deletions samples/client/petstore/qt5cpp/client/SWGQObjectWrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/

#ifndef SWG_QOBJECT_WRAPPER_H
#define SWG_QOBJECT_WRAPPER_H

#include <QObject>

namespace Swagger {

template <typename ObjectPtrT>
class SWGQObjectWrapper : public QObject {
public:
SWGQObjectWrapper(ObjectPtrT ptr){
data = ptr;
}
~SWGQObjectWrapper(){
delete data;
}
private :
ObjectPtrT data;
};

}

#endif // SWG_QOBJECT_WRAPPER_H
6 changes: 3 additions & 3 deletions samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ SWGStoreApi::getInventoryCallback(SWGHttpRequestWorker * worker) {
}

void
SWGStoreApi::getOrderById(qint64 order_id) {
SWGStoreApi::getOrderById(qint32 order_id) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}");

Expand Down Expand Up @@ -195,7 +195,7 @@ SWGStoreApi::getOrderByIdCallback(SWGHttpRequestWorker * worker) {
}

void
SWGStoreApi::placeOrder(SWGOrder& body) {
SWGStoreApi::placeOrder(SWGOrder& order) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/store/order");

Expand All @@ -206,7 +206,7 @@ SWGStoreApi::placeOrder(SWGOrder& body) {



QString output = body.asJson();
QString output = order.asJson();
input.request_body.append(output);


Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/qt5cpp/client/SWGStoreApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class SWGStoreApi: public QObject {

void deleteOrder(QString* order_id);
void getInventory();
void getOrderById(qint64 order_id);
void placeOrder(SWGOrder& body);
void getOrderById(qint32 order_id);
void placeOrder(SWGOrder& order);

private:
void deleteOrderCallback (SWGHttpRequestWorker * worker);
Expand Down
Loading

0 comments on commit ee2eb74

Please sign in to comment.