-
Notifications
You must be signed in to change notification settings - Fork 452
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
ApiReponse with type is an Advanced Types #41
Comments
It's not possible for the same reason as Array or T[] (look at the issue microsoft/TypeScript/issues/10576). export abstract class ServiceApiResponse<T> {
abstract get value(): T;
@ApiModelProperty({ type: Number })
pages: number;
@ApiModelProperty({ type: Number })
page: number;
@ApiModelProperty({ type: Number })
maxByPage: number;
@ApiModelProperty({ type: Number })
count: number;
@ApiModelProperty({ type: Object })
error: any;
}
export class PatientCaretrackPopulatedOutputResponse extends ServiceApiResponse<PatientCaretrackPopulatedResponse[]> {
@ApiModelProperty({ type: PatientCaretrackPopulatedResponse, isArray: true })
value: PatientCaretrackPopulatedResponse[];
} |
Hi @alisherks, this works fine. |
Cross posting this, does that mean a generic controller wouldn't be able to expose the proper endpoints? For example, something like this (taken from nestjs/nest#228): export abstract class EntityController<T> {
constructor(protected readonly service: EntityService<T>) { }
@Get()
async findAll() {
return this.service.findAll();
}
@Get(':id')
async getById(@Param() params) {
return this.service.getById(params.id);
}
@Post()
async create(@Body() data: Partial<T>) {
return this.service.create(data);
}
} |
Running into the same issue, having a generic CRUD controller being inherited is incredibly useful but for PUT and POST methods SwaggerUI is not implicitly picking up the T model. I've tried specifying the model type with I've tried various ways of passing the model constructor to the generic parent controller and have @ImplicitApiBody work, to no avail. Is there a way for Swagger to find the @Body type "T" in a generic parent controller like CrudController ? |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi,
I have an generic class who is return on all my request
And on my endpoint i have add
But i have this error
Error TS2348: Value of type 'ServerApiResponse' is not callable.
So i tried this
But when i launch swagger i have no description of response returned.
It's possible to do this ?
Thx
The text was updated successfully, but these errors were encountered: