diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 2d09ffa60565..cb3bd0769856 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -1148,6 +1148,18 @@ public String toDefaultValueWithParam(String name, Schema schema) { **/ @SuppressWarnings("static-method") public String getSchemaType(Schema schema) { + // TODO better logic to handle compose schema + if (schema instanceof ComposedSchema) { // composed schema + ComposedSchema cs = (ComposedSchema) schema; + for (Schema s : cs.getAllOf()) { + if (s != null) { + // using the first schema defined in allOf + schema = s; + break; + } + } + } + if (StringUtils.isNotBlank(schema.get$ref())) { // object // get the schema/model name from $ref String schemaName = ModelUtils.getSimpleRef(schema.get$ref()); 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 27678ade427c..9f379cd8f797 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 @@ -345,6 +345,7 @@ public String toDefaultValue(Schema p) { @Override public String getSchemaType(Schema p) { String openAPIType = super.getSchemaType(p); + String type = null; if (typeMapping.containsKey(openAPIType)) { type = typeMapping.get(openAPIType); @@ -362,6 +363,11 @@ public String getSchemaType(Schema p) { @Override public String toModelName(String type) { + if (type == null) { + LOGGER.warn("Model name can't be null. Defaul to 'UnknownModel'."); + type = "UnknownModel"; + } + if (typeMapping.keySet().contains(type) || typeMapping.values().contains(type) || importMapping.values().contains(type) || diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp index fea2b44e2447..666ce2c63233 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.cpp @@ -30,7 +30,7 @@ SWGPetApi::SWGPetApi(QString host, QString basePath) { } void -SWGPetApi::addPet(SWGPet& swg_pet) { +SWGPetApi::addPet(std::shared_ptr& swg_pet) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet"); @@ -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(); @@ -337,7 +405,7 @@ SWGPetApi::getPetByIdCallback(SWGHttpRequestWorker * worker) { } void -SWGPetApi::updatePet(SWGPet& swg_pet) { +SWGPetApi::updatePet(std::shared_ptr& swg_pet) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/pet"); diff --git a/samples/client/petstore/qt5cpp/client/SWGPetApi.h b/samples/client/petstore/qt5cpp/client/SWGPetApi.h index 70ce602c51cb..5f040d8a32a1 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPetApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGPetApi.h @@ -36,12 +36,12 @@ class SWGPetApi: public QObject { QString basePath; QMap defaultHeaders; - void addPet(SWGPet& swg_pet); + void addPet(std::shared_ptr& swg_pet); void deletePet(qint64 pet_id, QString* api_key); void findPetsByStatus(QList* status); void findPetsByTags(QList* tags); void getPetById(qint64 pet_id); - void updatePet(SWGPet& swg_pet); + void updatePet(std::shared_ptr& swg_pet); void updatePetWithForm(qint64 pet_id, QString* name, QString* status); void uploadFile(qint64 pet_id, QString* additional_metadata, SWGHttpRequestInputFileElement* file); diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp index b04e57e273b0..d61f26ba9fb5 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp @@ -196,7 +196,7 @@ SWGStoreApi::getOrderByIdCallback(SWGHttpRequestWorker * worker) { } void -SWGStoreApi::placeOrder(SWGOrder& swg_order) { +SWGStoreApi::placeOrder(std::shared_ptr& swg_order) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/store/order"); diff --git a/samples/client/petstore/qt5cpp/client/SWGStoreApi.h b/samples/client/petstore/qt5cpp/client/SWGStoreApi.h index 321a0e609280..bfa20043c5c3 100644 --- a/samples/client/petstore/qt5cpp/client/SWGStoreApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGStoreApi.h @@ -38,7 +38,7 @@ class SWGStoreApi: public QObject { void deleteOrder(QString* order_id); void getInventory(); void getOrderById(qint64 order_id); - void placeOrder(SWGOrder& swg_order); + void placeOrder(std::shared_ptr& swg_order); private: void deleteOrderCallback (SWGHttpRequestWorker * worker); diff --git a/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp b/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp index bb02a3d5de61..f79093e1cd95 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGUserApi.cpp @@ -30,7 +30,7 @@ SWGUserApi::SWGUserApi(QString host, QString basePath) { } void -SWGUserApi::createUser(SWGUser& swg_user) { +SWGUserApi::createUser(std::shared_ptr& swg_user) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user"); @@ -418,7 +418,7 @@ SWGUserApi::logoutUserCallback(SWGHttpRequestWorker * worker) { } void -SWGUserApi::updateUser(QString* username, SWGUser& swg_user) { +SWGUserApi::updateUser(QString* username, std::shared_ptr& swg_user) { QString fullPath; fullPath.append(this->host).append(this->basePath).append("/user/{username}"); diff --git a/samples/client/petstore/qt5cpp/client/SWGUserApi.h b/samples/client/petstore/qt5cpp/client/SWGUserApi.h index e6ad3c2e0926..816bd10ab95a 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUserApi.h +++ b/samples/client/petstore/qt5cpp/client/SWGUserApi.h @@ -15,6 +15,7 @@ #include "SWGHttpRequest.h" +#include #include #include "SWGUser.h" @@ -34,14 +35,14 @@ class SWGUserApi: public QObject { QString basePath; QMap defaultHeaders; - void createUser(SWGUser& swg_user); + void createUser(std::shared_ptr& swg_user); void createUsersWithArrayInput(QList*& swg_user); void createUsersWithListInput(QList*& swg_user); void deleteUser(QString* username); void getUserByName(QString* username); void loginUser(QString* username, QString* password); void logoutUser(); - void updateUser(QString* username, SWGUser& swg_user); + void updateUser(QString* username, std::shared_ptr& swg_user); private: void createUserCallback (SWGHttpRequestWorker * worker);