Via okhttp3.Request#tag(Invocation::class.java), we can get methodName, annotations etc. Is there any way to get the method's return type using Invocation class.
I've tried
request.tag(Invocation::class.java)!!.method().returnTyperequest.tag(Invocation::class.java)!!.method().genericReturnTypebut both of them simply return class java.lang.Object, even it's a List.
@GET("products")
suspend fun getProducts(): List<Product> // I need to get at least `List` as a String for this method
@GET("product")
suspend fun getProduct(): Product // I need to get at least `Object` as a String for this method
It's a suspend function so the return type of the java.lang reflect.Method is not the return type you declared. Look a the decompiled bytecode and you'll see the Java method and where the declared return type ends up in the signature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With