[BUG][typescript-fetch] deepObject serialization not supported in query string
Created by: Dijky
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
A query parameter of type: object
using additionalProperties
produces Typescript code that fails to compile.
A similar parameter without additionalProperties
that instead specifies properties compiles properly, but serializes the parameter improperly.
additionalProperties
Typescript compiler error with api/test/apis/DefaultApi.ts
Type error: Type '{ [key: string]: number; }' is not assignable to type 'string | number | boolean | (string | number | boolean)[]'.
Type '{ [key: string]: number; }' is not assignable to type 'string'. TS2322
30 |
31 | if (requestParameters.foffset !== undefined) {
> 32 | queryParameters['foffset'] = requestParameters.foffset;
| ^
33 | }
34 |
35 | const headerParameters: runtime.HTTPHeaders = {};
Invalid serialization with specified properties
The parameter is decoded to the string representation of an object in Javascript:
foffset=%5Bobject%20Object%5D
(URL encoded)
foffset=[object Object]
(URL decoded)
openapi-generator version
v4.0.0-beta2
As far as I can tell, there have been no relevant changes on master
.
OpenAPI declaration file
openapi: 3.0.0
info:
title: Test API
version: 0.0.1
paths:
/search:
get:
parameters:
- name: foffset
in: query
required: false
schema:
type: object
additionalProperties:
type: integer
responses:
'200':
description: OK
Command line used for generation
openapi-generator generate -g typescript-fetch -i ./test.openapi.yml -o api/
Steps to reproduce
- Specify a query parameter of
type: object
. - Generate
typescript-fetch
client code. - Include/compile the generated API typescript file (
additionalProperties
variant fails here). - Perform an API request providing an object for the parameter.
Related issues/PRs
Possibly related to PR #569 and Issue #802 (closed).
Suggest a fix
I'm working on a first pull request.
The idea is to allow nested HTTPQuery
objects that are recursively serialized.