OpenAPITools / OpenAPITools/openapi-generator
[BUG] [typescript] Get Parameter Object not serialized properly
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I am trying to serialize an object into an array.
The GET Url should be generated like this
http://localhost/index?filter[contact]=101d71e1-745e-4efc-8341-ad204bb1c5c7&page=1&count=8
but it generates like this
http://localhost/index/?filter=%5Bobject%20Object%5D&page=1&count=8
openapi-generator version
5.0.0-beta
OpenAPI declaration file content or url
{
"openapi":"3.0.0",
"info":{
"title":"Demo API",
"description":"",
"version":"1.0.0"
},
"servers":[
{
"url":"http:\/\/localhost"
}
],
"paths":{
"\/index":{
"get":{
"tags":[
"Index"
],
"summary":"Returns all Index.",
"operationId":"search",
"parameters":[
{
"name":"filter",
"in":"query",
"schema":{
"$ref":"#\/components\/schemas\/IndexFilterType"
}
},
{
"name":"page",
"in":"query",
"description":"The page number",
"schema":{
"type":"number"
}
},
{
"name":"count",
"in":"query",
"description":"items per page to load",
"schema":{
"type":"number"
}
}
],
"responses":{
"200":{
"description":"",
"content":{
"application\/json":{
"schema":{
"$ref":"#\/components\/schemas\/IndexResponse"
}
}
}
}
}
},
}
},
"components":{
"schemas":{
"IndexFilterType":{
"type":"object",
"properties": {
"contact": {
"type": "string"
}
},
},
"IndexResponse":{
"properties":{
"status":{
"type":"string"
},
"data":{
"type":"array",
"items":{
"$ref":"#\/components\/schemas\/MetaDto"
}
},
"total":{
"type":"number"
},
"pages":{
"type":"number"
}
},
"type":"object"
},
"MetaDto":{
"properties":{
"id":{
"type":"string"
},
"contact":{
"$ref":"#\/components\/schemas\/ContactDto"
},
"lead":{
"$ref":"#\/components\/schemas\/ContactDto"
},
"title":{
"type":"string"
},
"number":{
"type":"integer"
}
},
"type":"object"
},
"ContactDto":{
"properties":{
"id":{
"type":"string"
},
"display_name":{
"type":"string"
},
"short_name":{
"type":"string"
},
"initials":{
"type":"string"
},
"type":{
"type":"string"
},
"pre_name":{
"type":"string"
},
"last_name":{
"type":"string"
},
"title":{
"type":"string"
},
"sex":{
"type":"string"
},
"company_name":{
"type":"string"
},
"birthday":{
"type":"string"
},
"tax_id":{
"type":"string"
},
"salutation":{
"type":"string"
},
"avatar":{
"$ref":"#\/components\/schemas\/FileMetaDto"
}
},
"type":"object"
},
"FileMetaDto":{
"properties":{
"id":{
"type":"string"
},
"filename":{
"type":"string"
},
"mime_type":{
"type":"string"
},
"file_size":{
"title":"Filesize in Bytes",
"type":"integer"
},
"url":{
"type":"string"
}
},
"type":"object"
}
}
}
}
Generation Details
openapi-generator generate -i http://localhost/swagger.json -g typescript
Steps to reproduce
- See schema and generation details
Related issues/PRs
Maybe this? https://github.com/OpenAPITools/openapi-generator/issues/100
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 reproducing the generated TypeScript client from the supplied OpenAPI declaration with the shown openapi-generator command, then trace its GET query-parameter serialization. Done means the filter object produces a URL containing filter[contact]=101d71e1-745e-4efc-8341-ad204bb1c5c7 instead of [object Object], while page and count remain serialized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100