Skip to content

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

@bhahn57570

Description

@bhahn57570

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions