Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Change in addToHttpParams function lead to json encoding error - Regression 7.12 #20980

Open
2 of 6 tasks
bhahn57570 opened this issue Mar 27, 2025 · 0 comments
Open
2 of 6 tasks

Comments

@bhahn57570
Copy link

bhahn57570 commented Mar 27, 2025

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

There is a change in the post httparams behaviour in the typescript services with the base Service new implementation

openapi-generator version

7.11 was fine 7.12 add a regression

Bug

The function addToHttpParams in 7.11 version

// @ts-ignore
private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
if (typeof value === "object" && value instanceof Date === false) {
httpParams = this.addToHttpParamsRecursive(httpParams, value);
} else {
httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
}
return httpParams;
}

With this implementation the output was http://localhost:8090/api/persons?name=dd for a simple object containing a variable name

Now the new implementation

protected addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
// If the value is an object (but not a Date), recursively add its keys.
if (typeof value === 'object' && !(value instanceof Date)) {
return this.addToHttpParamsRecursive(httpParams, value, key);
}
return this.addToHttpParamsRecursive(httpParams, value, key);
}

Is producing the output http://localhost:8090/api/persons?criteria=%7B%22name%22%3A%22eee%22%7D.
The else is missing, then a json is used as a query parameter and then enconded.

@bhahn57570 bhahn57570 changed the title [BUG] Change in addToHttpParams functioon ead to json encoding error [BUG] Change in addToHttpParams function lead to json encoding error Mar 27, 2025
@bhahn57570 bhahn57570 changed the title [BUG] Change in addToHttpParams function lead to json encoding error [BUG] Change in addToHttpParams function lead to json encoding error - Regression 7.12 Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant