diff --git a/bin/qt5-petstore.sh b/bin/qt5-petstore.sh index d79dd513ded..7959785de34 100755 --- a/bin/qt5-petstore.sh +++ b/bin/qt5-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l qt5cpp -o samples/client/petstore/qt5cpp" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/qt5cpp -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l qt5cpp -o samples/client/petstore/qt5cpp" java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/Qt5CPPGenerator.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/Qt5CPPGenerator.java index b3adeb19a32..35d9bf58bbb 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/Qt5CPPGenerator.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/Qt5CPPGenerator.java @@ -130,11 +130,13 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig { typeMapping.put("boolean", "bool"); typeMapping.put("array", "QList"); typeMapping.put("map", "QMap"); - // typeMapping.put("number", "Long"); + typeMapping.put("file", "SWGHttpRequestInputFileElement"); typeMapping.put("object", PREFIX + "Object"); importMapping = new HashMap(); + importMapping.put("SWGHttpRequestInputFileElement", "#include \"" + PREFIX + "HttpRequest.h\""); + namespaces = new HashMap (); foundationClasses.add("QString"); @@ -210,7 +212,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig { else if (p instanceof MapProperty) { MapProperty mp = (MapProperty) p; Property inner = mp.getAdditionalProperties(); - return getSwaggerType(p) + "*"; + return getSwaggerType(p) + "*"; } if(foundationClasses.contains(swaggerType)) return swaggerType + "*"; @@ -243,7 +245,7 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig { else if (p instanceof MapProperty) { MapProperty ap = (MapProperty) p; String inner = getSwaggerType(ap.getAdditionalProperties()); - return "NULL"; + return "new QMap()"; } else if (p instanceof ArrayProperty) { ArrayProperty ap = (ArrayProperty) p; diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.cpp b/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.cpp index fed94e8dddb..b56004e8f51 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.cpp +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.cpp @@ -26,7 +26,7 @@ void HttpRequestInput::add_var(QString key, QString value) { } void HttpRequestInput::add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type) { - HttpRequestInputFileElement file; + SWGHttpRequestInputFileElement file; file.variable_name = variable_name; file.local_filename = local_filename; file.request_filename = request_filename; @@ -173,7 +173,7 @@ void HttpRequestWorker::execute(HttpRequestInput *input) { } // add files - for (QList::iterator file_info = input->files.begin(); file_info != input->files.end(); file_info++) { + for (QList::iterator file_info = input->files.begin(); file_info != input->files.end(); file_info++) { QFileInfo fi(file_info->local_filename); // ensure necessary variables are available diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.h b/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.h index 260ccb20679..a2e91a0765e 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.h +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/HttpRequest.h @@ -13,11 +13,10 @@ #include #include - enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART}; -class HttpRequestInputFileElement { +class SWGHttpRequestInputFileElement { public: QString variable_name; @@ -36,7 +35,7 @@ public: HttpRequestVarLayout var_layout; QMap vars; QMap headers; - QList files; + QList files; QByteArray request_body; HttpRequestInput(); diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/api-body.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/api-body.mustache index 9103cb5e16f..592c4158aeb 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/api-body.mustache @@ -1,5 +1,6 @@ #include "{{classname}}.h" #include "{{prefix}}Helpers.h" +#include "{{prefix}}ModelFactory.h" #include #include @@ -17,32 +18,97 @@ namespace Swagger { {{#operations}} {{#operation}} void -{{classname}}::{{nickname}}({{#allParams}}{{dataType}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { +{{classname}}::{{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("{{path}}"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "{{httpMethod}}"); + {{#pathParams}} QString {{paramName}}PathParam("{"); {{paramName}}PathParam.append("{{paramName}}").append("}"); fullPath.replace({{paramName}}PathParam, stringValue({{paramName}})); {{/pathParams}} - {{#queryParams}}if(fullPath.compare("?") > 0) fullPath.append("?"); - else fullPath.append("&"); + {{#formParams}}{{^isFile}} + if({{paramName}} != NULL) { + input.add_var("{{paramName}}", *{{paramName}}); + } + {{/isFile}}{{/formParams}} + + {{#queryParams}} + {{^collectionFormat}} + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); fullPath.append(QUrl::toPercentEncoding("{{paramName}}")) .append("=") .append(QUrl::toPercentEncoding(stringValue({{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("{{{paramName}}}=").append(stringValue(t)); + } + } + else if (QString("{{collectionFormat}}").indexOf("ssv") == 0) { + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); + fullPath.append("{{paramName}}="); + qint32 count = 0; + foreach({{{baseType}}} t, *{{paramName}}) { + if(count > 0) { + fullPath.append(" "); + } + fullPath.append(stringValue(t)); + } + } + else if (QString("{{collectionFormat}}").indexOf("tsv") == 0) { + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); + fullPath.append("{{paramName}}="); + qint32 count = 0; + foreach({{{baseType}}} t, *{{paramName}}) { + if(count > 0) { + fullPath.append("\t"); + } + fullPath.append(stringValue(t)); + } + } + } + + {{/collectionFormat}} {{/queryParams}} - - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "{{httpMethod}}"); - {{#bodyParams}} - // body - input.request_body.append({{paramName}}.asJson()); - {{/bodyParams}} + {{#isContainer}} + QJsonArray* {{paramName}}Array = new QJsonArray(); + toJsonArray((QList*){{paramName}}, {{paramName}}Array, QString("body"), QString("SWGUser*")); + + QJsonDocument doc(*{{paramName}}Array); + QByteArray bytes = doc.toJson(); + + input.request_body.append(bytes); + {{/isContainer}} + {{^isContainer}} + QString output = {{paramName}}.asJson(); + input.request_body.append(output); + + {{/isContainer}}{{/bodyParams}} {{#headerParams}} - input.headers + // TODO: add header support {{/headerParams}} connect(worker, @@ -71,7 +137,7 @@ void QJsonArray jsonArray = doc.array(); foreach(QJsonValue obj, jsonArray) { - {{returnBaseType}}* o = new {{returnBaseType}}(); + {{{returnBaseType}}}* o = new {{returnBaseType}}(); QJsonObject jv = obj.toObject(); QJsonObject * ptr = (QJsonObject*)&jv; o->fromJsonObject(*ptr); @@ -80,13 +146,29 @@ void {{/isListContainer}} {{^isListContainer}}{{#returnTypeIsPrimitive}} - {{returnType}} output; // TODO - + {{{returnType}}} output; // TODO add primitive output support {{/returnTypeIsPrimitive}} + {{#isMapContainer}} + {{{returnType}}} output = {{{defaultResponse}}}; + + QString json(worker->response); + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject obj = doc.object(); + + foreach(QString key, obj.keys()) { + qint32* val; + setValue(&val, obj[key], "{{returnBaseType}}", ""); + output->insert(key, *val); + } + + + {{/isMapContainer}} + {{^isMapContainer}} {{^returnTypeIsPrimitive}}QString json(worker->response); - {{returnType}} output = new {{returnBaseType}}(&json); - + {{{returnType}}} output = static_cast<{{{returnType}}}>(create(json, QString("{{{returnBaseType}}}"))); {{/returnTypeIsPrimitive}} + {{/isMapContainer}} {{/isListContainer}}{{/returnType}} worker->deleteLater(); diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache index 01e205a0773..7f4d748c2dc 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache @@ -154,6 +154,11 @@ stringValue(qint32 value) { return QString::number(value); } +QString +stringValue(qint64 value) { + return QString::number(value); +} + QString stringValue(bool value) { return QString(value ? "true" : "false"); diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-header.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-header.mustache index 988e6480da8..3a02c0952d5 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-header.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-header.mustache @@ -10,6 +10,7 @@ namespace Swagger { bool isCompatibleJsonValue(QString type); QString stringValue(QString* value); QString stringValue(qint32 value); + QString stringValue(qint64 value); QString stringValue(bool value); } diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/modelFactory.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/modelFactory.mustache index f3cd5c8e2f0..4ec9e6f7411 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/modelFactory.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/modelFactory.mustache @@ -5,14 +5,25 @@ #include "{{classname}}.h"{{/model}}{{/models}} namespace Swagger { - void* - create(QString type) { + inline void* create(QString type) { {{#models}}{{#model}}if(QString("{{classname}}").compare(type) == 0) { return new {{classname}}(); } {{/model}}{{/models}} return NULL; } + + inline void* create(QString json, QString type) { + void* val = create(type); + if(val != NULL) { + SWGObject* obj = static_cast(val); + return obj->fromJson(json); + } + if(type.startsWith("QString")) { + return new QString(); + } + return NULL; + } } /* namespace Swagger */ #endif /* ModelFactory_H_ */ diff --git a/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp b/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp new file mode 100644 index 00000000000..e5670fa4e00 --- /dev/null +++ b/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp @@ -0,0 +1,274 @@ +#include "PetApiTests.h" + +#include +#include +#include +#include + +PetApiTests::PetApiTests () {} + +PetApiTests::~PetApiTests () { + exit(1); +} + +SWGPetApi* PetApiTests::getApi() { + SWGPetApi* api = new SWGPetApi(); + api->host = "http://petstore.swagger.io"; + api->basePath = "/v2"; + return api; +} + +SWGPet* PetApiTests::createRandomPet() { + SWGPet* pet = new SWGPet(); + qint64 id = QDateTime::currentMSecsSinceEpoch(); + + pet->setName(new QString("monster")); + pet->setId(id); + pet->setStatus(new QString("freaky")); + + return pet; +} + +void PetApiTests::runTests() { + PetApiTests* tests = new PetApiTests(); + QTest::qExec(tests); + delete tests; +} + +void PetApiTests::getPetByIdTest() { + SWGPetApi* api = getApi(); + + static QEventLoop loop; + QTimer timer; + timer.setInterval(1000); + timer.setSingleShot(true); + + auto validator = [](SWGPet* pet) { + qDebug() << pet->asJson(); + QVERIFY(pet->getId() == 3); + loop.quit(); + }; + + connect(api, &SWGPetApi::getPetByIdSignal, this, validator); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + api->getPetById(3); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); + delete api; +} + +void PetApiTests::findPetsByStatusTest() { + SWGPetApi* api = getApi(); + + static QEventLoop loop; + QTimer timer; + timer.setInterval(1000); + timer.setSingleShot(true); + + auto validator = [](QList* pets) { + foreach(SWGPet* pet, *pets) { + QVERIFY(pet->getStatus()->startsWith("available") || pet->getStatus()->startsWith("sold")); + } + loop.quit(); + }; + + connect(api, &SWGPetApi::findPetsByStatusSignal, this, validator); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + + QList* status = new QList(); + status->append(new QString("available")); + status->append(new QString("sold")); + api->findPetsByStatus(status); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); + delete api; +} + +void PetApiTests::createAndGetPetTest() { + SWGPetApi* api = getApi(); + + static QEventLoop loop; + QTimer timer; + timer.setInterval(1000); + timer.setSingleShot(true); + + auto validator = []() { + // pet created + loop.quit(); + }; + + connect(api, &SWGPetApi::addPetSignal, this, validator); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + + SWGPet* pet = createRandomPet(); + qint64 id = pet->getId(); + + api->addPet(*pet); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); + + timer.setInterval(1000); + timer.setSingleShot(true); + + auto getPetValidator = [](SWGPet* pet) { + QVERIFY(pet->getId() > 0); + QVERIFY(pet->getStatus()->compare("freaky") == 0); + loop.quit(); + }; + + connect(api, &SWGPetApi::getPetByIdSignal, this, getPetValidator); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + + api->getPetById(id); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); + delete api; +} + +void PetApiTests::updatePetTest() { + static SWGPetApi* api = getApi(); + + SWGPet* pet = createRandomPet(); + static SWGPet* petToCheck; + qint64 id = pet->getId(); + static QEventLoop loop; + QTimer timer; + timer.setInterval(100000); + timer.setSingleShot(true); + + auto validator = []() { + loop.quit(); + }; + + connect(api, &SWGPetApi::addPetSignal, this, validator); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + + // create pet + api->addPet(*pet); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); + + // fetch it + timer.setInterval(1000); + timer.setSingleShot(true); + + auto fetchPet = [](SWGPet* pet) { + petToCheck = pet; + loop.quit(); + }; + connect(api, &SWGPetApi::getPetByIdSignal, this, fetchPet); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + + // create pet + api->getPetById(id); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); + + // update it + timer.setInterval(1000); + timer.setSingleShot(true); + auto updatePetTest = []() { + loop.quit(); + }; + + connect(api, &SWGPetApi::updatePetSignal, this, updatePetTest); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + + // update pet + petToCheck->setStatus(new QString("scary")); + api->updatePet(*petToCheck); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); + + // check it + timer.setInterval(1000); + timer.setSingleShot(true); + + auto fetchPet2 = [](SWGPet* pet) { + QVERIFY(pet->getId() == petToCheck->getId()); + QVERIFY(pet->getStatus()->compare(petToCheck->getStatus()) == 0); + loop.quit(); + }; + connect(api, &SWGPetApi::getPetByIdSignal, this, fetchPet2); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + api->getPetById(id); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); +} + +void PetApiTests::updatePetWithFormTest() { + static SWGPetApi* api = getApi(); + + SWGPet* pet = createRandomPet(); + static SWGPet* petToCheck; + qint64 id = pet->getId(); + static QEventLoop loop; + QTimer timer; + + // create pet + timer.setInterval(1000); + timer.setSingleShot(true); + + auto validator = []() { + loop.quit(); + }; + + connect(api, &SWGPetApi::addPetSignal, this, validator); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + api->addPet(*pet); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); + + // fetch it + timer.setInterval(1000); + timer.setSingleShot(true); + + auto fetchPet = [](SWGPet* pet) { + petToCheck = pet; + loop.quit(); + }; + connect(api, &SWGPetApi::getPetByIdSignal, this, fetchPet); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + + api->getPetById(id); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); + + // update it + timer.setInterval(1000); + timer.setSingleShot(true); + + connect(api, &SWGPetApi::updatePetWithFormSignal, this, [](){loop.quit();}); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + + api->updatePetWithForm(new QString(QString::number(id)), new QString("gorilla"), NULL); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); + + // fetch it + timer.setInterval(1000); + timer.setSingleShot(true); + + auto fetchUpdatedPet = [](SWGPet* pet) { + QVERIFY(pet->getName()->compare(QString("gorilla")) == 0); + loop.quit(); + }; + connect(api, &SWGPetApi::getPetByIdSignal, this, fetchUpdatedPet); + connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + + api->getPetById(id); + timer.start(); + loop.exec(); + QVERIFY2(timer.isActive(), "didn't finish within timeout"); +} diff --git a/samples/client/petstore/qt5cpp/PetStore/PetApiTests.h b/samples/client/petstore/qt5cpp/PetStore/PetApiTests.h new file mode 100644 index 00000000000..9fdc939ab11 --- /dev/null +++ b/samples/client/petstore/qt5cpp/PetStore/PetApiTests.h @@ -0,0 +1,35 @@ +#ifndef PETAPITESTS_H +#define PETAPITESTS_H + +#include +#include + +#include "../client/SWGPetApi.h" + +using namespace Swagger; + +class PetApiTests: public QObject { +Q_OBJECT +public: + PetApiTests(); + virtual ~PetApiTests(); + + static void runTests(); + +private: + SWGPetApi* getApi(); + SWGPet* createRandomPet(); + +signals: + void quit(); + bool success(); + +private slots: + void getPetByIdTest(); + void findPetsByStatusTest(); + void createAndGetPetTest(); + void updatePetTest(); + void updatePetWithFormTest(); +}; + +#endif // PETAPITESTS_H diff --git a/samples/client/petstore/qt5cpp/PetStore/PetStore.pro b/samples/client/petstore/qt5cpp/PetStore/PetStore.pro new file mode 100644 index 00000000000..70b3618cba6 --- /dev/null +++ b/samples/client/petstore/qt5cpp/PetStore/PetStore.pro @@ -0,0 +1,46 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-05-14T20:56:31 +# +#------------------------------------------------- + +QT += core gui testlib network + +QT -= gui + +TARGET = PetStore +CONFIG += console +CONFIG -= app_bundle + +CONFIG += c++11 + +TEMPLATE = app + + +SOURCES += main.cpp \ + ../client/SWGCategory.cpp \ + ../client/SWGHelpers.cpp \ + ../client/SWGHttpRequest.cpp \ + ../client/SWGOrder.cpp \ + ../client/SWGPet.cpp \ + ../client/SWGPetApi.cpp \ + ../client/SWGStoreApi.cpp \ + ../client/SWGTag.cpp \ + ../client/SWGUser.cpp \ + ../client/SWGUserApi.cpp \ + PetApiTests.cpp + +HEADERS += \ + ../client/SWGCategory.h \ + ../client/SWGHelpers.h \ + ../client/SWGHttpRequest.h \ + ../client/SWGObject.h \ + ../client/SWGOrder.h \ + ../client/SWGPet.h \ + ../client/SWGPetApi.h \ + ../client/SWGStoreApi.h \ + ../client/SWGTag.h \ + ../client/SWGUser.h \ + ../client/SWGUserApi.h \ + PetApiTests.h \ + ../client/SWGModelFactory.h diff --git a/samples/client/petstore/qt5cpp/PetStore/PetStore.pro.user b/samples/client/petstore/qt5cpp/PetStore/PetStore.pro.user new file mode 100644 index 00000000000..a506d15a1d1 --- /dev/null +++ b/samples/client/petstore/qt5cpp/PetStore/PetStore.pro.user @@ -0,0 +1,269 @@ + + + + + + EnvironmentId + {e1009bf2-3b8d-440a-a972-23a1fd0a9453} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.4.1 clang 64bit + Desktop Qt 5.4.1 clang 64bit + qt.54.clang_64_kit + 0 + 0 + 0 + + /Users/tony/dev/projects/swagger-api/swagger-codegen/samples/client/petstore/qt5cpp/build-PetStore-Desktop_Qt_5_4_1_clang_64bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /Users/tony/dev/projects/swagger-api/swagger-codegen/samples/client/petstore/qt5cpp/build-PetStore-Desktop_Qt_5_4_1_clang_64bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/local/bin/valgrind + + 11 + 14 + 12 + 13 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 0 + 1 + + 2 + + PetStore + + Qt4ProjectManager.Qt4RunConfiguration:/Users/tony/dev/projects/swagger-api/swagger-codegen/samples/client/petstore/qt5cpp/PetStore/PetStore.pro + + PetStore.pro + false + false + + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/samples/client/petstore/qt5cpp/PetStore/main.cpp b/samples/client/petstore/qt5cpp/PetStore/main.cpp new file mode 100644 index 00000000000..800544fbded --- /dev/null +++ b/samples/client/petstore/qt5cpp/PetStore/main.cpp @@ -0,0 +1,12 @@ +#include +#include "PetApiTests.h" + +int main(int argc, char *argv[]) { + QCoreApplication a(argc, argv); + + PetApiTests::runTests(); + + + + return a.exec(); +} diff --git a/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp b/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp index 01e205a0773..7f4d748c2dc 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp @@ -154,6 +154,11 @@ stringValue(qint32 value) { return QString::number(value); } +QString +stringValue(qint64 value) { + return QString::number(value); +} + QString stringValue(bool value) { return QString(value ? "true" : "false"); diff --git a/samples/client/petstore/qt5cpp/client/SWGHelpers.h b/samples/client/petstore/qt5cpp/client/SWGHelpers.h index 988e6480da8..3a02c0952d5 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHelpers.h +++ b/samples/client/petstore/qt5cpp/client/SWGHelpers.h @@ -10,6 +10,7 @@ namespace Swagger { bool isCompatibleJsonValue(QString type); QString stringValue(QString* value); QString stringValue(qint32 value); + QString stringValue(qint64 value); QString stringValue(bool value); } diff --git a/samples/client/petstore/qt5cpp/client/SWGHttpRequest.cpp b/samples/client/petstore/qt5cpp/client/SWGHttpRequest.cpp index fed94e8dddb..b56004e8f51 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHttpRequest.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGHttpRequest.cpp @@ -26,7 +26,7 @@ void HttpRequestInput::add_var(QString key, QString value) { } void HttpRequestInput::add_file(QString variable_name, QString local_filename, QString request_filename, QString mime_type) { - HttpRequestInputFileElement file; + SWGHttpRequestInputFileElement file; file.variable_name = variable_name; file.local_filename = local_filename; file.request_filename = request_filename; @@ -173,7 +173,7 @@ void HttpRequestWorker::execute(HttpRequestInput *input) { } // add files - for (QList::iterator file_info = input->files.begin(); file_info != input->files.end(); file_info++) { + for (QList::iterator file_info = input->files.begin(); file_info != input->files.end(); file_info++) { QFileInfo fi(file_info->local_filename); // ensure necessary variables are available diff --git a/samples/client/petstore/qt5cpp/client/SWGHttpRequest.h b/samples/client/petstore/qt5cpp/client/SWGHttpRequest.h index 260ccb20679..a2e91a0765e 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHttpRequest.h +++ b/samples/client/petstore/qt5cpp/client/SWGHttpRequest.h @@ -13,11 +13,10 @@ #include #include - enum HttpRequestVarLayout {NOT_SET, ADDRESS, URL_ENCODED, MULTIPART}; -class HttpRequestInputFileElement { +class SWGHttpRequestInputFileElement { public: QString variable_name; @@ -36,7 +35,7 @@ public: HttpRequestVarLayout var_layout; QMap vars; QMap headers; - QList files; + QList files; QByteArray request_body; HttpRequestInput(); diff --git a/samples/client/petstore/qt5cpp/client/SWGModelFactory.h b/samples/client/petstore/qt5cpp/client/SWGModelFactory.h index 3eaf51ab0a9..588a7ad952b 100644 --- a/samples/client/petstore/qt5cpp/client/SWGModelFactory.h +++ b/samples/client/petstore/qt5cpp/client/SWGModelFactory.h @@ -9,8 +9,7 @@ #include "SWGOrder.h" namespace Swagger { - void* - create(QString type) { + inline void* create(QString type) { if(QString("SWGUser").compare(type) == 0) { return new SWGUser(); } @@ -29,6 +28,18 @@ namespace Swagger { return NULL; } + + inline void* create(QString json, QString type) { + void* val = create(type); + if(val != NULL) { + SWGObject* obj = static_cast(val); + return obj->fromJson(json); + } + if(type.startsWith("QString")) { + return new QString(); + } + return NULL; + } } /* namespace Swagger */ #endif /* ModelFactory_H_ */ diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp index 4405b0e4d24..eae6eb4e760 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp @@ -1,5 +1,6 @@ #include "SWGPetApi.h" #include "SWGHelpers.h" +#include "SWGModelFactory.h" #include #include @@ -19,16 +20,20 @@ SWGPetApi::updatePet(SWGPet body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet"); - - - - HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "PUT"); - // body - input.request_body.append(body.asJson()); + + + + + + + + QString output = body.asJson(); + input.request_body.append(output); + @@ -63,16 +68,20 @@ SWGPetApi::addPet(SWGPet body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet"); - - - - HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "POST"); - // body - input.request_body.append(body.asJson()); + + + + + + + + QString output = body.asJson(); + input.request_body.append(output); + @@ -103,19 +112,10 @@ SWGPetApi::addPetCallback(HttpRequestWorker * worker) { emit addPetSignal(); } void -SWGPetApi::findPetsByStatus(QList<QString*>* status) { +SWGPetApi::findPetsByStatus(QList* status) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus"); - - - if(fullPath.compare("?") > 0) fullPath.append("?"); - else fullPath.append("&"); - fullPath.append(QUrl::toPercentEncoding("status")) - .append("=") - .append(QUrl::toPercentEncoding(stringValue(status))); - - HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "GET"); @@ -123,6 +123,57 @@ SWGPetApi::findPetsByStatus(QList<QString*>* status) { + + + + + + if(status->size() > 0) { + if(QString("multi").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("multi").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("multi").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)); + } + } + } + + + + + + + connect(worker, &HttpRequestWorker::on_execution_finished, this, @@ -165,19 +216,10 @@ SWGPetApi::findPetsByStatusCallback(HttpRequestWorker * worker) { } void -SWGPetApi::findPetsByTags(QList<QString*>* tags) { +SWGPetApi::findPetsByTags(QList* tags) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet/findByTags"); - - - if(fullPath.compare("?") > 0) fullPath.append("?"); - else fullPath.append("&"); - fullPath.append(QUrl::toPercentEncoding("tags")) - .append("=") - .append(QUrl::toPercentEncoding(stringValue(tags))); - - HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "GET"); @@ -185,6 +227,57 @@ SWGPetApi::findPetsByTags(QList<QString*>* tags) { + + + + + + if(tags->size() > 0) { + if(QString("multi").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("multi").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("multi").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)); + } + } + } + + + + + + + connect(worker, &HttpRequestWorker::on_execution_finished, this, @@ -231,6 +324,9 @@ SWGPetApi::getPetById(qint64 petId) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); + QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); fullPath.replace(petIdPathParam, stringValue(petId)); @@ -238,9 +334,7 @@ SWGPetApi::getPetById(qint64 petId) { - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); - + @@ -266,9 +360,11 @@ SWGPetApi::getPetByIdCallback(HttpRequestWorker * worker) { + + QString json(worker->response); - SWGPet* output = new SWGPet(&json); - + SWGPet* output = static_cast(create(json, QString("SWGPet"))); + @@ -282,16 +378,25 @@ SWGPetApi::updatePetWithForm(QString* petId, QString* name, QString* status) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "POST"); + QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); fullPath.replace(petIdPathParam, stringValue(petId)); + if(name != NULL) { + input.add_var("name", *name); + } + + if(status != NULL) { + input.add_var("status", *status); + } + - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "POST"); - + @@ -326,6 +431,9 @@ SWGPetApi::deletePet(QString* api_key, qint64 petId) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet/{petId}"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "DELETE"); + QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); fullPath.replace(petIdPathParam, stringValue(petId)); @@ -333,13 +441,11 @@ SWGPetApi::deletePet(QString* api_key, qint64 petId) { - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "DELETE"); - + - input.headers + // TODO: add header support connect(worker, @@ -368,20 +474,25 @@ SWGPetApi::deletePetCallback(HttpRequestWorker * worker) { emit deletePetSignal(); } void -SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGFile* file) { +SWGPetApi::uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "POST"); + QString petIdPathParam("{"); petIdPathParam.append("petId").append("}"); fullPath.replace(petIdPathParam, stringValue(petId)); + if(additionalMetadata != NULL) { + input.add_var("additionalMetadata", *additionalMetadata); + } + - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "POST"); - + diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.h b/samples/client/petstore/qt5cpp/client/SWGPetApi.h index 1067265656b..2f65cade2c4 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.h @@ -5,7 +5,7 @@ #include "SWGPet.h" #include -#include "SWGFile.h" +#include "SWGHttpRequest.h" #include @@ -29,7 +29,7 @@ public: void getPetById(qint64 petId); void updatePetWithForm(QString* petId, QString* name, QString* status); void deletePet(QString* api_key, qint64 petId); - void uploadFile(qint64 petId, QString* additionalMetadata, SWGFile* file); + void uploadFile(qint64 petId, QString* additionalMetadata, SWGHttpRequestInputFileElement* file); private: void updatePetCallback (HttpRequestWorker * worker); diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp index 8602eb009fd..49906842199 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp @@ -1,5 +1,6 @@ #include "SWGStoreApi.h" #include "SWGHelpers.h" +#include "SWGModelFactory.h" #include #include @@ -19,10 +20,6 @@ SWGStoreApi::getInventory() { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/store/inventory"); - - - - HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "GET"); @@ -30,6 +27,11 @@ SWGStoreApi::getInventory() { + + + + + connect(worker, &HttpRequestWorker::on_execution_finished, this, @@ -51,9 +53,22 @@ SWGStoreApi::getInventoryCallback(HttpRequestWorker * worker) { - QString json(worker->response); - QMap<String, qint32>* output = new QMap(&json); + + QMap* output = new QMap(); + QString json(worker->response); + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject obj = doc.object(); + + foreach(QString key, obj.keys()) { + qint32* val; + setValue(&val, obj[key], "QMap", ""); + output->insert(key, *val); + } + + + @@ -67,16 +82,20 @@ SWGStoreApi::placeOrder(SWGOrder body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/store/order"); - - - - HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "POST"); - // body - input.request_body.append(body.asJson()); + + + + + + + + QString output = body.asJson(); + input.request_body.append(output); + @@ -102,9 +121,11 @@ SWGStoreApi::placeOrderCallback(HttpRequestWorker * worker) { + + QString json(worker->response); - SWGOrder* output = new SWGOrder(&json); - + SWGOrder* output = static_cast(create(json, QString("SWGOrder"))); + @@ -118,6 +139,9 @@ SWGStoreApi::getOrderById(QString* orderId) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); + QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}"); fullPath.replace(orderIdPathParam, stringValue(orderId)); @@ -125,9 +149,7 @@ SWGStoreApi::getOrderById(QString* orderId) { - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); - + @@ -153,9 +175,11 @@ SWGStoreApi::getOrderByIdCallback(HttpRequestWorker * worker) { + + QString json(worker->response); - SWGOrder* output = new SWGOrder(&json); - + SWGOrder* output = static_cast(create(json, QString("SWGOrder"))); + @@ -169,6 +193,9 @@ SWGStoreApi::deleteOrder(QString* orderId) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/store/order/{orderId}"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "DELETE"); + QString orderIdPathParam("{"); orderIdPathParam.append("orderId").append("}"); fullPath.replace(orderIdPathParam, stringValue(orderId)); @@ -176,9 +203,7 @@ SWGStoreApi::deleteOrder(QString* orderId) { - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "DELETE"); - + diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.h b/samples/client/petstore/qt5cpp/client/SWGStoreApi.h index 6b7755c7d5e..7bbe8e5f92a 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.h @@ -34,7 +34,7 @@ private: void deleteOrderCallback (HttpRequestWorker * worker); signals: - void getInventorySignal(QMap* summary); + void getInventorySignal(QMap* summary); void placeOrderSignal(SWGOrder* summary); void getOrderByIdSignal(SWGOrder* summary); void deleteOrderSignal(); diff --git a/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp b/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp index 9d17e9067e3..6f56ef2ebbb 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp @@ -1,5 +1,6 @@ #include "SWGUserApi.h" #include "SWGHelpers.h" +#include "SWGModelFactory.h" #include #include @@ -19,16 +20,20 @@ SWGUserApi::createUser(SWGUser body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user"); - - - - HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "POST"); - // body - input.request_body.append(body.asJson()); + + + + + + + + QString output = body.asJson(); + input.request_body.append(output); + @@ -59,20 +64,28 @@ SWGUserApi::createUserCallback(HttpRequestWorker * worker) { emit createUserSignal(); } void -SWGUserApi::createUsersWithArrayInput(QList<SWGUser*>* body) { +SWGUserApi::createUsersWithArrayInput(QList* body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/createWithArray"); - - - - HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "POST"); - // body - input.request_body.append(body.asJson()); + + + + + + + QJsonArray* bodyArray = new QJsonArray(); + toJsonArray((QList*)body, bodyArray, QString("body"), QString("SWGUser*")); + + QJsonDocument doc(*bodyArray); + QByteArray bytes = doc.toJson(); + + input.request_body.append(bytes); + @@ -103,20 +116,28 @@ SWGUserApi::createUsersWithArrayInputCallback(HttpRequestWorker * worker) { emit createUsersWithArrayInputSignal(); } void -SWGUserApi::createUsersWithListInput(QList<SWGUser*>* body) { +SWGUserApi::createUsersWithListInput(QList* body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/createWithList"); - - - - HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "POST"); - // body - input.request_body.append(body.asJson()); + + + + + + + QJsonArray* bodyArray = new QJsonArray(); + toJsonArray((QList*)body, bodyArray, QString("body"), QString("SWGUser*")); + + QJsonDocument doc(*bodyArray); + QByteArray bytes = doc.toJson(); + + input.request_body.append(bytes); + @@ -151,23 +172,38 @@ SWGUserApi::loginUser(QString* username, QString* password) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/login"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); + - if(fullPath.compare("?") > 0) fullPath.append("?"); - else fullPath.append("&"); + + + + + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); fullPath.append(QUrl::toPercentEncoding("username")) .append("=") .append(QUrl::toPercentEncoding(stringValue(username))); - if(fullPath.compare("?") > 0) fullPath.append("?"); - else fullPath.append("&"); + + + + + + if(fullPath.indexOf("?") > 0) + fullPath.append("&"); + else + fullPath.append("?"); fullPath.append(QUrl::toPercentEncoding("password")) .append("=") .append(QUrl::toPercentEncoding(stringValue(password))); - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); - + + @@ -193,9 +229,11 @@ SWGUserApi::loginUserCallback(HttpRequestWorker * worker) { + + QString json(worker->response); - QString* output = new QString(&json); - + QString* output = static_cast(create(json, QString("QString"))); + @@ -209,10 +247,6 @@ SWGUserApi::logoutUser() { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/logout"); - - - - HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "GET"); @@ -220,6 +254,11 @@ SWGUserApi::logoutUser() { + + + + + connect(worker, &HttpRequestWorker::on_execution_finished, this, @@ -250,6 +289,9 @@ SWGUserApi::getUserByName(QString* username) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/{username}"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "GET"); + QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); fullPath.replace(usernamePathParam, stringValue(username)); @@ -257,9 +299,7 @@ SWGUserApi::getUserByName(QString* username) { - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "GET"); - + @@ -285,9 +325,11 @@ SWGUserApi::getUserByNameCallback(HttpRequestWorker * worker) { + + QString json(worker->response); - SWGUser* output = new SWGUser(&json); - + SWGUser* output = static_cast(create(json, QString("SWGUser"))); + @@ -301,6 +343,9 @@ SWGUserApi::updateUser(QString* username, SWGUser body) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/{username}"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "PUT"); + QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); fullPath.replace(usernamePathParam, stringValue(username)); @@ -308,12 +353,13 @@ SWGUserApi::updateUser(QString* username, SWGUser body) { - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "PUT"); - - // body - input.request_body.append(body.asJson()); + + + + QString output = body.asJson(); + input.request_body.append(output); + @@ -348,6 +394,9 @@ SWGUserApi::deleteUser(QString* username) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/{username}"); + HttpRequestWorker *worker = new HttpRequestWorker(); + HttpRequestInput input(fullPath, "DELETE"); + QString usernamePathParam("{"); usernamePathParam.append("username").append("}"); fullPath.replace(usernamePathParam, stringValue(username)); @@ -355,9 +404,7 @@ SWGUserApi::deleteUser(QString* username) { - HttpRequestWorker *worker = new HttpRequestWorker(); - HttpRequestInput input(fullPath, "DELETE"); - +