Skip to content

[typescript-angular] Fix recursive Query-Param Object name#23896

Open
angelaki wants to merge 3 commits into
OpenAPITools:masterfrom
angelaki:recursive-query-params
Open

[typescript-angular] Fix recursive Query-Param Object name#23896
angelaki wants to merge 3 commits into
OpenAPITools:masterfrom
angelaki:recursive-query-params

Conversation

@angelaki
Copy link
Copy Markdown
Contributor

@angelaki angelaki commented May 28, 2026

Fixes #23895


Summary by cubic

Fixes nested query param naming and serialization in the typescript-angular generator. Form+explode now prefixes child keys with dot notation (e.g., user.name), and DeepObject recurses with bracket notation (e.g., options[foo][0]) to preserve structure and avoid collisions (fixes #23895).

  • Bug Fixes
    • For Form + explode objects, recurse with ${key}.${k} in api.base.service.mustache.
    • Route DeepObject through a private addToHttpParamsDeepObject to serialize nested objects/arrays/sets with ${key}[...]; updated tests and sample outputs.

Written for commit 66bad2b. Summary will update on new commits.

Review in cubic

Copy link
Copy Markdown
Contributor

@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 20 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@wing328
Copy link
Copy Markdown
Member

wing328 commented Jun 1, 2026

thanks for the PR

cc @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) @joscha (2024/10) @dennisameling (2026/02)

@wing328 wing328 changed the title Fix recursive Query-Param Object name [typescript-angular] Fix recursive Query-Param Object name Jun 1, 2026
Copy link
Copy Markdown
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

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

thanks for the fix!

@macjohnny
Copy link
Copy Markdown
Member

@angelaki please update the failing tests

@angelaki
Copy link
Copy Markdown
Contributor Author

angelaki commented Jun 1, 2026

@macjohnny could you please check the discussion here: #23895. Guess the final solution still needs to be clearified.

And sorry but I'm not quite sure how to check those tests. Even don't get why it should break Angular 20 but no other tests?

@angelaki
Copy link
Copy Markdown
Contributor Author

angelaki commented Jun 2, 2026

I've added a fix for DeepObject now. Sorry but don't have a Java Environment set up. Would be super great if someone could support me here / verify this fix.

It's actually not tested, just "assumed"!

Copy link
Copy Markdown
Contributor

@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.

2 issues found across 21 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="samples/client/petstore/typescript-angular-v19/builds/default/api.base.service.ts">

<violation number="1" location="samples/client/petstore/typescript-angular-v19/builds/default/api.base.service.ts:97">
P2: DeepObject recursion lacks cycle handling, causing stack overflow on cyclic input objects</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/typescript-angular/api.base.service.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/typescript-angular/api.base.service.mustache:103">
P1: `Object.entries` is not available under the generator’s current TypeScript lib setup, so this change breaks generated Angular builds/type-checking.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

});
return httpParams;
} else {
return Object.entries(value).reduce(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1: Object.entries is not available under the generator’s current TypeScript lib setup, so this change breaks generated Angular builds/type-checking.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/typescript-angular/api.base.service.mustache, line 103:

<comment>`Object.entries` is not available under the generator’s current TypeScript lib setup, so this change breaks generated Angular builds/type-checking.</comment>

<file context>
@@ -85,4 +85,25 @@ export class BaseService {
+            });
+            return httpParams;
+        } else {
+            return Object.entries(value).reduce(
+                (hp, [k, v]) => this.addToHttpParamsDeepObject(hp, `${key}[${k}]`, v),
+                httpParams,
</file context>
Suggested change
return Object.entries(value).reduce(
return Object.keys(value).reduce(
(hp, k) => this.addToHttpParamsDeepObject(hp, `${key}[${k}]`, value[k]),
httpParams,
);

}
}

private addToHttpParamsDeepObject(httpParams: OpenApiHttpParams, key: string, value: any | null | undefined): OpenApiHttpParams {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: DeepObject recursion lacks cycle handling, causing stack overflow on cyclic input objects

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/typescript-angular-v19/builds/default/api.base.service.ts, line 97:

<comment>DeepObject recursion lacks cycle handling, causing stack overflow on cyclic input objects</comment>

<file context>
@@ -93,4 +93,25 @@ export class BaseService {
         }
     }
+
+    private addToHttpParamsDeepObject(httpParams: OpenApiHttpParams, key: string, value: any | null | undefined): OpenApiHttpParams {
+        if (value == null) {
+            return httpParams;
</file context>

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.

[BUG] [Angular] Form-Query-Params for recursive objects don't include property path

3 participants