Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
c15yi opened this issue Sep 29, 2021 · 2 comments · Fixed by #20467
Closed

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

c15yi opened this issue Sep 29, 2021 · 2 comments · Fixed by #20467
Assignees
Labels
Milestone

Comments

@c15yi
Copy link
Contributor

c15yi commented Sep 29, 2021

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
@c15yi c15yi added the kind/bug Something isn't working label Sep 29, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 29, 2021

/cc @evanchooly

@c15yi c15yi changed the title Support Kotlin Data classes in Multipart From Requests with Reasteasy Reactive Kotlin Data classes in Multipart From Requests with Reasteasy Reactive not working Sep 29, 2021
@c15yi c15yi changed the title Kotlin Data classes in Multipart From Requests with Reasteasy Reactive not working Kotlin Data Classes in MultipartFrom Requests with Reasteasy Reactive not working Sep 29, 2021
@geoand
Copy link
Contributor

geoand commented Sep 29, 2021

This is similar but no the same as #19686

@geoand geoand self-assigned this Sep 30, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 30, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 30, 2021
geoand added a commit to geoand/quarkus that referenced this issue Sep 30, 2021
@geoand geoand removed the area/rest label Sep 30, 2021
geoand added a commit that referenced this issue Sep 30, 2021
Support getters in REST Client Reactive multipart requests
@quarkus-bot quarkus-bot bot added this to the 2.4 - main milestone Sep 30, 2021
@gsmet gsmet modified the milestones: 2.4.0.CR1, 2.3.1.Final Oct 18, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants