diff --git a/bin/openapi3/qt5-petstore.sh b/bin/openapi3/qt5-petstore.sh new file mode 100755 index 000000000000..4c89d47c1ab4 --- /dev/null +++ b/bin/openapi3/qt5-petstore.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +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 -t modules/openapi-generator/src/main/resources/qt5cpp -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l cpp-qt5 -o samples/client/petstore/qt5cpp" + +java $JAVA_OPTS -jar $executable $ags diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5ClientCodegen.java index 600246f30438..dd4252c91028 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5ClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQt5ClientCodegen.java @@ -289,8 +289,7 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo Schema inner = ap.getItems(); return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">*"; } else if (isMapSchema(p)) { - MapSchema mp = (MapSchema) p; - Schema inner = (Schema) mp.getAdditionalProperties(); + Schema inner = (Schema) p.getAdditionalProperties(); return getSchemaType(p) + "*"; } if (foundationClasses.contains(openAPIType)) { diff --git a/samples/client/petstore/qt5cpp/client/SWGBody.cpp b/samples/client/petstore/qt5cpp/client/SWGBody.cpp new file mode 100644 index 000000000000..b64ee2c43b26 --- /dev/null +++ b/samples/client/petstore/qt5cpp/client/SWGBody.cpp @@ -0,0 +1,126 @@ +/** + * 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: apiteam@swagger.io + * + * 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. + */ + + +#include "SWGBody.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace Swagger { + +SWGBody::SWGBody(QString json) { + init(); + this->fromJson(json); +} + +SWGBody::SWGBody() { + init(); +} + +SWGBody::~SWGBody() { + this->cleanup(); +} + +void +SWGBody::init() { + name = new QString(""); + m_name_isSet = false; + status = new QString(""); + m_status_isSet = false; +} + +void +SWGBody::cleanup() { + if(name != nullptr) { + delete name; + } + if(status != nullptr) { + delete status; + } +} + +SWGBody* +SWGBody::fromJson(QString json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGBody::fromJsonObject(QJsonObject pJson) { + ::Swagger::setValue(&name, pJson["name"], "QString", "QString"); + + ::Swagger::setValue(&status, pJson["status"], "QString", "QString"); + +} + +QString +SWGBody::asJson () +{ + QJsonObject obj = this->asJsonObject(); + QJsonDocument doc(obj); + QByteArray bytes = doc.toJson(); + return QString(bytes); +} + +QJsonObject +SWGBody::asJsonObject() { + QJsonObject obj; + if(name != nullptr && *name != QString("")){ + toJsonValue(QString("name"), name, obj, QString("QString")); + } + if(status != nullptr && *status != QString("")){ + toJsonValue(QString("status"), status, obj, QString("QString")); + } + + return obj; +} + +QString* +SWGBody::getName() { + return name; +} +void +SWGBody::setName(QString* name) { + this->name = name; + this->m_name_isSet = true; +} + +QString* +SWGBody::getStatus() { + return status; +} +void +SWGBody::setStatus(QString* status) { + this->status = status; + this->m_status_isSet = true; +} + + +bool +SWGBody::isSet(){ + bool isObjectUpdated = false; + do{ + if(name != nullptr && *name != QString("")){ isObjectUpdated = true; break;} + if(status != nullptr && *status != QString("")){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/samples/client/petstore/qt5cpp/client/SWGBody.h b/samples/client/petstore/qt5cpp/client/SWGBody.h new file mode 100644 index 000000000000..1945b8ac3250 --- /dev/null +++ b/samples/client/petstore/qt5cpp/client/SWGBody.h @@ -0,0 +1,64 @@ +/** + * 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: apiteam@swagger.io + * + * 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. + */ + +/* + * SWGBody.h + * + * + */ + +#ifndef SWGBody_H_ +#define SWGBody_H_ + +#include + + +#include + +#include "SWGObject.h" + +namespace Swagger { + +class SWGBody: public SWGObject { +public: + SWGBody(); + SWGBody(QString json); + ~SWGBody(); + void init(); + void cleanup(); + + QString asJson () override; + QJsonObject asJsonObject() override; + void fromJsonObject(QJsonObject json) override; + SWGBody* fromJson(QString jsonString) override; + + QString* getName(); + void setName(QString* name); + + QString* getStatus(); + void setStatus(QString* status); + + + virtual bool isSet() override; + +private: + QString* name; + bool m_name_isSet; + + QString* status; + bool m_status_isSet; + +}; + +} + +#endif /* SWGBody_H_ */ diff --git a/samples/client/petstore/qt5cpp/client/SWGBody_1.cpp b/samples/client/petstore/qt5cpp/client/SWGBody_1.cpp new file mode 100644 index 000000000000..6f169af90bf8 --- /dev/null +++ b/samples/client/petstore/qt5cpp/client/SWGBody_1.cpp @@ -0,0 +1,126 @@ +/** + * 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: apiteam@swagger.io + * + * 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. + */ + + +#include "SWGBody_1.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace Swagger { + +SWGBody_1::SWGBody_1(QString json) { + init(); + this->fromJson(json); +} + +SWGBody_1::SWGBody_1() { + init(); +} + +SWGBody_1::~SWGBody_1() { + this->cleanup(); +} + +void +SWGBody_1::init() { + additional_metadata = new QString(""); + m_additional_metadata_isSet = false; + file = NULL; + m_file_isSet = false; +} + +void +SWGBody_1::cleanup() { + if(additional_metadata != nullptr) { + delete additional_metadata; + } + if(file != nullptr) { + delete file; + } +} + +SWGBody_1* +SWGBody_1::fromJson(QString json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGBody_1::fromJsonObject(QJsonObject pJson) { + ::Swagger::setValue(&additional_metadata, pJson["additionalMetadata"], "QString", "QString"); + + ::Swagger::setValue(&file, pJson["file"], "QString", "QString"); + +} + +QString +SWGBody_1::asJson () +{ + QJsonObject obj = this->asJsonObject(); + QJsonDocument doc(obj); + QByteArray bytes = doc.toJson(); + return QString(bytes); +} + +QJsonObject +SWGBody_1::asJsonObject() { + QJsonObject obj; + if(additional_metadata != nullptr && *additional_metadata != QString("")){ + toJsonValue(QString("additionalMetadata"), additional_metadata, obj, QString("QString")); + } + if((file != nullptr) && (file->isSet())){ + toJsonValue(QString("file"), file, obj, QString("QString")); + } + + return obj; +} + +QString* +SWGBody_1::getAdditionalMetadata() { + return additional_metadata; +} +void +SWGBody_1::setAdditionalMetadata(QString* additional_metadata) { + this->additional_metadata = additional_metadata; + this->m_additional_metadata_isSet = true; +} + +QString* +SWGBody_1::getFile() { + return file; +} +void +SWGBody_1::setFile(QString* file) { + this->file = file; + this->m_file_isSet = true; +} + + +bool +SWGBody_1::isSet(){ + bool isObjectUpdated = false; + do{ + if(additional_metadata != nullptr && *additional_metadata != QString("")){ isObjectUpdated = true; break;} + if(file != nullptr && file->isSet()){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/samples/client/petstore/qt5cpp/client/SWGBody_1.h b/samples/client/petstore/qt5cpp/client/SWGBody_1.h new file mode 100644 index 000000000000..dda618666f73 --- /dev/null +++ b/samples/client/petstore/qt5cpp/client/SWGBody_1.h @@ -0,0 +1,64 @@ +/** + * 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: apiteam@swagger.io + * + * 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. + */ + +/* + * SWGBody_1.h + * + * + */ + +#ifndef SWGBody_1_H_ +#define SWGBody_1_H_ + +#include + + +#include + +#include "SWGObject.h" + +namespace Swagger { + +class SWGBody_1: public SWGObject { +public: + SWGBody_1(); + SWGBody_1(QString json); + ~SWGBody_1(); + void init(); + void cleanup(); + + QString asJson () override; + QJsonObject asJsonObject() override; + void fromJsonObject(QJsonObject json) override; + SWGBody_1* fromJson(QString jsonString) override; + + QString* getAdditionalMetadata(); + void setAdditionalMetadata(QString* additional_metadata); + + QString* getFile(); + void setFile(QString* file); + + + virtual bool isSet() override; + +private: + QString* additional_metadata; + bool m_additional_metadata_isSet; + + QString* file; + bool m_file_isSet; + +}; + +} + +#endif /* SWGBody_1_H_ */ diff --git a/samples/client/petstore/qt5cpp/client/SWGModelFactory.h b/samples/client/petstore/qt5cpp/client/SWGModelFactory.h index 3e2fef6458e8..07f1984af195 100644 --- a/samples/client/petstore/qt5cpp/client/SWGModelFactory.h +++ b/samples/client/petstore/qt5cpp/client/SWGModelFactory.h @@ -16,6 +16,8 @@ #include "SWGObject.h" #include "SWGApiResponse.h" +#include "SWGBody.h" +#include "SWGBody_1.h" #include "SWGCategory.h" #include "SWGOrder.h" #include "SWGPet.h" @@ -28,6 +30,12 @@ namespace Swagger { if(QString("SWGApiResponse").compare(type) == 0) { return new SWGApiResponse(); } + if(QString("SWGBody").compare(type) == 0) { + return new SWGBody(); + } + if(QString("SWGBody_1").compare(type) == 0) { + return new SWGBody_1(); + } if(QString("SWGCategory").compare(type) == 0) { return new SWGCategory(); } diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp index 825c145778be..4a1f37e99ddf 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp @@ -141,13 +141,47 @@ SWGPetApi::findPetsByStatus(QList* status) { fullPath.append(this->host).append(this->basePath).append("/pet/findByStatus"); - if (fullPath.indexOf("?") > 0) - fullPath.append("&"); - else - fullPath.append("?"); - fullPath.append(QUrl::toPercentEncoding("status")) - .append("=") - .append(QUrl::toPercentEncoding(stringValue(status))); + + + 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)); + } + } + } SWGHttpRequestWorker *worker = new SWGHttpRequestWorker(); @@ -214,13 +248,47 @@ SWGPetApi::findPetsByTags(QList* tags) { fullPath.append(this->host).append(this->basePath).append("/pet/findByTags"); - if (fullPath.indexOf("?") > 0) - fullPath.append("&"); - else - fullPath.append("?"); - fullPath.append(QUrl::toPercentEncoding("tags")) - .append("=") - .append(QUrl::toPercentEncoding(stringValue(tags))); + + + 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)); + } + } + } SWGHttpRequestWorker *worker = new SWGHttpRequestWorker(); @@ -446,7 +514,7 @@ SWGPetApi::updatePetWithFormCallback(SWGHttpRequestWorker * worker) { } void -SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file) { +SWGPetApi::uploadFile(qint64 pet_id, QString* additional_metadata, QString* file) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet/{petId}/uploadImage"); diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.h b/samples/client/petstore/qt5cpp/client/SWGPetApi.h index c1da383fa19e..a718ad014c72 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.h @@ -17,7 +17,6 @@ #include #include "SWGApiResponse.h" -#include "SWGHttpRequest.h" #include "SWGPet.h" #include @@ -43,7 +42,7 @@ public: void getPetById(qint64 pet_id); void updatePet(SWGPet& pet); void updatePetWithForm(qint64 pet_id, QString* name, QString* status); - void uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file); + void uploadFile(qint64 pet_id, QString* additional_metadata, QString* file); private: void addPetCallback (SWGHttpRequestWorker * worker); diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp index a5d59345a758..c4e2b97f3c1f 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp @@ -119,15 +119,15 @@ SWGStoreApi::getInventoryCallback(SWGHttpRequestWorker * worker) { msg = "Error: " + worker->error_str; } - QMap* output = new QMap(); + QMap* output = NULL; 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], "qint32", QString()); + QMap val; + setValue(&val, obj[key], "QMap", QString()); output->insert(key, val); } worker->deleteLater(); diff --git a/samples/client/petstore/qt5cpp/client/client.pri b/samples/client/petstore/qt5cpp/client/client.pri index c4202c44aee0..9144c532a023 100644 --- a/samples/client/petstore/qt5cpp/client/client.pri +++ b/samples/client/petstore/qt5cpp/client/client.pri @@ -3,6 +3,8 @@ QT += network HEADERS += \ # Models $${PWD}/SWGApiResponse.h \ + $${PWD}/SWGBody.h \ + $${PWD}/SWGBody_1.h \ $${PWD}/SWGCategory.h \ $${PWD}/SWGOrder.h \ $${PWD}/SWGPet.h \ @@ -22,6 +24,8 @@ HEADERS += \ SOURCES += \ # Models $${PWD}/SWGApiResponse.cpp \ + $${PWD}/SWGBody.cpp \ + $${PWD}/SWGBody_1.cpp \ $${PWD}/SWGCategory.cpp \ $${PWD}/SWGOrder.cpp \ $${PWD}/SWGPet.cpp \