OpenAPITools / OpenAPITools/openapi-generator

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

Open
#23,895 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

In my C# WebAPI I have a key[(key/value)] query param ([FromQuery] IDictionary<string, IDictionary<string, string>> properties) producing the following OpenAPI schema:

{ "name": "properties", "in": "query", "schema": { "type": "object", "additionalProperties": { "type": "object", "additionalProperties": { "type": "string" } } } },

Generator 7.11 recursively added the properties so that e.g. an object {a:{x:1}} was passed as a.x=1 to the query params:

Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive(
   httpParams, value[k], key != null ? `${key}.${k}` : k));

The current version doesn't include the key:

if (explode) {
   Object.keys(value).forEach(k => {
      httpParams = this.addToHttpParams(httpParams, k, value[k], paramStyle, explode);
   });
   return httpParams;
}

always resulting in x=1. The full path to the property is lost. I guess the old logic needed to be used here, too but this will sure change the current behavior (what just is wrong, isn't it?). I'm going to create a PR immediatelly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Angular generator code containing addToHttpParamsRecursive and addToHttpParams, then compare the current explode handling with the recursive behavior described in the issue. Reproduce a nested object such as {a:{x:1}} and verify that serialization preserves the full property path, producing a.x=1 rather than x=1.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.