From 688c89c915cd3eae325d031123168a55e7d8e30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=98=8E=E5=8D=8E?= <735161977@qq.com> Date: Mon, 8 Jan 2024 20:39:02 +0800 Subject: [PATCH] refactor: classNameMode?: 'parentPath' | 'normal' | ((path: string, method: string, reqProps:IRequestMethod) => string) --- src/baseInterfaces.ts | 2 +- src/requestCodegen/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/baseInterfaces.ts b/src/baseInterfaces.ts index de5dd7c..e2c78d5 100644 --- a/src/baseInterfaces.ts +++ b/src/baseInterfaces.ts @@ -4,7 +4,7 @@ export interface ISwaggerOptions { serviceNameSuffix?: string enumNamePrefix?: string methodNameMode?: 'operationId' | 'path' | 'shortOperationId' | ((reqProps: IRequestMethod) => string) - classNameMode?: 'parentPath' | 'normal' | ((path: string, tag: string[]) => string) + classNameMode?: 'parentPath' | 'normal' | ((path: string, method: string, reqProps:IRequestMethod) => string) /** only effect classNameMode='parentPath' */ pathClassNameDefaultName?: string outputDir?: string diff --git a/src/requestCodegen/index.ts b/src/requestCodegen/index.ts index 50878b9..b7ccc57 100644 --- a/src/requestCodegen/index.ts +++ b/src/requestCodegen/index.ts @@ -51,7 +51,7 @@ export function requestCodegen(paths: IPaths, isV3: boolean, options: ISwaggerOp className = camelcase(className, { pascalCase: true }) } } else if (typeof options.classNameMode === 'function') { - className = options.classNameMode(path, reqProps.tags || []) + className = options.classNameMode(path, method, reqProps) } else { if (!reqProps.tags) continue className = camelcase(RemoveSpecialCharacters(reqProps.tags[0]), { pascalCase: true })