From 9b2a954d1e6d9b06f31e48ec43f45360bb470609 Mon Sep 17 00:00:00 2001 From: Jakub Wicher Date: Wed, 6 May 2026 12:52:01 +0200 Subject: [PATCH 1/2] fix(cpp-qt-client): #23702 - required members are always present in output of toJsonObject --- .../src/main/resources/cpp-qt-client/model-body.mustache | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/model-body.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/model-body.mustache index 6055967efcc3..c000c80a9ba9 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/model-body.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/model-body.mustache @@ -100,11 +100,11 @@ QString {{classname}}::asJson() const { QJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}} {{classname}}::asJson{{^isEnum}}Object{{/isEnum}}{{#isEnum}}Value{{/isEnum}}() const { {{^isEnum}}QJsonObject obj;{{#vars}}{{^isContainer}}{{#complexType}} - if (m_{{name}}.isSet()){{/complexType}}{{^complexType}} - if (m_{{name}}_isSet){{/complexType}} { + if (true{{^required}} && m_{{name}}.isSet(){{/required}}){{/complexType}}{{^complexType}} + if (true{{^required}} && m_{{name}}_isSet{{/required}}){{/complexType}} { obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue(m_{{name}})); }{{/isContainer}}{{#isContainer}} - if (m_{{name}}.size() > 0) { + if (true{{^required}} && m_{{name}}.size() > 0{{/required}}) { {{^items.isContainer}}obj.insert(QString("{{baseName}}"), ::{{cppNamespace}}::toJsonValue(m_{{name}}));{{/items.isContainer}}{{#items.isContainer}} obj.insert(QString("{{baseName}}"), toJsonValue(m_{{name}}));{{/items.isContainer}} }{{/isContainer}}{{/vars}} From 94462e38fe9ba8b1bedf33ff0976c570fcd77460 Mon Sep 17 00:00:00 2001 From: Jakub Wicher Date: Fri, 8 May 2026 01:07:57 +0200 Subject: [PATCH 2/2] chore(cpp-qt-client): #23702 - regenerate samples --- .../client/PFXApiResponse.cpp | 6 +++--- .../client/PFXCategory.cpp | 4 ++-- .../client/PFXOrder.cpp | 12 ++++++------ .../cpp-qt-addDownloadProgress/client/PFXPet.cpp | 12 ++++++------ .../cpp-qt-addDownloadProgress/client/PFXTag.cpp | 4 ++-- .../client/PFXTestAnyType.cpp | 4 ++-- .../client/PFXUser.cpp | 16 ++++++++-------- .../petstore/cpp-qt/client/PFXApiResponse.cpp | 6 +++--- .../petstore/cpp-qt/client/PFXCategory.cpp | 4 ++-- .../client/petstore/cpp-qt/client/PFXOrder.cpp | 12 ++++++------ samples/client/petstore/cpp-qt/client/PFXPet.cpp | 12 ++++++------ samples/client/petstore/cpp-qt/client/PFXTag.cpp | 4 ++-- .../petstore/cpp-qt/client/PFXTestAnyType.cpp | 4 ++-- .../client/petstore/cpp-qt/client/PFXUser.cpp | 16 ++++++++-------- 14 files changed, 58 insertions(+), 58 deletions(-) diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp index ef7bb19bdb17..3f25f8b565bb 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp @@ -71,13 +71,13 @@ QString PFXApiResponse::asJson() const { QJsonObject PFXApiResponse::asJsonObject() const { QJsonObject obj; - if (m_code_isSet) { + if (true && m_code_isSet) { obj.insert(QString("code"), ::test_namespace::toJsonValue(m_code)); } - if (m_type_isSet) { + if (true && m_type_isSet) { obj.insert(QString("type"), ::test_namespace::toJsonValue(m_type)); } - if (m_message_isSet) { + if (true && m_message_isSet) { obj.insert(QString("message"), ::test_namespace::toJsonValue(m_message)); } return obj; diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXCategory.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXCategory.cpp index 46944b4aa07b..1860ae8e06b3 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXCategory.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXCategory.cpp @@ -65,10 +65,10 @@ QString PFXCategory::asJson() const { QJsonObject PFXCategory::asJsonObject() const { QJsonObject obj; - if (m_id_isSet) { + if (true && m_id_isSet) { obj.insert(QString("id"), ::test_namespace::toJsonValue(m_id)); } - if (m_name_isSet) { + if (true && m_name_isSet) { obj.insert(QString("name"), ::test_namespace::toJsonValue(m_name)); } return obj; diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXOrder.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXOrder.cpp index bb299fd96336..b51fa1ba1efe 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXOrder.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXOrder.cpp @@ -89,22 +89,22 @@ QString PFXOrder::asJson() const { QJsonObject PFXOrder::asJsonObject() const { QJsonObject obj; - if (m_id_isSet) { + if (true && m_id_isSet) { obj.insert(QString("id"), ::test_namespace::toJsonValue(m_id)); } - if (m_pet_id_isSet) { + if (true && m_pet_id_isSet) { obj.insert(QString("petId"), ::test_namespace::toJsonValue(m_pet_id)); } - if (m_quantity_isSet) { + if (true && m_quantity_isSet) { obj.insert(QString("quantity"), ::test_namespace::toJsonValue(m_quantity)); } - if (m_ship_date_isSet) { + if (true && m_ship_date_isSet) { obj.insert(QString("shipDate"), ::test_namespace::toJsonValue(m_ship_date)); } - if (m_status_isSet) { + if (true && m_status_isSet) { obj.insert(QString("status"), ::test_namespace::toJsonValue(m_status)); } - if (m_complete_isSet) { + if (true && m_complete_isSet) { obj.insert(QString("complete"), ::test_namespace::toJsonValue(m_complete)); } return obj; diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPet.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPet.cpp index dc9d4d036940..e1af3a4e1dc4 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPet.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXPet.cpp @@ -89,22 +89,22 @@ QString PFXPet::asJson() const { QJsonObject PFXPet::asJsonObject() const { QJsonObject obj; - if (m_id_isSet) { + if (true && m_id_isSet) { obj.insert(QString("id"), ::test_namespace::toJsonValue(m_id)); } - if (m_category.isSet()) { + if (true && m_category.isSet()) { obj.insert(QString("category"), ::test_namespace::toJsonValue(m_category)); } - if (m_name_isSet) { + if (true) { obj.insert(QString("name"), ::test_namespace::toJsonValue(m_name)); } - if (m_photo_urls.size() > 0) { + if (true) { obj.insert(QString("photoUrls"), ::test_namespace::toJsonValue(m_photo_urls)); } - if (m_tags.size() > 0) { + if (true && m_tags.size() > 0) { obj.insert(QString("tags"), ::test_namespace::toJsonValue(m_tags)); } - if (m_status_isSet) { + if (true && m_status_isSet) { obj.insert(QString("status"), ::test_namespace::toJsonValue(m_status)); } return obj; diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXTag.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXTag.cpp index 255653d5f7a0..f9d9a57abe66 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXTag.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXTag.cpp @@ -65,10 +65,10 @@ QString PFXTag::asJson() const { QJsonObject PFXTag::asJsonObject() const { QJsonObject obj; - if (m_id_isSet) { + if (true && m_id_isSet) { obj.insert(QString("id"), ::test_namespace::toJsonValue(m_id)); } - if (m_name_isSet) { + if (true && m_name_isSet) { obj.insert(QString("name"), ::test_namespace::toJsonValue(m_name)); } return obj; diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXTestAnyType.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXTestAnyType.cpp index d5ef6d36da48..f90e9063361b 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXTestAnyType.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXTestAnyType.cpp @@ -65,10 +65,10 @@ QString PFXTestAnyType::asJson() const { QJsonObject PFXTestAnyType::asJsonObject() const { QJsonObject obj; - if (m_code_isSet) { + if (true && m_code_isSet) { obj.insert(QString("code"), ::test_namespace::toJsonValue(m_code)); } - if (m_message_isSet) { + if (true && m_message_isSet) { obj.insert(QString("message"), ::test_namespace::toJsonValue(m_message)); } return obj; diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUser.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUser.cpp index c329701733b4..3ba2a1a8903c 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUser.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXUser.cpp @@ -101,28 +101,28 @@ QString PFXUser::asJson() const { QJsonObject PFXUser::asJsonObject() const { QJsonObject obj; - if (m_id_isSet) { + if (true && m_id_isSet) { obj.insert(QString("id"), ::test_namespace::toJsonValue(m_id)); } - if (m_username_isSet) { + if (true && m_username_isSet) { obj.insert(QString("username"), ::test_namespace::toJsonValue(m_username)); } - if (m_first_name_isSet) { + if (true && m_first_name_isSet) { obj.insert(QString("firstName"), ::test_namespace::toJsonValue(m_first_name)); } - if (m_last_name_isSet) { + if (true && m_last_name_isSet) { obj.insert(QString("lastName"), ::test_namespace::toJsonValue(m_last_name)); } - if (m_email_isSet) { + if (true && m_email_isSet) { obj.insert(QString("email"), ::test_namespace::toJsonValue(m_email)); } - if (m_password_isSet) { + if (true && m_password_isSet) { obj.insert(QString("password"), ::test_namespace::toJsonValue(m_password)); } - if (m_phone_isSet) { + if (true && m_phone_isSet) { obj.insert(QString("phone"), ::test_namespace::toJsonValue(m_phone)); } - if (m_user_status_isSet) { + if (true && m_user_status_isSet) { obj.insert(QString("userStatus"), ::test_namespace::toJsonValue(m_user_status)); } return obj; diff --git a/samples/client/petstore/cpp-qt/client/PFXApiResponse.cpp b/samples/client/petstore/cpp-qt/client/PFXApiResponse.cpp index ef7bb19bdb17..3f25f8b565bb 100644 --- a/samples/client/petstore/cpp-qt/client/PFXApiResponse.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXApiResponse.cpp @@ -71,13 +71,13 @@ QString PFXApiResponse::asJson() const { QJsonObject PFXApiResponse::asJsonObject() const { QJsonObject obj; - if (m_code_isSet) { + if (true && m_code_isSet) { obj.insert(QString("code"), ::test_namespace::toJsonValue(m_code)); } - if (m_type_isSet) { + if (true && m_type_isSet) { obj.insert(QString("type"), ::test_namespace::toJsonValue(m_type)); } - if (m_message_isSet) { + if (true && m_message_isSet) { obj.insert(QString("message"), ::test_namespace::toJsonValue(m_message)); } return obj; diff --git a/samples/client/petstore/cpp-qt/client/PFXCategory.cpp b/samples/client/petstore/cpp-qt/client/PFXCategory.cpp index 46944b4aa07b..1860ae8e06b3 100644 --- a/samples/client/petstore/cpp-qt/client/PFXCategory.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXCategory.cpp @@ -65,10 +65,10 @@ QString PFXCategory::asJson() const { QJsonObject PFXCategory::asJsonObject() const { QJsonObject obj; - if (m_id_isSet) { + if (true && m_id_isSet) { obj.insert(QString("id"), ::test_namespace::toJsonValue(m_id)); } - if (m_name_isSet) { + if (true && m_name_isSet) { obj.insert(QString("name"), ::test_namespace::toJsonValue(m_name)); } return obj; diff --git a/samples/client/petstore/cpp-qt/client/PFXOrder.cpp b/samples/client/petstore/cpp-qt/client/PFXOrder.cpp index bb299fd96336..b51fa1ba1efe 100644 --- a/samples/client/petstore/cpp-qt/client/PFXOrder.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXOrder.cpp @@ -89,22 +89,22 @@ QString PFXOrder::asJson() const { QJsonObject PFXOrder::asJsonObject() const { QJsonObject obj; - if (m_id_isSet) { + if (true && m_id_isSet) { obj.insert(QString("id"), ::test_namespace::toJsonValue(m_id)); } - if (m_pet_id_isSet) { + if (true && m_pet_id_isSet) { obj.insert(QString("petId"), ::test_namespace::toJsonValue(m_pet_id)); } - if (m_quantity_isSet) { + if (true && m_quantity_isSet) { obj.insert(QString("quantity"), ::test_namespace::toJsonValue(m_quantity)); } - if (m_ship_date_isSet) { + if (true && m_ship_date_isSet) { obj.insert(QString("shipDate"), ::test_namespace::toJsonValue(m_ship_date)); } - if (m_status_isSet) { + if (true && m_status_isSet) { obj.insert(QString("status"), ::test_namespace::toJsonValue(m_status)); } - if (m_complete_isSet) { + if (true && m_complete_isSet) { obj.insert(QString("complete"), ::test_namespace::toJsonValue(m_complete)); } return obj; diff --git a/samples/client/petstore/cpp-qt/client/PFXPet.cpp b/samples/client/petstore/cpp-qt/client/PFXPet.cpp index dc9d4d036940..e1af3a4e1dc4 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPet.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXPet.cpp @@ -89,22 +89,22 @@ QString PFXPet::asJson() const { QJsonObject PFXPet::asJsonObject() const { QJsonObject obj; - if (m_id_isSet) { + if (true && m_id_isSet) { obj.insert(QString("id"), ::test_namespace::toJsonValue(m_id)); } - if (m_category.isSet()) { + if (true && m_category.isSet()) { obj.insert(QString("category"), ::test_namespace::toJsonValue(m_category)); } - if (m_name_isSet) { + if (true) { obj.insert(QString("name"), ::test_namespace::toJsonValue(m_name)); } - if (m_photo_urls.size() > 0) { + if (true) { obj.insert(QString("photoUrls"), ::test_namespace::toJsonValue(m_photo_urls)); } - if (m_tags.size() > 0) { + if (true && m_tags.size() > 0) { obj.insert(QString("tags"), ::test_namespace::toJsonValue(m_tags)); } - if (m_status_isSet) { + if (true && m_status_isSet) { obj.insert(QString("status"), ::test_namespace::toJsonValue(m_status)); } return obj; diff --git a/samples/client/petstore/cpp-qt/client/PFXTag.cpp b/samples/client/petstore/cpp-qt/client/PFXTag.cpp index 255653d5f7a0..f9d9a57abe66 100644 --- a/samples/client/petstore/cpp-qt/client/PFXTag.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXTag.cpp @@ -65,10 +65,10 @@ QString PFXTag::asJson() const { QJsonObject PFXTag::asJsonObject() const { QJsonObject obj; - if (m_id_isSet) { + if (true && m_id_isSet) { obj.insert(QString("id"), ::test_namespace::toJsonValue(m_id)); } - if (m_name_isSet) { + if (true && m_name_isSet) { obj.insert(QString("name"), ::test_namespace::toJsonValue(m_name)); } return obj; diff --git a/samples/client/petstore/cpp-qt/client/PFXTestAnyType.cpp b/samples/client/petstore/cpp-qt/client/PFXTestAnyType.cpp index d5ef6d36da48..f90e9063361b 100644 --- a/samples/client/petstore/cpp-qt/client/PFXTestAnyType.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXTestAnyType.cpp @@ -65,10 +65,10 @@ QString PFXTestAnyType::asJson() const { QJsonObject PFXTestAnyType::asJsonObject() const { QJsonObject obj; - if (m_code_isSet) { + if (true && m_code_isSet) { obj.insert(QString("code"), ::test_namespace::toJsonValue(m_code)); } - if (m_message_isSet) { + if (true && m_message_isSet) { obj.insert(QString("message"), ::test_namespace::toJsonValue(m_message)); } return obj; diff --git a/samples/client/petstore/cpp-qt/client/PFXUser.cpp b/samples/client/petstore/cpp-qt/client/PFXUser.cpp index c329701733b4..3ba2a1a8903c 100644 --- a/samples/client/petstore/cpp-qt/client/PFXUser.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXUser.cpp @@ -101,28 +101,28 @@ QString PFXUser::asJson() const { QJsonObject PFXUser::asJsonObject() const { QJsonObject obj; - if (m_id_isSet) { + if (true && m_id_isSet) { obj.insert(QString("id"), ::test_namespace::toJsonValue(m_id)); } - if (m_username_isSet) { + if (true && m_username_isSet) { obj.insert(QString("username"), ::test_namespace::toJsonValue(m_username)); } - if (m_first_name_isSet) { + if (true && m_first_name_isSet) { obj.insert(QString("firstName"), ::test_namespace::toJsonValue(m_first_name)); } - if (m_last_name_isSet) { + if (true && m_last_name_isSet) { obj.insert(QString("lastName"), ::test_namespace::toJsonValue(m_last_name)); } - if (m_email_isSet) { + if (true && m_email_isSet) { obj.insert(QString("email"), ::test_namespace::toJsonValue(m_email)); } - if (m_password_isSet) { + if (true && m_password_isSet) { obj.insert(QString("password"), ::test_namespace::toJsonValue(m_password)); } - if (m_phone_isSet) { + if (true && m_phone_isSet) { obj.insert(QString("phone"), ::test_namespace::toJsonValue(m_phone)); } - if (m_user_status_isSet) { + if (true && m_user_status_isSet) { obj.insert(QString("userStatus"), ::test_namespace::toJsonValue(m_user_status)); } return obj;