Closed Rudomitori closed 1 year ago
If you try to generate client with the following command arguments and swagger.json:
react-query-swagger openapi2tsclient /tanstack /input:swagger.json /output:api-client.ts /template:Axios /serviceHost:. /minimal
{ "openapi": "3.0.0", "info": { "title": "Bug reproduction", "description": "Bug reproduction", "version": "1" }, "paths": { "/api/v1/Answers": { "get": { "tags": [ "Answers" ], "operationId": "Answers_GetAnswers", "parameters": [ { "name": "Tags", "in": "query", "x-position": 7, "content": { "application/json": { "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } } ], "responses": { "200": { "description": "", "content": { "application/json": { "schema": {} } } } } } } } }
You get the following invalid TypeScript code in api-client/AnswersQuery.ts and api-client/AnswersClient.ts:
api-client/AnswersQuery.ts
api-client/AnswersClient.ts
let url_ = getBaseUrl() + "/api/v1/Answers?"; if (tags === null) throw new Error("The parameter 'tags' cannot be null."); else if (tags !== undefined) { const content_ = Types.serialize{ [key: string]: string; }(tags); url_ += "Tags=" + encodeURIComponent(content_) + "&"; }
I think in this case it should be:
const content_ = JSON.stringify(tags);
react-query-swagger version: 15.7.6
Thanks for the report! Fixed in 15.7.9
I've tested it with the latest version and all works fine. Thanks for the quick fix!
If you try to generate client with the following command arguments and swagger.json:
You get the following invalid TypeScript code in
api-client/AnswersQuery.ts
andapi-client/AnswersClient.ts
:I think in this case it should be:
react-query-swagger version: 15.7.6