Skip to content

Conversation

@ReallyVirtual
Copy link
Contributor

Add asJsonObject method to OAIEnum class for cpp-qt-client

Adds the missing method to enum moustache file

@etherealjoy @MartinDelille

@MartinDelille
Copy link
Contributor

Can you explain the need for this new method ? Also, you would need to re-generate the example if you want the PR to be merge.

@ReallyVirtual
Copy link
Contributor Author

@MartinDelille This PR adds the missing asJsonObject method to the Enum class. When generating the schema for enums, the generated client code does not compile with my FastAPI schemas that use enums, as the client is expecting this method.

The issue is also reported by another person here: #19307

I've generated and pushed the examples.

Copy link
Contributor

@MartinDelille MartinDelille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for you for your edit and your explanation. I indeed don't use edit and had trouble using it one time in the past!

@ReallyVirtual ReallyVirtual force-pushed the fix-cpp-qt-enum-asjsonobject branch from 988e125 to 543675d Compare May 8, 2025 08:41
@ReallyVirtual
Copy link
Contributor Author

Thanks for the fix @wing328 - @MartinDelille: the CI checks are passing now, please reapprove if necessary.

@wing328 wing328 added this to the 7.14.0 milestone May 15, 2025
@wing328 wing328 merged commit bd8a206 into OpenAPITools:master May 15, 2025
18 of 21 checks passed
ReallyVirtual added a commit to ReallyVirtual/openapi-generator that referenced this pull request Sep 2, 2025
…nd referenced enums

For enum query parameters, the template was incorrectly using asJsonObject()
which returns {"value": "enumValue"} and then iterating over keys, using
"value" as the parameter name instead of the actual parameter name.

This fix adds special handling for both inline enums (isEnum) and referenced
enums (isEnumRef) to use asJson() directly, which returns the correct enum
string value for URL serialization.

Fixes enum query parameters like ?scope=property instead of ?value=property.

Completes the fix started in PR OpenAPITools#21211 which added the asJsonObject() method
to make enum code compile, but the template logic was still incorrect for URL
query parameter serialization.

Note: The petstore samples don't contain enum query parameter tests to
demonstrate this fix (they use string arrays). Future contributors may want
to add enum query parameter examples to better showcase this functionality.
wing328 added a commit that referenced this pull request Dec 18, 2025
…nd referenced enums (#22559)

* fix(cpp-qt): Fix enum query parameter serialization for both inline and referenced enums

For enum query parameters, the template was incorrectly using asJsonObject()
which returns {"value": "enumValue"} and then iterating over keys, using
"value" as the parameter name instead of the actual parameter name.

This fix adds special handling for both inline enums (isEnum) and referenced
enums (isEnumRef) to use asJson() directly, which returns the correct enum
string value for URL serialization.

Fixes enum query parameters like ?scope=property instead of ?value=property.

Completes the fix started in PR #21211 which added the asJsonObject() method
to make enum code compile, but the template logic was still incorrect for URL
query parameter serialization.

Note: The petstore samples don't contain enum query parameter tests to
demonstrate this fix (they use string arrays). Future contributors may want
to add enum query parameter examples to better showcase this functionality.

* add tests for enum inline, ref for query parameters

* update cmake version to 3.5

---------

Co-authored-by: Sohaib Athar <[email protected]>
rajvesh pushed a commit to rajvesh/openapi-generator that referenced this pull request Dec 25, 2025
…nd referenced enums (OpenAPITools#22559)

* fix(cpp-qt): Fix enum query parameter serialization for both inline and referenced enums

For enum query parameters, the template was incorrectly using asJsonObject()
which returns {"value": "enumValue"} and then iterating over keys, using
"value" as the parameter name instead of the actual parameter name.

This fix adds special handling for both inline enums (isEnum) and referenced
enums (isEnumRef) to use asJson() directly, which returns the correct enum
string value for URL serialization.

Fixes enum query parameters like ?scope=property instead of ?value=property.

Completes the fix started in PR OpenAPITools#21211 which added the asJsonObject() method
to make enum code compile, but the template logic was still incorrect for URL
query parameter serialization.

Note: The petstore samples don't contain enum query parameter tests to
demonstrate this fix (they use string arrays). Future contributors may want
to add enum query parameter examples to better showcase this functionality.

* add tests for enum inline, ref for query parameters

* update cmake version to 3.5

---------

Co-authored-by: Sohaib Athar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants