snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

Kotlin Data Classes in MultipartFrom Requests with Reasteasy Reactive not working #433

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

Describe the bug

When performing a MultipartForm request on a REST client with a Kotlin data class wrapping the form fields it fails to generate the REST client with the error below.

Request failed:
org.eclipse.microprofile.rest.client.RestClientDefinitionException:
org.jboss.resteasy.reactive.client.api.InvalidRestClientDefinitionException:
Failed to generate client for class interface com.acme.accountmanager.apis.google.GoogleApi:
Non-public field found in a multipart form data class com.acme.accountmanager.apis.google.dto.recaptcha.GoogleRecaptchaRequestDto.
Rest Client Reactive only supports multipart form classes with a list of public fields

The REST client is defined as

import com.acme.accountmanager.apis.google.dto.recaptcha.GoogleRecaptchaRequestDto
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient
import org.jboss.resteasy.reactive.MultipartForm
import javax.ws.rs.Consumes
import javax.ws.rs.POST
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response

@Produces(MediaType.APPLICATION_JSON)
@RegisterRestClient(configKey = "google-api")
interface GoogleApi {

    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    fun verifyCaptcha(@MultipartForm captcha: GoogleRecaptchaRequestDto): Response
}

And the data class as

import org.jboss.resteasy.reactive.PartType
import javax.ws.rs.FormParam
import javax.ws.rs.core.MediaType

data class GoogleRecaptchaRequestDto(
    @FormParam("secret")
    @PartType(MediaType.TEXT_PLAIN)
    val secret: String,
    @FormParam("response")
    @PartType(MediaType.TEXT_PLAIN)
    val captchaValue: String
)

Expected behavior

Since all fields in a data class are public by default, I would expect it to perform the request as when providing the form params like this

@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
fun verifyCaptcha(@FormParam("secret") secret: String, @FormParam("response") captchaValue: String): Response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

openjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment (build 11.0.10+9) OpenJDK 64-Bit Server VM (build 11.0.10+9, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.3-Final

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

During build time it also shows this error message

Failed to create client proxy for com.acme.accountmanager.apis.google.GoogleApi this can usually be safely ignored:
java.lang.IllegalArgumentException:
Non-public field found in a multipart form data class com.acme.accountmanager.apis.google.dto.recaptcha.GoogleRecaptchaRequestDto.
Rest Client Reactive only supports multipart form classes with a list of public fields

https://github.com/quarkusio/quarkus/issues/20457


$upstream:20457$