Skip to content

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

@BigMichi1

Description

@BigMichi1

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();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions