swagger-api / swagger-api/swagger-codegen
Wrong HttpParams generation for { [key: string]: Array<string>; }
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
By default AspNetCore supports parameters either of type IDictionary<string, string> or even IDictionary<string, IEnumerable<string>> (e.g. for queries like /get?id=1&id=2).
Technically this is perfectly correct and swagger-codegen (at least typescript-angular) supports the first scenario:
order?: Array<string>
if (order) {
order.forEach((element) => {
queryParameters = queryParameters.append('order', <any>element);
})
}
but seams to have issues with the second one:
paramProperties?: { [key: string]: Array<string>; }
if (paramProperties !== undefined && paramProperties !== null) {
queryParameters = queryParameters.set('paramProperties', <any>paramProperties);
}
This way a serialized objects gets added to the HttpParams.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the typescript-angular generation logic for dictionary-valued query parameters and compare it with the shown Array handling. Verify generated HttpParams for paramProperties: { [key: string]: Array } preserves repeated query values instead of serializing the object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100