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

Meta-annotation support for annotation-error-decoder #1457

Closed
BigMichi1 opened this issue Jul 13, 2021 · 0 comments · Fixed by #1458
Closed

Meta-annotation support for annotation-error-decoder #1457

BigMichi1 opened this issue Jul 13, 2021 · 0 comments · Fixed by #1458

Comments

@BigMichi1
Copy link
Contributor

BigMichi1 commented Jul 13, 2021

This is a re-creation of the issue located in OpenFeign/feign-annotation-error-decoder#31 and a follow-up of #1447 / #1454

Mainly in combination with spring-cloud-openfeign it would be really helpfull to have support for meta-annotations.
This will reduce the amount of annotations in the interface.

The idea is to have a custom annotation which combines the @RequestMapping annotations with the @ErrorHandling annotation on a method/class level. the SpringDecoder is able to work with the meta-annotations already so it is more consistent to have also @ErrorHandling working in a meta-annotation

e.g.

@ErrorHandling(codeSpecific =
    {
        @ErrorCodes( codes = {401}, generate = UnAuthorizedException.class),
        @ErrorCodes( codes = {403}, generate = ForbiddenException.class),
        @ErrorCodes( codes = {404}, generate = UnknownItemException.class),
    },
    defaultException = MethodLevelDefaultException.class
)
@RequestMapping(method = RequestMethod.GET, consumes = APPLICATION_CBOR_VALUE, produces = APPLICATION_CBOR_VALUE)
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface GetMappingWithErrorHandling {
    @AliasFor(annotation = RequestMapping.class)
    String[] path() default {};
}

and so it is possible to have in the interface only one annotation

public interface GitHub {
    @GetMappingWithErrorHandling(path="https://github.com/projects")
    List<Contributor> projects();
}
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

Successfully merging a pull request may close this issue.

1 participant