You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all thanks for your work. Your library is very helpfull for building quickly api client services.
I am currently working on version "2.2.0". I wanted to build the following service in kotlin 1.1 (List refers to kotlin collection):
interfaceMyService{
@GET("/my/api/path/that/wont/work")
funwontWork(
@Query("enumParameter") enumParameters:List<EnumQueryParameter>?=null)
:Call<String>
}
// ...val httpClientBuilder:OkHttpClient.Builder=OkHttpClient.Builder()
val retrofit =Retrofit.Builder()
.baseUrl("http://somewhere.org")
.client(httpClientBuilder.build())
.addConverterFactory(JacksonConverterFactory.create(JacksonConfig.objectMapper))
.build()
val service = retrofit.create(MyService::class.java)
service.wontWork(listOf(EnumQueryParameter.one, EnumQueryParameter.two))
Running the above code raises me an exception:
java.lang.IllegalArgumentException: Parameter type must not include a type variable or wildcard: java.util.List<? extends com.orange.datashare.api.EnumQueryParameter> (parameter #1)
From what I understood, retrofit does not accept generic types as it needs to fully know what type of object is up to handle. Yet on that point I am not asking him to handle wild card type (even though enum class is saw as a Enum<T>)
What is more surprising is it accepts the following declaration (replacing Listby MutableList)
You can add @JvmSuppressWildcard either inside the angle brackets before the String type, or before the List. Both should work and remove the wildcard.
Hi,
First of all thanks for your work. Your library is very helpfull for building quickly api client services.
I am currently working on version
"2.2.0"
. I wanted to build the following service in kotlin 1.1 (List
refers to kotlin collection):Running the above code raises me an exception:
From what I understood, retrofit does not accept generic types as it needs to fully know what type of object is up to handle. Yet on that point I am not asking him to handle wild card type (even though enum class is saw as a
Enum<T>
)What is more surprising is it accepts the following declaration (replacing
List
byMutableList
)The text was updated successfully, but these errors were encountered: