OpenAPITools / OpenAPITools/openapi-generator

[BUG][C++][QT] Unable to compile generated sources from cpp-qt-client generator

Open
#21,196 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I am using Gitea (version 1.23.4) which provides swagger.json for it's API. I was able to generate code for python, however, when I used cpp-qt-client generator, source code was successful generated, but I am not able to compile it.

CMake is working find, but make ends up with:

[  0%] Built target QtGiteaApi_autogen_timestamp_deps
[  1%] Automatic MOC for target QtGiteaApi
[  1%] Built target QtGiteaApi_autogen
[  1%] Building CXX object CMakeFiles/QtGiteaApi.dir/QtGiteaApi_autogen/mocs_compilation.cpp.o
In file included from /opt/git/test/API_Gitea/cpp_qt/client/build/QtGiteaApi_autogen/EWIEGA46WW/../../../Gitea_AdminApi.h:34,
                 from /opt/git/test/API_Gitea/cpp_qt/client/build/QtGiteaApi_autogen/EWIEGA46WW/moc_Gitea_AdminApi.cpp:10,
                 from /opt/git/test/API_Gitea/cpp_qt/client/build/QtGiteaApi_autogen/mocs_compilation.cpp:3:
/opt/git/test/API_Gitea/cpp_qt/client/build/QtGiteaApi_autogen/EWIEGA46WW/../../../Gitea_Repository.h:560:22: error: field ‘m_parent’ has incomplete type ‘gitea::v1::Gitea_Repository’
  560 |     Gitea_Repository m_parent;
      |                      ^~~~~~~~
/opt/git/test/API_Gitea/cpp_qt/client/build/QtGiteaApi_autogen/EWIEGA46WW/../../../Gitea_Repository.h:45:7: note: definition of ‘class gitea::v1::Gitea_Repository’ is not complete until the closing brace
   45 | class Gitea_Repository : public Gitea_Object {
      |       ^~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/QtGiteaApi.dir/build.make:85: CMakeFiles/QtGiteaApi.dir/QtGiteaApi_autogen/mocs_compilation.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:90: CMakeFiles/QtGiteaApi.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I checked similar issue #6377 which was closed as resolved but I still have same problem, so I opened this issue.

openapi-generator version

7.12.0

OpenAPI declaration file content or url

swagger.json

Generation Details

I am using openapi-generator-cli of version 7.12.0 with cpp-qt-client generator. I am not using any specific config, only command line arguments.

Steps to reproduce
  1. generate sources:
    openapi-generator-cli generate -i swagger.v1.json -g cpp-qt-client -o /tmp/gitea_test/ --additional-properties=allowUnicodeIdentifiers=true,cppNamespace=gitea::v1;enumUnknownDefaultCase=true;packageName=QtGiteaApiClient
    
  2. create build dir
    cd /tmp/gitea_test/client && mkdir build && cd build
    
  3. run cmake:
    cmake ../CMakeLists.txt
    
  4. run make
  5. Error during compilation occurs.
Related issues/PRs

#6377

Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the linked swagger.json using the cpp-qt-client command, then run CMake and make as described. Inspect the generated Gitea_Repository.h around m_parent and the cpp-qt-client generator sources; done means the generated project compiles successfully without the incomplete-type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, openapi
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.