rewrite-spring icon indicating copy to clipboard operation
rewrite-spring copied to clipboard

@PathVariable, @RequestBody, @ApiParam, similar annotations, may be removed if they're present on superclass or interface

Open sambsnyd opened this issue 5 years ago • 2 comments

There are various spring annotations, including but not limited to @PathVariable, @RequestBody, @Valid, @Size, @ApiParam, @Pattern, which allow developers to tell spring about the contract their API has.

If these annotations are present on a superclass or interface being implemented then they can be removed from the subclass. Leaving them isn't necessarily harmful so long as the arguments of the duplicated annotations match. If the arguments do not match it's a spring runtime error. So this is a "best practices & hygiene" rather than an "essential for migration" sort visitor.

sambsnyd avatar Oct 20 '20 20:10 sambsnyd

Turns out this is really hard/ almost impossible with our current API. We just don't have enough information on JavaType.Class about what methods and what annotations are on those methods to be able to do this correctly.

sambsnyd avatar Jan 14 '21 19:01 sambsnyd

This issue is blocked until https://github.com/openrewrite/rewrite/issues/150 is implemented

sambsnyd avatar Jan 14 '21 19:01 sambsnyd