diff --git a/package.json b/package.json index 4f34549..3b0ea1b 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" } diff --git a/src/templates/serviceHeader.ts b/src/templates/serviceHeader.ts index a8c712e..72c47b1 100644 --- a/src/templates/serviceHeader.ts +++ b/src/templates/serviceHeader.ts @@ -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 @@ -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; + /** + * indicates whether Authorization credentials are required for the request + * @default true + */ + withAuthorization?: boolean; } export interface IRequestConfig { @@ -38,7 +52,7 @@ export function serviceHeader(options: ISwaggerOptions) { } ${requestHeader()} - `; + ` } export function disableLint() { @@ -46,19 +60,33 @@ export function disableLint() { // @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; + /** + * indicates whether Authorization credentials are required for the request + * @default true + */ + withAuthorization?: boolean; } export interface IRequestPromise extends Promise> {}