@fxri/swagger2api 1.1.9 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
const { apiConfig, generateResponses, config } = it;
|
|
3
3
|
%>
|
|
4
4
|
|
|
5
|
-
import type { AxiosInstance, AxiosRequestConfig, HeadersDefaults, ResponseType, AxiosResponse
|
|
5
|
+
import type { AxiosInstance, AxiosRequestConfig, HeadersDefaults, ResponseType, AxiosResponse } from "axios";
|
|
6
6
|
import axios from "axios";
|
|
7
7
|
|
|
8
8
|
export type QueryParamsType = Record<string | number, any>;
|
|
9
9
|
|
|
10
10
|
<% if (config.param?.extractResponseRaw) { %>
|
|
11
11
|
/** 提取响应 */
|
|
12
|
-
export interface
|
|
12
|
+
export interface AxiosResponseRaw<T = any> {
|
|
13
13
|
/** 原始数据 */
|
|
14
|
-
raw:
|
|
14
|
+
raw: AxiosResponse<T>;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
<% } %>
|
|
@@ -117,6 +117,8 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
117
117
|
...params
|
|
118
118
|
<% if (config.unwrapResponseData) { %>
|
|
119
119
|
}: FullRequestParams): Promise<T> => {
|
|
120
|
+
<% } else if (config.param?.extractResponseRaw) { %>
|
|
121
|
+
}: FullRequestParams): Promise<AxiosResponseRaw<T>> => {
|
|
120
122
|
<% } else { %>
|
|
121
123
|
}: FullRequestParams): Promise<AxiosResponse<T>> => {
|
|
122
124
|
<% } %>
|
|
@@ -77,7 +77,7 @@ const describeReturnType = () => {
|
|
|
77
77
|
|
|
78
78
|
switch(config.httpClientType) {
|
|
79
79
|
case HTTP_CLIENT.AXIOS: {
|
|
80
|
-
return `Promise<AxiosResponse<${type}>>`
|
|
80
|
+
return config.param?.extractResponseRaw ? `Promise<AxiosResponseRaw<${type}>>` : `Promise<AxiosResponse<${type}>>`
|
|
81
81
|
}
|
|
82
82
|
default: {
|
|
83
83
|
return `Promise<HttpResponse<${type}, ${errorType}>`
|