diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 564e6d56..a8ea2c57 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 @@ -29,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 }} diff --git a/package.json b/package.json index cba7cf6b..5f672dec 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "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", "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": [ diff --git a/templates/base/http-clients/fetch-http-client.ejs b/templates/base/http-clients/fetch-http-client.ejs index a1db3833..18af6365 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), } diff --git a/yarn.lock b/yarn.lock index c0b1f01a..373eeb01 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"