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

Added @IgnoreParameter meta annotation #3577

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

nightfire2
Copy link

This is an attempt to add the custom parameter annotations ability requested #2890 in a way that is not intrusive to the existing Retrofit API surface.

I added an @IgnoreParameter meta annotation that can be applied to any custom parameter annotation that then causes Retrofit to ignore it during processing. The developer is then free to handle the annotation in a custom request interceptor if they so choose.

This approach preserves the behavior of any existing non Retrofit managed parameters causing Retrofit to throw an exception when building the client.

Example Usage

@IgnoreParameter
@Target(PARAMETER)
@Retention(RUNTIME)
public @interface CustomParam { }
public interface ExampleClient {
   @GET
   Call<Object> test(@CustomParam String myParam);
}

The biggest downside to this method is that it requires just-in-time handling of any custom annotations in your interceptor which is not ideal but not worse than being unable to do it in the first place in my opinion.

I'm also not satisfied with the name. @IgnoreParameter seems a little clunky so I'm open to suggestions.

Added NoOp ParameterHandler
Added support for ignoring parameters annotated with an annotation with the IgnoreParameter annotation on it to the RequestFactory.
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 this pull request may close these issues.

None yet

1 participant