OpenAPITools / OpenAPITools/openapi-generator
[BUG] [cpp-qt-client] C++ compiler error "'asJsonObject': is not a member of" when pulling enums into schemas
Nobody has claimed this yet.
- 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
When I pull the pet status enum in the modules/openapi-generator/src/test/resources/3_0/petstore.json file into the schemas section of the .json file and use the schema in the /pet/findByStatus function and then compile the generated library I get the follwing compiler error:
client\PFXPetApi.cpp(499,48): error C2039: 'asJsonObject': is not a member of 'test_namespace::PFXPetStatus'
The created class PFXPetStatus derives from PFXEnum. Neither provides a asJsonObject() function.
openapi-generator version
7.8.0-20240702.091835-1
OpenAPI declaration file content or url
Here ist the modified petstore.json that reproduces the problem
https://gist.github.com/Knitschi/9c86f1e06dd52c29ee4cdb79ce540fa7
The difference to the original file is that it introduces a schema with the PetStatus enum that is then used in the definition of the /pet/findByStatus function and the Pet schema.
Generation Details
Client was generated with
java -jar openapi-generator-cli-7.8.0-20240702.091835-1.jar generate --input-spec petstore.json --generator-name cpp-qt-client --output . --package-name CppQtPetstoreClient --additional-properties cppNamespace=test_namespace --minimal-update --model-name-prefix PFX
Steps to reproduce
- Generate and compile the example
samples\client\petstore\cpp-qtwith the modifiedpetstore.jsonfile.
Possible Fix
I am not competent enough to provide one.
Related issues/PRs
Maybe this issue is related to: https://github.com/OpenAPITools/openapi-generator/issues/15277
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
Start with the modified petstore.json from the issue and generate samples/client/petstore/cpp-qt using the cpp-qt-client generator. Trace the generated PFXPetStatus type and the call in client/PFXPetApi.cpp that produces the asJsonObject error. Done means the generated library compiles when the PetStatus enum is pulled into schemas and used by /pet/findByStatus.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100