diff --git a/docs/generators/cpp-qt-client.md b/docs/generators/cpp-qt-client.md index 3e8027011ea..c7da6c1da09 100644 --- a/docs/generators/cpp-qt-client.md +++ b/docs/generators/cpp-qt-client.md @@ -38,6 +38,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | Type/Alias | Imports | | ---------- | ------- | |OAIHttpFileElement|#include "OAIHttpFileElement.h"| +|QJsonValue|#include <QJsonValue>| ## INSTANTIATION TYPES diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQtClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQtClientCodegen.java index 5aa46278a9c..6785239ef04 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQtClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQtClientCodegen.java @@ -108,7 +108,9 @@ public class CppQtClientCodegen extends CppQtAbstractCodegen implements CodegenC supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri")); } typeMapping.put("file", PREFIX + "HttpFileElement"); + typeMapping.put("AnyType", "QJsonValue"); importMapping.put(PREFIX + "HttpFileElement", "#include \"" + PREFIX + "HttpFileElement.h\""); + importMapping.put("QJsonValue", "#include "); } @Override @@ -140,7 +142,9 @@ public class CppQtClientCodegen extends CppQtAbstractCodegen implements CodegenC typeMapping.put("file", modelNamePrefix + "HttpFileElement"); + typeMapping.put("AnyType", "QJsonValue"); importMapping.put(modelNamePrefix + "HttpFileElement", "#include \"" + modelNamePrefix + "HttpFileElement.h\""); + importMapping.put("QJsonValue", "#include "); if (optionalProjectFileFlag) { supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, modelNamePrefix + "client.pri")); } diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/helpers-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/helpers-body.mustache index 0661117b0ab..0e19b1771fb 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/helpers-body.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/helpers-body.mustache @@ -186,6 +186,10 @@ QJsonValue toJsonValue(const {{prefix}}HttpFileElement &value) { return value.asJsonValue(); } +QJsonValue toJsonValue(const QJsonValue &value) { + return value; +} + bool fromStringValue(const QString &inStr, QString &value) { value.clear(); value.append(inStr); @@ -415,6 +419,11 @@ bool fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval) { return value.fromJsonValue(jval); } +bool fromJsonValue(QJsonValue &value, const QJsonValue &jval) { + value = jval; + return true; +} + {{#cppNamespaceDeclarations}} } // namespace {{this}} {{/cppNamespaceDeclarations}} diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/helpers-header.mustache index 6b0ad489b1c..75523b15ebf 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/helpers-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/helpers-header.mustache @@ -127,6 +127,7 @@ QJsonValue toJsonValue(const double &value); QJsonValue toJsonValue(const {{prefix}}Object &value); QJsonValue toJsonValue(const {{prefix}}Enum &value); QJsonValue toJsonValue(const {{prefix}}HttpFileElement &value); +QJsonValue toJsonValue(const QJsonValue &value); template QJsonValue toJsonValue(const QList &val) { @@ -213,6 +214,7 @@ bool fromJsonValue(double &value, const QJsonValue &jval); bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval); bool fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval); bool fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval); +bool fromJsonValue(QJsonValue &value, const QJsonValue &jval); template bool fromJsonValue(QList &val, const QJsonValue &jval) { diff --git a/samples/client/petstore/cpp-qt/client/PFXHelpers.cpp b/samples/client/petstore/cpp-qt/client/PFXHelpers.cpp index 7245de9007f..aab9ed05f20 100644 --- a/samples/client/petstore/cpp-qt/client/PFXHelpers.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXHelpers.cpp @@ -194,6 +194,10 @@ QJsonValue toJsonValue(const PFXHttpFileElement &value) { return value.asJsonValue(); } +QJsonValue toJsonValue(const QJsonValue &value) { + return value; +} + bool fromStringValue(const QString &inStr, QString &value) { value.clear(); value.append(inStr); @@ -423,4 +427,9 @@ bool fromJsonValue(PFXHttpFileElement &value, const QJsonValue &jval) { return value.fromJsonValue(jval); } +bool fromJsonValue(QJsonValue &value, const QJsonValue &jval) { + value = jval; + return true; +} + } // namespace test_namespace diff --git a/samples/client/petstore/cpp-qt/client/PFXHelpers.h b/samples/client/petstore/cpp-qt/client/PFXHelpers.h index 3980b8ac2f1..ad1c3bb0cda 100644 --- a/samples/client/petstore/cpp-qt/client/PFXHelpers.h +++ b/samples/client/petstore/cpp-qt/client/PFXHelpers.h @@ -135,6 +135,7 @@ QJsonValue toJsonValue(const double &value); QJsonValue toJsonValue(const PFXObject &value); QJsonValue toJsonValue(const PFXEnum &value); QJsonValue toJsonValue(const PFXHttpFileElement &value); +QJsonValue toJsonValue(const QJsonValue &value); template QJsonValue toJsonValue(const QList &val) { @@ -221,6 +222,7 @@ bool fromJsonValue(double &value, const QJsonValue &jval); bool fromJsonValue(PFXObject &value, const QJsonValue &jval); bool fromJsonValue(PFXEnum &value, const QJsonValue &jval); bool fromJsonValue(PFXHttpFileElement &value, const QJsonValue &jval); +bool fromJsonValue(QJsonValue &value, const QJsonValue &jval); template bool fromJsonValue(QList &val, const QJsonValue &jval) {