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

Invalid Filter type #4

Open
Ramblurr opened this issue Apr 20, 2017 · 1 comment
Open

Invalid Filter type #4

Ramblurr opened this issue Apr 20, 2017 · 1 comment

Comments

@Ramblurr
Copy link

Ramblurr commented Apr 20, 2017

It seems that retrofit requires the @QueryMap types to be explictly stated

      ServiceService service = rancher.type(io.rancher.service.ServiceService.class);
        Filters f = new Filters();
        f.put("name", "testname");
        Response<TypeCollection<Service>> response = service.list(f).execute();

produces

java.lang.IllegalArgumentException: Map must include generic types (e.g., Map<String, String>) (parameter #1)
    for method ServiceService.list

This simple patch fixed it:

diff --git a/src/main/java/io/rancher/base/Filters.java b/src/main/java/io/rancher/base/Filters.java
index da9e8b9..23b1130 100644
--- a/src/main/java/io/rancher/base/Filters.java
+++ b/src/main/java/io/rancher/base/Filters.java
@@ -2,5 +2,5 @@ package io.rancher.base;

 import java.util.HashMap;

-public class Filters extends HashMap<String, String> {
+public class Filters<K,V> extends HashMap<K, V> {
 }

Followed by a ack Filters -l | xargs sed -ri 's/Filters filters/Filters<String, String> filters/'

@Ramblurr
Copy link
Author

Ah, this can easily be changed in the service template

diff --git a/generator/service.template b/generator/service.template
index 0b30ba6..7c5bef6 100644
--- a/generator/service.template
+++ b/generator/service.template
@@ -21,7 +21,7 @@ public interface {{.class}}Service {
   Call<TypeCollection<{{.class}}>> list();

   @GET("{{.type}}")
-  Call<TypeCollection<{{.class}}>> list(@QueryMap Filters filters);
+  Call<TypeCollection<{{.class}}>> list(@QueryMap Filters<String, String> filters);

   @GET("{{.type}}/{id}")
   Call<{{.class}}> get(@Path("id") String id);

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

No branches or pull requests

1 participant