OpenAPITools / OpenAPITools/openapi-generator
[BUG][cpp-qt-client] Required array member is not outputted to JSON
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
The array item is marked required in the .yaml file but is not visible in json file
schemas:
SomeObject:
type: object
properties:
some_array:
type: array
items:
$ref: "#/components/schemas/SomeArray"
required:
- some_array
The check for putting array member is
// toJsonObject() {
if ( m_{{name}}.size() > 0 ) {
// put values to json
}
// }
which is incorrect for required values - even empty array should be present in there.
The correct approach would be to check whether the variable is required and then perform this check
// toJsonObject() {
if ( true{{^required}} && m_{{name}}.size() > 0{{/required}} ) {
// put values to json
}
// }
openapi-generator version
7.22.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the cpp-qt-client template responsible for toJsonObject() and trace generated output for the YAML example. Verify that a required empty array is emitted while optional empty arrays retain their existing behavior, then run the relevant generator tests or generation path to confirm the output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100