Skip to content

Commit 7edbb73

Browse files
WangMingHua111Manweill
authored andcommitted
fix: 1、添加 rimraf 解决pnpm本地无rm的问题。 2、拓展 IRequestOptions 定义
1 parent 5a17fa8 commit 7edbb73

File tree

2 files changed

+46
-17
lines changed

2 files changed

+46
-17
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"codegen"
1818
],
1919
"scripts": {
20-
"build": "rm -rf ./dist && tsc -p ./src",
20+
"build": "rimraf -rf ./dist && tsc -p ./src",
2121
"build-win": "rd /s /q dist && tsc -p ./src",
2222
"prestart": "npm run build",
2323
"precommit": "prettier --write --config .prettierrc ./src/*.ts",
@@ -36,6 +36,7 @@
3636
"devDependencies": {
3737
"@types/node": "16",
3838
"@types/prettier": "^1.12.2",
39+
"rimraf": "^5.0.5",
3940
"tslint": "^5.10.0",
4041
"typescript": "^4.8.3"
4142
}

src/templates/serviceHeader.ts

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as fs from 'fs'
22
import * as path from 'path'
3-
import { ISwaggerOptions } from "../baseInterfaces";
4-
import { abpGenericTypeDefinition, universalGenericTypeDefinition } from './genericTypeDefinitionTemplate';
5-
import { trimString } from '../utils';
3+
import { ISwaggerOptions } from '../baseInterfaces'
4+
import { abpGenericTypeDefinition, universalGenericTypeDefinition } from './genericTypeDefinitionTemplate'
65

76
export function serviceHeader(options: ISwaggerOptions) {
87
const classTransformerImport = options.useClassTransformer
98
? `import { Expose, Transform, Type, plainToClass } from 'class-transformer';
10-
` : '';
9+
`
10+
: ''
1111
return `/** Generate by swagger-axios-codegen */
1212
/* eslint-disable */
1313
// @ts-nocheck
@@ -16,9 +16,23 @@ export function serviceHeader(options: ISwaggerOptions) {
1616
${classTransformerImport}
1717
1818
export interface IRequestOptions extends AxiosRequestConfig {
19-
/** only in axios interceptor config*/
20-
loading?:boolean;
21-
showError?:boolean;
19+
/**
20+
* show loading status
21+
*/
22+
loading?: boolean;
23+
/**
24+
* display error message
25+
*/
26+
showError?: boolean;
27+
/**
28+
* data security, extended fields are encrypted using the specified algorithm
29+
*/
30+
security?: Record<string, 'md5' | 'sha1' | 'aes' | 'des'>;
31+
/**
32+
* indicates whether Authorization credentials are required for the request
33+
* @default true
34+
*/
35+
withAuthorization?: boolean;
2236
}
2337
2438
export interface IRequestConfig {
@@ -38,27 +52,41 @@ export function serviceHeader(options: ISwaggerOptions) {
3852
}
3953
4054
${requestHeader()}
41-
`;
55+
`
4256
}
4357

4458
export function disableLint() {
4559
return `/** Generate by swagger-axios-codegen */
4660
// @ts-nocheck
4761
/* eslint-disable */
4862
49-
`}
50-
63+
`
64+
}
5165

5266
export function customerServiceHeader(options: ISwaggerOptions) {
53-
5467
return `/** Generate by swagger-axios-codegen */
5568
// @ts-nocheck
5669
/* eslint-disable */
57-
export interface IRequestOptions {
58-
headers?: any;
59-
/** only in axios interceptor config*/
60-
loading:boolean;
61-
showError:boolean;
70+
import axiosStatic, { AxiosInstance, AxiosRequestConfig } from 'axios';
71+
72+
export interface IRequestOptions extends AxiosRequestConfig {
73+
/**
74+
* show loading status
75+
*/
76+
loading?: boolean;
77+
/**
78+
* display error message
79+
*/
80+
showError?: boolean;
81+
/**
82+
* data security, extended fields are encrypted using the specified algorithm
83+
*/
84+
security?: Record<string, 'md5' | 'sha1' | 'aes' | 'des'>;
85+
/**
86+
* indicates whether Authorization credentials are required for the request
87+
* @default true
88+
*/
89+
withAuthorization?: boolean;
6290
}
6391
6492
export interface IRequestPromise<T=any> extends Promise<IRequestResponse<T>> {}

0 commit comments

Comments
 (0)