title: How to use generic types with retrofit and moshi in kotlin?
body: <p>Suppose we have the following model</p>
  <pre><code>open class Orden(@field:Json(name = &quot;vehiculo_id&quot;) var vehiculo_id: IdNameItem = IdNameItem()) :
  RealmObject()
  
  open class IdNameItem(
  @field:Json(name = &quot;id&quot;) var id: Long = 0,
  @field:Json(name = &quot;name&quot;) var name: String = &quot;&quot;
  </code></pre>
  <p>) : RealmObject()</p>
  <p>the, we want to fetch all Orden from WS, something like this</p>
  <pre><code> @GET(&quot;orden&quot;)
  fun getOrden(@Body body: Any = Object()): Call&lt;SyncResponse&gt;
  </code></pre>
  <p>We have configured Retrofit like this</p>
  <pre><code>val retrofit = Retrofit.Builder()
          .baseUrl(environment.url)
          .addConverterFactory(MoshiConverterFactory.create())
          .client(httpClient.build())
          .build()
      return retrofit.create(WebServices::class.java)
  </code></pre>
  <p>And SyncReponse is configured like this</p>
  <pre><code>class SyncResponse : BaseResponse&lt;List&lt;Orden&gt;&gt;()
  
  open class BaseResponse&lt;T&gt; {
  
  @field:Json(name = &quot;result&quot;)
  lateinit var result: ResultResponse&lt;T&gt;
  
  @field:Json(name = &quot;error&quot;)
  val error: ErrorResponse = ErrorResponse()
  </code></pre>
  <p>and ResultResponse looking like..</p>
  <pre><code>open class ResultResponse&lt;T&gt;(
  @field:Json(name = &quot;status&quot;) val status: Int = 0,
  @field:Json(name = &quot;msj_error&quot;) val msj_error: String = &quot;&quot;,
  @field:Json(name = &quot;data&quot;)  var data: T
  </code></pre>
  <p>This is how I pretend to parse this response</p>
  <pre><code>{
      &quot;result&quot;: {
           &quot;status&quot;: 201,
           &quot;msj_error&quot;: &quot;&quot;,
           &quot;data&quot;: [
               {&quot;user_id&quot;: 1,
                &quot;vehiculo&quot;: &quot;New Holland/7630/1235888&quot;,
                  ** others fields **
               }]
           }
  }
  </code></pre>
  <p>And when I run it, it throws this error</p>
  <pre><code>06-27 20:12:27.895 1036-1036/com.azanini.ordenes E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.azanini.ordenes, PID: 1036
  java.lang.IllegalArgumentException: Unable to create converter for class com.azanini.ordenes.ws.NoResponse
      for method WebServices.login
      at retrofit2.Utils.methodError(Utils.java:53)
      at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:115)
      at retrofit2.HttpServiceMethod.parseAnnotations(HttpServiceMethod.java:82)
      at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:37)
      at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:192)
      at retrofit2.Retrofit$1.invoke(Retrofit.java:149)
      at java.lang.reflect.Proxy.invoke(Proxy.java:393)
      at $Proxy0.login(Unknown Source)
      at com.azanini.ordenes.activities.LoginActivity.login(LoginActivity.kt:83)
      at com.azanini.ordenes.activities.LoginActivity.onClick(LoginActivity.kt:76)
      at android.view.View.performClick(View.java:5716)
      at android.widget.TextView.performClick(TextView.java:10926)
      at android.view.View$PerformClick.run(View.java:22596)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:7325)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
   Caused by: java.lang.IllegalArgumentException: No JsonAdapter for ? extends com.azanini.ordenes.model.Orden (with no annotations)
  for ? extends com.azanini.ordenes.model.Orden
  for java.util.List&lt;? extends com.azanini.ordenes.model.Orden&gt; data
  for class com.azanini.ordenes.ws.ResultResponse result
  for class com.azanini.ordenes.ws.NoResponse
      at com.squareup.moshi.Moshi$LookupChain.exceptionWithLookupStack(Moshi.java:348)
      at com.squareup.moshi.Moshi.adapter(Moshi.java:149)
      at com.squareup.moshi.Moshi.adapter(Moshi.java:97)
      at com.squareup.moshi.Moshi.adapter(Moshi.java:67)
      at com.squareup.moshi.CollectionJsonAdapter.newArrayListAdapter(CollectionJsonAdapter.java:52)
      at com.squareup.moshi.CollectionJsonAdapter$1.create(CollectionJsonAdapter.java:36)
      at com.squareup.moshi.Moshi.adapter(Moshi.java:137)
      at com.squareup.moshi.ClassJsonAdapter$1.createFieldBindings(ClassJsonAdapter.java:99)
      at com.squareup.moshi.ClassJsonAdapter$1.create(ClassJsonAdapter.java:82)
      at com.squareup.moshi.Moshi.adapter(Moshi.java:137)
      at com.squareup.moshi.ClassJsonAdapter$1.createFieldBindings(ClassJsonAdapter.java:99)
      at com.squareup.moshi.ClassJsonAdapter$1.create(ClassJsonAdapter.java:82)
      at com.squareup.moshi.Moshi.adapter(Moshi.java:137)
      at com.squareup.moshi.Moshi.adapter(Moshi.java:97)
      at retrofit2.converter.moshi.MoshiConverterFactory.responseBodyConverter(MoshiConverterFactory.java:91)
      at retrofit2.Retrofit.nextResponseBodyConverter(Retrofit.java:352)
      at retrofit2.Retrofit.responseBodyConverter(Retrofit.java:335)
      at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:113)
          ... 18 more
   Caused by: java.lang.IllegalArgumentException: No JsonAdapter for ? extends com.azanini.ordenes.model.Orden (with no annotations)
      at com.squareup.moshi.Moshi.adapter(Moshi.java:147)
          ... 34 more
  </code></pre>
  <p>I imagine you can figure out that any type of data can be set in the &quot;data&quot; field, so I wwant to parametrize it, it is possible?</p>