fix(cpp-qt-client): #23702 - required members are always present in output of toJsonObject#23703
Open
TheZlodziej wants to merge 1 commit intoOpenAPITools:masterfrom
Open
fix(cpp-qt-client): #23702 - required members are always present in output of toJsonObject#23703TheZlodziej wants to merge 1 commit intoOpenAPITools:masterfrom
TheZlodziej wants to merge 1 commit intoOpenAPITools:masterfrom
Conversation
…present in output of toJsonObject
Contributor
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/resources/cpp-qt-client/model-body.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/cpp-qt-client/model-body.mustache:104">
P1: Required primitive fields may serialize uninitialized/indeterminate values after this change</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| 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}} { |
Contributor
There was a problem hiding this comment.
P1: Required primitive fields may serialize uninitialized/indeterminate values after this change
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/cpp-qt-client/model-body.mustache, line 104:
<comment>Required primitive fields may serialize uninitialized/indeterminate values after this change</comment>
<file context>
@@ -100,11 +100,11 @@ QString {{classname}}::asJson() const {
- 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}}
</file context>
Member
|
please follow step 3 to update the samples so as to fix https://github.com/OpenAPITools/openapi-generator/actions/runs/25431058267/job/74599299188?pr=23703 cc @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @MartinDelille (2018/03) @muttleyxd (2019/08) @aminya (2025/05) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes issue mentioned in #23702
the toJsonObject should always contain required variables (even if they are not set)
Summary by cubic
Ensure the
cpp-qt-clientgenerator always includes required model fields in JSON output, even when unset. Fixes #23702 to prevent missing required keys in serialized payloads.model-body.mustacheto always insert required fields inasJsonObject(removesisSet/size()>0guards for required properties).Written for commit 9b2a954. Summary will update on new commits.