[typescript-axios] doesn't serialize deepObject query params
See original GitHub issueBug 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?
input:
{day: 20, year: {min: 1990, max: 2000}}
actual output:?day=20&year
expected output:?day=20&year[min]=1990&year[max]=2000
Description
I’m using [typescript-axios] api client generator. Some of the properties I pass to it specified as deepObject
. It looks that it doesn’t support this type of args at all. Is there any possible ways to fix it?
openapi-generator version
v4.3.1 v5.0.0-beta
OpenAPI declaration file content or url
YearRange:
in: query
name: year
required: false
style: deepObject
schema:
type: object
properties:
min:
type: string
example: 2010
max:
type: string
example: 2019
Generation Details
[typescript-axios] generator
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/6075
Suggest a fix
Replace old deprecated url API with URLSearchParams.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9
Top Results From Across the Web
swagger-codegen wont generate query parameter objects
1) Your query parameter is defined using content.application-json , which means the parameter is serialized as a JSON string i.e. /plans?filter ...
Read more >serialize-query-params - npm
A library for simplifying encoding and decoding URL query parameters.. Latest version: 2.0.2, last published: 10 days ago.
Read more >Parameter Serialization - Swagger
Parameter Serialization · style defines how multiple values are delimited. Possible styles depend on the parameter location – path, query, header or cookie....
Read more >OpenAPI JSON Objects as Query Parameters - Baeldung
OpenAPI 2 doesn't support objects as query parameters; only primitive values and arrays of primitives are supported.
Read more >Does Stoplight support query parameters?
... Stoplight supports query params but not all serialization options. This means that common ways of doing query params, like deepObject, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have made a workaround but I think that it will be good to add it to the generator.
I’ve just had a similar problem. Loopback 4 expects filter parameters as serialised JSON.
It can be solved in a ‘nice’ way using template overrides.
openapi-templates
apiInner.mustache
intoopenapi-templates
from https://github.com/OpenAPITools/openapi-generator/blob/7ffd0711c3c3e7e08110a3e8d63e324daa1773d8/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustachelocalVarQueryParameter
. My example is below.-t /path/to/openapi-templates
toopenapi-generator-cli
I modified the template to serialise any object passed as a parameter to JSON:
@wamujlb - In your case, you could probably add your code to the template.