Swagger: Missing Responses DTOs
Argeento opened this issue · comments
Adrian Wieprzkowicz commented
I have encountered an issue where there are no defined Response DTOs. In API service generators like swagger-typescript-api, this results in generating a void
type response for every endpoint.
Could you consider updating controllers to include Response DTOs and operationIds?
@SerializeOptions({
groups: ['me'],
})
@Post('email/login')
@HttpCode(HttpStatus.OK)
@ApiOperation({ operationId: 'emailLogin' }) // <-- NEW
@ApiOkResponse({ type: LoginResponseDto }) // <-- NEW
public login(@Body() loginDto: AuthEmailLoginDto): Promise<LoginResponseDto> {
return this.service.validateLogin(loginDto);
}
This results in a nicely generated service:
auth = {
/**
* No description
*
* @tags Auth
* @name EmailLogin
* @request POST:/api/v1/auth/email/login
* @response `default` `LoginResponseDto`
*/
emailLogin: (data: AuthEmailLoginDto, params: RequestParams = {}) =>
this.request<any, LoginResponseDto>({
path: `/api/v1/auth/email/login`,
method: 'POST',
body: data,
type: ContentType.Json,
...params
}),
instead of:
auth = {
/**
* No description
*
* @tags Auth
* @name AuthControllerLogin
* @request POST:/api/v1/auth/email/login
* @response `200` `void`
*/
authControllerLogin: (data: AuthEmailLoginDto, params: RequestParams = {}) =>
this.request<void, any>({ // void 🥺
path: `/api/v1/auth/email/login`,
method: 'POST',
body: data,
type: ContentType.Json,
...params
}),
(I am trying to avoid defining types once again in front-end app like this /src/services/api/types)
Vladyslav Shchepotin commented
@Argeento Good Idea, we'll consider your proposal 🤝