@@ -254,6 +254,7 @@ export function getDefaultType(
254254 return `{ ${ keys ( schemaObject . properties )
255255 . map ( ( key ) => {
256256 let required = false ;
257+ const property = ( schemaObject . properties ?. [ key ] || { } ) as SchemaObject ;
257258
258259 if ( isBoolean ( schemaObject . required ) && schemaObject . required ) {
259260 required = true ;
@@ -266,20 +267,20 @@ export function getDefaultType(
266267 required = true ;
267268 }
268269
269- if (
270- 'required' in ( schemaObject . properties [ key ] || { } ) &&
271- ( schemaObject . properties [ key ] as SchemaObject ) ?. required
272- ) {
270+ if ( property . required ) {
273271 required = true ;
274272 }
273+
275274 /**
276275 * 将类型属性变为字符串,兼容错误格式如:
277276 * 3d_tile(数字开头)等错误命名,
278277 * 在后面进行格式化的时候会将正确的字符串转换为正常形式,
279278 * 错误的继续保留字符串。
280279 * */
281- return `'${ key } '${ required ? '' : '?' } : ${ getDefaultType (
282- schemaObject . properties ?. [ key ] ,
280+ return `
281+ ${ property . description ? `/** ${ property . description } */` : '' }
282+ '${ key } '${ required ? '' : '?' } : ${ getDefaultType (
283+ property ,
283284 namespace
284285 ) } ; `;
285286 } )
@@ -293,11 +294,19 @@ export function getDefaultFileTag(
293294 operationObject : OperationObject ,
294295 apiPath : string
295296) : string [ ] {
296- return operationObject [ 'x-swagger-router-controller' ]
297- ? [ operationObject [ 'x-swagger-router-controller' ] as string ]
298- : operationObject . tags || [ operationObject . operationId ] || [
299- apiPath . replace ( '/' , '' ) . split ( '/' ) [ 1 ] ,
300- ] ;
297+ let lastTags : string [ ] = [ ] ;
298+
299+ if ( operationObject [ 'x-swagger-router-controller' ] ) {
300+ lastTags = [ operationObject [ 'x-swagger-router-controller' ] as string ] ;
301+ } else if ( ! isEmpty ( operationObject . tags ) ) {
302+ lastTags = operationObject . tags ;
303+ } else if ( operationObject . operationId ) {
304+ lastTags = [ operationObject . operationId ] ;
305+ } else {
306+ lastTags = [ apiPath . replace ( '/' , '' ) . split ( '/' ) [ 1 ] ] ;
307+ }
308+
309+ return lastTags ;
301310}
302311
303312function findDuplicateTypeNames ( arr : string [ ] ) {
0 commit comments