OpenAPITools / OpenAPITools/openapi-generator
[BUG] [cpp-qt5] Array of files generates a solution not compilable
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
The auto-generated code doesn't compile (after running CMake to generate the solution).
The problem seems to be related to this part of the YAML:
file:
type: array
items:
type: string
format: binary
This is an array of files, inside the cpp-qt5 generated code is declared as a ::OpenAPI::OptionalParam<QList<OAIHttpFileElement>> &file but than is accessed like if it was a single element: file.value().local_filename, causing the compilation to fail.
openapi-generator version
5.1.0
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: Processing Service
version: 1.0.0
servers:
- url: 'http://localhost:8080'
description: Processing Service (Aresys GRAPeS Library)
paths:
'/api/companies/{companyId}/mask':
post:
tags:
- maskEndpoint
operationId: uploadMask
parameters:
- name: companyId
in: path
required: true
schema:
type: integer
format: int64
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
mask:
$ref: '#/components/schemas/MaskInfo'
file:
type: array
items:
type: string
format: binary
required: true
responses:
'200':
description: OK
content:
'*/*':
schema:
type: string
components:
schemas:
MaskInfo:
required:
- maskId
- timestamp
type: object
properties:
maskId:
type: array
items:
type: string
timestamp:
type: string
format: date-time
Command line used for generation
java -DskipFormModel=false -jar openapi-generator-cli-5.1.0.jar generate -i openapi.yaml -g cpp-qt5-client -o qt5
Steps to reproduce
- Execute the command in the folder containing the YAML file and the openapi-generator-cli-5.1.0.jar
- Execute
cmake client - Open the vs solution "client.sln" and rebuild
Related issues/PRs
Seems to be similar to: https://github.com/OpenAPITools/openapi-generator/issues/3271
Suggest a fix/enhancement
The problem seems to happen only with cpp-qt5, since using SPRING the generators handles correcly the resulting list
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
Reproduce with the supplied OpenAPI YAML and the cpp-qt5-client generation command, then run CMake and rebuild client.sln. Inspect the generated handling of the multipart file array and its OAIHttpFileElement access; done means the generated C++/Qt5 solution compiles for this specification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100