diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache index 0da998eb5060..4188010a9cc2 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/api-body.mustache @@ -397,7 +397,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} } fullPath.append(paramString); {{/isPrimitiveType}}{{#isPrimitiveType}} - fullPath.append(QUrl::toPercentEncoding("{{baseName}}")).append(querySuffix).append(QUrl::toPercentEncoding(::{{cppNamespace}}::toStringValue({{paramName}}{{^required}}.value(){{/required}}))); + fullPath.append(QUrl::toPercentEncoding("{{baseName}}")).append(querySuffix).append(QUrl::toPercentEncoding({{paramName}}{{^required}}.stringValue(){{/required}})); {{/isPrimitiveType}} {{/collectionFormat}} {{#collectionFormat}} 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 75523b15ebff..a7bccbe67950 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 @@ -21,27 +21,6 @@ namespace {{this}} { {{/cppNamespaceDeclarations}} -template -class OptionalParam { -public: - T m_Value; - bool m_hasValue; -public: - OptionalParam(){ - m_hasValue = false; - } - OptionalParam(const T &val){ - m_hasValue = true; - m_Value = val; - } - bool hasValue() const { - return m_hasValue; - } - T value() const{ - return m_Value; - } -}; - bool setDateTimeFormat(const QString &format); bool setDateTimeFormat(const Qt::DateFormat &format); @@ -264,6 +243,37 @@ bool fromJsonValue(QMap &val, const QJsonValue &jval) { return ok; } +template +class OptionalParam { +public: + T m_Value; + bool m_isNull = false; + bool m_hasValue; +public: + OptionalParam(){ + m_hasValue = false; + } + OptionalParam(const T &val, bool isNull = false){ + m_hasValue = true; + m_Value = val; + m_isNull = isNull; + } + bool hasValue() const { + return m_hasValue; + } + T value() const{ + return m_Value; + } + + QString stringValue() const { + if (m_isNull) { + return QStringLiteral(""); + } else { + return toStringValue(value()); + } + } +}; + {{#cppNamespaceDeclarations}} } // namespace {{this}} {{/cppNamespaceDeclarations}} diff --git a/samples/client/petstore/cpp-qt/client/PFXHelpers.h b/samples/client/petstore/cpp-qt/client/PFXHelpers.h index ad1c3bb0cdad..3503fff75236 100644 --- a/samples/client/petstore/cpp-qt/client/PFXHelpers.h +++ b/samples/client/petstore/cpp-qt/client/PFXHelpers.h @@ -29,27 +29,6 @@ namespace test_namespace { -template -class OptionalParam { -public: - T m_Value; - bool m_hasValue; -public: - OptionalParam(){ - m_hasValue = false; - } - OptionalParam(const T &val){ - m_hasValue = true; - m_Value = val; - } - bool hasValue() const { - return m_hasValue; - } - T value() const{ - return m_Value; - } -}; - bool setDateTimeFormat(const QString &format); bool setDateTimeFormat(const Qt::DateFormat &format); @@ -272,6 +251,37 @@ bool fromJsonValue(QMap &val, const QJsonValue &jval) { return ok; } +template +class OptionalParam { +public: + T m_Value; + bool m_isNull = false; + bool m_hasValue; +public: + OptionalParam(){ + m_hasValue = false; + } + OptionalParam(const T &val, bool isNull = false){ + m_hasValue = true; + m_Value = val; + m_isNull = isNull; + } + bool hasValue() const { + return m_hasValue; + } + T value() const{ + return m_Value; + } + + QString stringValue() const { + if (m_isNull) { + return QStringLiteral(""); + } else { + return toStringValue(value()); + } + } +}; + } // namespace test_namespace #endif // PFX_HELPERS_H diff --git a/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp b/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp index 86c362b90a80..7949f0afa3a4 100644 --- a/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXUserApi.cpp @@ -655,7 +655,7 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) { else fullPath.append("?"); - fullPath.append(QUrl::toPercentEncoding("username")).append(querySuffix).append(QUrl::toPercentEncoding(::test_namespace::toStringValue(username))); + fullPath.append(QUrl::toPercentEncoding("username")).append(querySuffix).append(QUrl::toPercentEncoding(username)); } { @@ -670,7 +670,7 @@ void PFXUserApi::loginUser(const QString &username, const QString &password) { else fullPath.append("?"); - fullPath.append(QUrl::toPercentEncoding("password")).append(querySuffix).append(QUrl::toPercentEncoding(::test_namespace::toStringValue(password))); + fullPath.append(QUrl::toPercentEncoding("password")).append(querySuffix).append(QUrl::toPercentEncoding(password)); } PFXHttpRequestWorker *worker = new PFXHttpRequestWorker(this, _manager); worker->setTimeOut(_timeOut);