Skip to content

Conversation

@winrid
Copy link
Contributor

@winrid winrid commented Jan 8, 2026

Fixes #12737

  • Basically support for map<string, map<string, string>> was broken.
  • Also fixes "additionalProperties" and adds a test.

Summary by cubic

Fix nested map generation in C++ (Qt, RestSDK, Tiny) so map<string, map<string, string>> types resolve and compile. Also add additionalProperties support to cpp-restsdk models to capture and serialize unknown fields. Fixes #12737.

  • Bug Fixes

    • Resolve $ref-ed map schemas in CppQtAbstractCodegen, CppRestSdkClientCodegen, and CppTinyClientCodegen to properly type nested maps.
    • Generate correct map types (QMap/std::map) in type declarations and defaults; add std::map mapping and includes in cpp-tiny.
    • Update cpp-tiny templates to use actual map types in getters, setters, and fields (no hard-coded <string, string>).
    • Add a nested-maps test spec and extend petstore with StringMap, NestedStringMap, and PetStatistics; generate sample models to validate JSON (de)serialization.
  • New Features

    • cpp-restsdk: support additionalProperties on models with defined properties; store unknown keys in std::map<utility::string_t, web::json::value> and include them in JSON (de)serialization; add SchemaWithPropsAndAddlProps sample.

Written for commit d5f82ef. Summary will update on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 23 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppTinyClientCodegen.java">

<violation number="1" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppTinyClientCodegen.java:281">
P1: Potential NullPointerException: `ModelUtils.getAdditionalProperties(resolved)` can return null when `additionalProperties` is a boolean or not present. Consider adding a null check before calling `getTypeDeclaration(inner)`.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@winrid winrid changed the title [cpp] Fix Nested Map Support [cpp] Fix Nested Map & Additional Properties Support Jan 8, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 7 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java">

<violation number="1" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java:398">
P2: Method inserted in wrong location - this separates the existing JavaDoc for `getTypeDeclaration()` from its method. The `isPureMapSchema()` helper should be placed either before that JavaDoc block or after the `getTypeDeclaration()` method to preserve the documentation association.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@winrid
Copy link
Contributor Author

winrid commented Jan 9, 2026

Ready for review @muttleyxd @aminya

@winrid winrid changed the title [cpp] Fix Nested Map & Additional Properties Support [BUG][cpp] Fix Nested Map & Additional Properties Support Jan 9, 2026
@winrid winrid changed the title [BUG][cpp] Fix Nested Map & Additional Properties Support [cpp] Fix Nested Map & Additional Properties Support Jan 9, 2026
@winrid winrid requested a review from aminya January 9, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][C++][cpp-restsdk] cpp-restsdk not able to handle maps with nested schemas ("additionalProperties")

2 participants