在翻新中传递任意@Path参数

时间:2019-05-14 21:29:45

标签: java android annotations retrofit retrofit2

在改造中,我们为每个API调用指定需要使用的每个@Path参数,例如:

@GET("slider/{app-key}/{category}")
Call<ArrayList<SliderContent>> getSliderInfo(@Path("app-key") String appKey,
                                             @Path("category") String categoryKey);

在将@Path参数传递给类似这样的东西时,我试图使API调用更通用:

@GET("slider/{app-key}/{category}")
Call<ArrayList<SliderContent>> getSliderInfo(@Path("type?") String... body);


// Where body[0] corresponds to @Path("app-key") String appKey
// body[1] corresponds to @Path("category") String categoryKey

问题是:

  1. 如果不指定注释(例如@Path@Header@Query),翻新改造可能无法区分参数。
  2. 和/或,如果我们可以通过这种方式解决它,该如何传递@Path字符串的数组或集合。

0 个答案:

没有答案