Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 2 #1000

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Patch 2 #1000

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Publish

on:
release:
types:
- published
- push

permissions: read-all

Expand 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 }}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"contributors": [
Expand Down
34 changes: 22 additions & 12 deletions templates/base/http-clients/fetch-http-client.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,28 @@ export class HttpClient<SecurityDataType = unknown> {
[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),
}

Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading