Skip to content

Commit

Permalink
fix: swag-axios params error
Browse files Browse the repository at this point in the history
  • Loading branch information
mao committed Mar 16, 2023
1 parent e9a80fc commit 404bca7
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 5 deletions.
8 changes: 8 additions & 0 deletions packages/apipgen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# apipgen

## 0.3.14

### Patch Changes

- Updated dependencies
- [email protected]
- [email protected]

## 0.3.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/apipgen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apipgen",
"version": "0.3.13",
"version": "0.3.14",
"description": "Generator Api",
"author": "Hairy",
"license": "ISC",
Expand Down
10 changes: 10 additions & 0 deletions packages/swag-axios-js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# apipgen-swag-js

## 0.2.0

### Minor Changes

- fix: swag-axios params error

### Patch Changes

- [email protected]

## 0.1.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/swag-axios-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apipgen-swag-axios-js",
"version": "0.1.12",
"version": "0.2.0",
"description": "",
"author": "",
"license": "ISC",
Expand Down
4 changes: 3 additions & 1 deletion packages/swag-axios-js/src/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function transformPaths(paths: Paths, { configRead, functions, interfaces
name: 'config',
required: false,
})
options.unshift('url')
options.unshift(['method', `"${config.method}"`])
if (configRead.config.baseURL)
options.unshift('baseURL')
Expand All @@ -86,7 +87,8 @@ export function transformPaths(paths: Paths, { configRead, functions, interfaces
description,
parameters,
body: [
`return http.request(${url}, { ${literalFieldsToString(options)} })`,
`const url = ${url}`,
`return http.request({ ${literalFieldsToString(options)} })`,
],
})
})
Expand Down
10 changes: 10 additions & 0 deletions packages/swag-axios-ts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# apipgen-swag-axios-ts

## 0.2.0

### Minor Changes

- fix: swag-axios params error

### Patch Changes

- [email protected]

## 0.1.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/swag-axios-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apipgen-swag-axios-ts",
"version": "0.1.11",
"version": "0.2.0",
"description": "",
"author": "",
"license": "ISC",
Expand Down
4 changes: 3 additions & 1 deletion packages/swag-axios-ts/src/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function transformPaths(paths: Paths, { configRead, functions, interfaces
type: 'AxiosRequestConfig',
required: false,
})
options.unshift('url')
options.unshift(['method', `"${config.method}"`])
if (configRead.config.baseURL)
options.unshift('baseURL')
Expand All @@ -85,7 +86,8 @@ export function transformPaths(paths: Paths, { configRead, functions, interfaces
description,
parameters,
body: [
`return http.request<${spaceResponseType}>(${url},{ ${literalFieldsToString(options)} })`,
`const url = ${url}`,
`return http.request<${spaceResponseType}>({ ${literalFieldsToString(options)} })`,
],
})
})
Expand Down

0 comments on commit 404bca7

Please sign in to comment.