[BUG][C++][QT5] Code not compileable when circular scheme dependencies exist
Created by: ghost
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
The generated C++ (QT5) code cannot be compiled, when circular scheme dependencies are used.
openapi-generator version
4.3.1
OpenAPI declaration file content or url
openapi: 3.0.0
info:
version: 0.0.1
title: Test
paths:
/endpoint:
get:
operationId: getOptions
description: "-"
parameters:
- name: OptionA
in: header
schema:
$ref: '#/components/schemas/OptionA'
responses:
200:
description: Success
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/OptionA'
components:
schemas:
OptionA:
type: object
description: 'OptionA'
properties:
suboptions:
type: array
description: 'Suboptions of OptionA'
items:
$ref: '#/components/schemas/OptionB'
OptionB:
type: object
description: 'OptionB'
properties:
suboptions1:
type: array
description: 'Suboptions 1 of OptionB'
items:
$ref: '#/components/schemas/OptionA'
suboptions2:
type: array
description: 'Suboptions 2 of OptionB'
items:
$ref: '#/components/schemas/OptionB'
Command line used for generation
java -cp openapi-generator-cli-4.3.1.jar org.openapitools.codegen.OpenAPIGenerator generate -i ${SPEC_FILE} -g cpp-qt5-client -o gen/ --model-name-prefix Test
Steps to reproduce
- Generate CPP code with above command line.
- Generate Makefiles e.g. with (MAC and QT5.14.0):
cmake CMakeLists.txt -DCMAKE_PREFIX_PATH=/usr/local/Cellar/qt/5.14.0/
- Compile:
make
Related issues/PRs
Few similar issues (other languages) seems to exist.
Suggest a fix
Partly it can probably be fixed by forward declaration in headers, but not completely. More investigation needed.