Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
makerForAll opened this issue Jul 14, 2024 · 1 comment
Assignees

Comments

@makerForAll
Copy link

makerForAll commented Jul 14, 2024

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. ------

@mrlubos
Copy link
Collaborator

mrlubos commented Jul 14, 2024

Hey @makerForAll, this package is no longer maintained. Please check if the problem exists in https://github.com/hey-api/openapi-ts and open an issue there if you'd like it resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants