1- import { getClassNameByPath , getMethodNameByPath , RemoveSpecialCharacters } from '../utils'
2- import { IPaths } from '../swaggerInterfaces'
3- import { getRequestParameters } from './getRequestParameters'
4- import { getResponseType } from './getResponseType'
51import camelcase from 'camelcase'
6- import { getRequestBody } from './getRequestBody'
72import { ISwaggerOptions } from '../baseInterfaces'
3+ import { IPaths } from '../swaggerInterfaces'
4+ import { getClassNameByPath , getMethodNameByPath , RemoveSpecialCharacters } from '../utils'
85import { getContentType } from './getContentType'
6+ import { getRequestBody } from './getRequestBody'
7+ import { getRequestParameters } from './getRequestParameters'
8+ import { getResponseType } from './getResponseType'
99import { mapFormDataToV2 } from './mapFormDataToV2'
1010
1111export interface IRequestClass {
@@ -29,10 +29,10 @@ export function requestCodegen(paths: IPaths, isV3: boolean, options: ISwaggerOp
2929 options . methodNameMode === 'operationId'
3030 ? reqProps . operationId
3131 : options . methodNameMode === 'shortOperationId'
32- ? trimSuffix ( reqProps . operationId , reqProps . tags ?. [ 0 ] )
33- : typeof options . methodNameMode === 'function'
34- ? options . methodNameMode ( reqProps )
35- : methodName
32+ ? trimSuffix ( reqProps . operationId , reqProps . tags ?. [ 0 ] )
33+ : typeof options . methodNameMode === 'function'
34+ ? options . methodNameMode ( reqProps )
35+ : methodName
3636 if ( ! methodName ) {
3737 // console.warn('method Name is null:', path);
3838 continue
@@ -50,6 +50,8 @@ export function requestCodegen(paths: IPaths, isV3: boolean, options: ISwaggerOp
5050 } else {
5151 className = camelcase ( className , { pascalCase : true } )
5252 }
53+ } else if ( typeof options . classNameMode === 'function' ) {
54+ className = options . classNameMode ( path , reqProps . tags || [ ] )
5355 } else {
5456 if ( ! reqProps . tags ) continue
5557 className = camelcase ( RemoveSpecialCharacters ( reqProps . tags [ 0 ] ) , { pascalCase : true } )
@@ -59,8 +61,6 @@ export function requestCodegen(paths: IPaths, isV3: boolean, options: ISwaggerOp
5961 // 如果是数字开头,则加上下划线
6062 if ( ! Number . isNaN ( Number ( className [ 0 ] ) ) ) className = '_' + className
6163
62-
63-
6464 // 是否存在
6565 if ( ! requestClasses [ className ] ) {
6666 requestClasses [ className ] = [ ]
@@ -138,7 +138,7 @@ export function requestCodegen(paths: IPaths, isV3: boolean, options: ISwaggerOp
138138 }
139139 } catch ( error ) {
140140 // 获取方法名字失败,跳过该请求
141- console . log ( 'error request, url: ' , path ) ;
141+ console . log ( 'error request, url: ' , path )
142142 continue
143143 }
144144
0 commit comments