Skip to content

Commit

Permalink
fix: 1、添加 rimraf 解决pnpm本地无rm的问题。 2、拓展 IRequestOptions 定义
Browse files Browse the repository at this point in the history
  • Loading branch information
WangMingHua111 authored and Manweill committed Dec 1, 2023
1 parent 5a17fa8 commit 7edbb73
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"codegen"
],
"scripts": {
"build": "rm -rf ./dist && tsc -p ./src",
"build": "rimraf -rf ./dist && tsc -p ./src",
"build-win": "rd /s /q dist && tsc -p ./src",
"prestart": "npm run build",
"precommit": "prettier --write --config .prettierrc ./src/*.ts",
Expand All @@ -36,6 +36,7 @@
"devDependencies": {
"@types/node": "16",
"@types/prettier": "^1.12.2",
"rimraf": "^5.0.5",
"tslint": "^5.10.0",
"typescript": "^4.8.3"
}
Expand Down
60 changes: 44 additions & 16 deletions src/templates/serviceHeader.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as fs from 'fs'
import * as path from 'path'
import { ISwaggerOptions } from "../baseInterfaces";
import { abpGenericTypeDefinition, universalGenericTypeDefinition } from './genericTypeDefinitionTemplate';
import { trimString } from '../utils';
import { ISwaggerOptions } from '../baseInterfaces'
import { abpGenericTypeDefinition, universalGenericTypeDefinition } from './genericTypeDefinitionTemplate'

export function serviceHeader(options: ISwaggerOptions) {
const classTransformerImport = options.useClassTransformer
? `import { Expose, Transform, Type, plainToClass } from 'class-transformer';
` : '';
`
: ''
return `/** Generate by swagger-axios-codegen */
/* eslint-disable */
// @ts-nocheck
Expand All @@ -16,9 +16,23 @@ export function serviceHeader(options: ISwaggerOptions) {
${classTransformerImport}
export interface IRequestOptions extends AxiosRequestConfig {
/** only in axios interceptor config*/
loading?:boolean;
showError?:boolean;
/**
* show loading status
*/
loading?: boolean;
/**
* display error message
*/
showError?: boolean;
/**
* data security, extended fields are encrypted using the specified algorithm
*/
security?: Record<string, 'md5' | 'sha1' | 'aes' | 'des'>;
/**
* indicates whether Authorization credentials are required for the request
* @default true
*/
withAuthorization?: boolean;
}
export interface IRequestConfig {
Expand All @@ -38,27 +52,41 @@ export function serviceHeader(options: ISwaggerOptions) {
}
${requestHeader()}
`;
`
}

export function disableLint() {
return `/** Generate by swagger-axios-codegen */
// @ts-nocheck
/* eslint-disable */
`}

`
}

export function customerServiceHeader(options: ISwaggerOptions) {

return `/** Generate by swagger-axios-codegen */
// @ts-nocheck
/* eslint-disable */
export interface IRequestOptions {
headers?: any;
/** only in axios interceptor config*/
loading:boolean;
showError:boolean;
import axiosStatic, { AxiosInstance, AxiosRequestConfig } from 'axios';
export interface IRequestOptions extends AxiosRequestConfig {
/**
* show loading status
*/
loading?: boolean;
/**
* display error message
*/
showError?: boolean;
/**
* data security, extended fields are encrypted using the specified algorithm
*/
security?: Record<string, 'md5' | 'sha1' | 'aes' | 'des'>;
/**
* indicates whether Authorization credentials are required for the request
* @default true
*/
withAuthorization?: boolean;
}
export interface IRequestPromise<T=any> extends Promise<IRequestResponse<T>> {}
Expand Down

0 comments on commit 7edbb73

Please sign in to comment.