darraghoriordan / eslint-plugin-nestjs-typed

Some eslint rules for working with NestJs projects
http://www.darraghoriordan.com
174 stars 34 forks source link

api-method-should-specify-api-response could not detect when using `applyDecorators` function #199

Closed han911976 closed 3 months ago

han911976 commented 3 months ago

Hi I am trying to follow code here to reduce my copy-and-paste hassle (and improve tiny readability) https://docs.nestjs.com/openapi/operations#advanced-generic-apiresponse

funcionally my code works, which allow me to group multi response decorators into single decorator

export const ApiAuthUnauthorizedNotFoundResponse = () => {
  return applyDecorators(
    ApiUnauthorizedResponse({ type: UnauthorizedResponse }),
    ApiNotFoundResponse({ type: NotFoundResponse }),
  );
};

However, warning will occur image

I am also having swagger cli enabled, I think the ApiOkRepsonse is generated by the cli and do not require manual paste.

As a work around I can slient the error / add a ApiOkResponse() for each endpoint which makes me feel redundant -v-

I think this might be able to fix by implementing or extends the original ApiResponse?

I am new to nest, hopefully this is not a stupid question.

Thank you.

api-method-should-specify-api-response

darraghoriordan commented 3 months ago

Yea so I don't use the cli in my project, this rule is probably redundant if you're having an automated tool adding the thing that it is telling you you should add? so you can just turn it off in your eslint conifg

   rules: {
   "@darraghor/nestjs-typed/api-method-should-specify-api-response": "off",
   }