Skip to content

Issues with Generated Files in Front-End after Using Commands Following the Definition of DTO Generics in Back-End #2226

Open
@makerForAll

Description

@makerForAll

My back-end uses the NestJS framework. When I configured the DTO...

import { ApiProperty } from '@nestjs/swagger';
import { IsNumber, IsString } from 'class-validator';

export class ResultType<T> {
  @ApiProperty({ description: '数据数组', isArray: true })
  data: T[];

  @ApiProperty({ description: '总数', required: false })
  total?: number;
}

export class ResponseType<T> {
  @ApiProperty({ description: '返回code' })
  @IsNumber()
  code: number;

  @ApiProperty({ description: '返回提示信息' })
  @IsString()
  message: string;

  @ApiProperty({ description: '返回结果' })
  results: ResultType<T>;
}

next-------controller.ts------- begin use it ----------------------

@ApiOperation({ summary: 'create client' })
 @ApiResponse({ type: ResponseType<CreateClientDTO> })
 @Post()
 @UsePipes(new ValidationPipe({ transform: true }))
 async create(@Body() client: CreateClientDTO): Promise<ResultType<CreateClientDTO>> {
   return this.clientService.create(client);
 };

next------ frontend --------- I started using commands to generate API client files.----------------------------
openapi --input http://localhost:3000/api-json --output ./src/api --client axios --request ./src/api/custom-request.ts --name APIforBackEnd --useOptions

next------- frontend ------- open generate file about the ResultType -------

Describe the bug


export type ResultType = {
    /**
     * 数据数组
     */
    data: Array<any[]>;
    /**
     * 总数
     */
    total?: number;
};

-------------- is error------------------
data: Array<any[]>;

--------------the right ------------------
data: Array<any>;

-------- Generics are also not supported. ------

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions