From bb69900e0ddaea1cc1671853dfaa79760b32aa95 Mon Sep 17 00:00:00 2001 From: Untaek Date: Fri, 24 May 2024 13:07:10 +0900 Subject: [PATCH 1/6] fetch client handle formdata with array of file properly --- .../base/http-clients/fetch-http-client.ejs | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/templates/base/http-clients/fetch-http-client.ejs b/templates/base/http-clients/fetch-http-client.ejs index a1db3833e..18af63659 100644 --- a/templates/base/http-clients/fetch-http-client.ejs +++ b/templates/base/http-clients/fetch-http-client.ejs @@ -105,18 +105,28 @@ export class HttpClient { [ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, [ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input, [ContentType.FormData]: (input: any) => - Object.keys(input || {}).reduce((formData, key) => { - const property = input[key]; - formData.append( - key, - property instanceof Blob ? - property : - typeof property === "object" && property !== null ? - JSON.stringify(property) : - `${property}` - ); - return formData; - }, new FormData()), + { + const append = (formData: FormData, key: string, value: any) => formData.append( + key, + value instanceof Blob + ? value + : typeof value === 'object' && value !== null + ? JSON.stringify(value) + : `${value}`, + ) + + return Object.keys(input || {}).reduce((formData, key) => { + const property = input[key] + if (Array.isArray(property) && property.length === property.filter(p => p instanceof Blob).length) { + property.forEach(element => { + append(formData, key, element) + }) + } else { + append(formData, key, property) + } + return formData + }, new FormData()) + }, [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), } From 4ce5394ac4f22ff86cc83504cb6ff979d9e5440b Mon Sep 17 00:00:00 2001 From: Untaek Date: Sun, 1 Dec 2024 22:08:39 +0900 Subject: [PATCH 2/6] Update publish.yml --- .github/workflows/publish.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 564e6d563..02fda99aa 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,9 +1,7 @@ name: Publish on: - release: - types: - - published + - push permissions: read-all From e1098bf394a81e961abf7fc04569214638034470 Mon Sep 17 00:00:00 2001 From: Untaek Date: Sun, 1 Dec 2024 22:12:41 +0900 Subject: [PATCH 3/6] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cba7cf6bd..99e48a9de 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "swagger-typescript-api", + "name": "swagger-typescript-api-untaek", "version": "13.0.22", "description": "Generate the API client for Fetch or Axios from an OpenAPI Specification", "homepage": "https://github.com/acacode/swagger-typescript-api", From 640699148b28699873ac5c8abcdaa20e37fba706 Mon Sep 17 00:00:00 2001 From: Untaek Date: Sun, 1 Dec 2024 22:16:39 +0900 Subject: [PATCH 4/6] Update yarn.lock --- yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index c0b1f01a8..373eeb019 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2522,9 +2522,9 @@ __metadata: languageName: node linkType: hard -"swagger-typescript-api@workspace:.": +"swagger-typescript-api-untaek@workspace:.": version: 0.0.0-use.local - resolution: "swagger-typescript-api@workspace:." + resolution: "swagger-typescript-api-untaek@workspace:." dependencies: "@biomejs/biome": "npm:1.9.4" "@tsconfig/node18": "npm:18.2.4" From 226cc1227df717a1a5f681b6fc67274784276b71 Mon Sep 17 00:00:00 2001 From: Untaek Date: Sun, 1 Dec 2024 22:23:17 +0900 Subject: [PATCH 5/6] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 99e48a9de..5f672decd 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Generate the API client for Fetch or Axios from an OpenAPI Specification", "homepage": "https://github.com/acacode/swagger-typescript-api", "bugs": "https://github.com/acacode/swagger-typescript-api/issues", - "repository": "github:acacode/swagger-typescript-api", + "repository": "github:Untaek/swagger-typescript-api", "license": "MIT", "author": "Sergey Volkov ", "contributors": [ From 9199300febf3fe888aa60a5bc9a1001012c21ca2 Mon Sep 17 00:00:00 2001 From: Untaek Date: Sun, 1 Dec 2024 22:25:54 +0900 Subject: [PATCH 6/6] Update publish.yml --- .github/workflows/publish.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 02fda99aa..a8ea2c57f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,6 +27,8 @@ jobs: - run: yarn install --immutable - - run: yarn npm publish --tolerate-republish + - run: yarn build + + - run: yarn npm publish env: NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}