From 9a5efccf0d475e690c8d2707107dd203284fc78a Mon Sep 17 00:00:00 2001 From: sup39 Date: Sat, 23 Jul 2022 17:29:45 +0900 Subject: [PATCH] Fix axios query of array type in IClientAPI --- README.md | 2 ++ dist/codegen.js | 2 +- lib/codegen.ts | 2 +- package.json | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 78c2165..3fd3c2a 100644 --- a/README.md +++ b/README.md @@ -608,6 +608,8 @@ interface Task { This tool only supports `application/json` type for request and response body. Any other type like `multipart/form` or `image/*` are **not supported** and will be ignored. ## Versions +#### 2.1.2 +- Fix axios query of array type in IClientAPI (add `{arrayFormat: 'repeat'}`) #### 2.1.1 - Fix axios type bug (`AxiosPromise` vs `Promise`) #### 2.1.0 diff --git a/dist/codegen.js b/dist/codegen.js index a620d33..11dd7b1 100644 --- a/dist/codegen.js +++ b/dist/codegen.js @@ -166,7 +166,7 @@ function codegenClientAPI(funcs, config, cp) { // axios cp.writeln('const $http = axios.create({', 1); cp.writeln('validateStatus: () => true,'); - cp.writeln('paramsSerializer: params => qStringify(params),'); + cp.writeln("paramsSerializer: params => qStringify(params, {arrayFormat: 'repeat'}),"); cp.writeln('});', -1); // function cp.writeln('\nfunction urlReplacer(url: string, ' + diff --git a/lib/codegen.ts b/lib/codegen.ts index c52ca2d..c5a5bd9 100644 --- a/lib/codegen.ts +++ b/lib/codegen.ts @@ -171,7 +171,7 @@ function codegenClientAPI(funcs: APIFuncs, config: Config, cp: CodePrinter) { // axios cp.writeln('const $http = axios.create({', 1); cp.writeln('validateStatus: () => true,'); - cp.writeln('paramsSerializer: params => qStringify(params),'); + cp.writeln(`paramsSerializer: params => qStringify(params, {arrayFormat: 'repeat'}),`); cp.writeln('});', -1); // function cp.writeln('\nfunction urlReplacer(url: string, ' + diff --git a/package.json b/package.json index 1f5de30..e83c4ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sup39/api-ts-gen", - "version": "2.1.1-rc", + "version": "2.1.2", "description": "OpenAPI code generator for TypeScript", "main": "dist/lib/index.js", "types": "dist/lib/index.d.ts",