quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.69k stars 2.65k forks source link

Qute/Resteasy: @Valid support for request parameter #34654

Open mr-mos opened 1 year ago

mr-mos commented 1 year ago

Description

Having a controller action like:

@Path("/apiKey")
@POST
@Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public TemplateInstance apiKeyPost (@Valid ApiKey key) {       // ApiKey uses jakarta.validation.constraints.* annotations..
  return apiKey.data("apiKey",key);
}

@Valid seems not to be supported for form based requests (enctype="application/x-www-form-urlencoded"). It always leads to a an 415 "Unsupported Media Type" error.

Would be nice to support it.

Implementation ideas

No response

quarkus-bot[bot] commented 1 year ago

/cc @mkouba (qute)

mkouba commented 1 year ago

I don't think this is related to Qute in any way.

@mr-mos do you use resteasy-reactive or resteasy-classic?

mr-mos commented 1 year ago

I'm using resteasy-reactive. Yes, you could be right, that this is not related to Qute directly. So perhaps it is better to label it for "resteasy-reactive"? But in the end it is the "interface" between Qute and Resteasy-Reactive. Having a form like this:

<form method="POST" action="apiKey">
            <input type="text" name="key" value="{apiKey??}"/>
            <input type="submit" value="Submit Key"  />
</form>

It would be nice to have a hint in the Qute documentation, how to validate the user-input. Resteasy is arguing that it is just a REST framework and has nothing do to with form submits. On the other hand, Qute is a framework that should work with Resteasy in a smooth way. So who is responsible?

mkouba commented 1 year ago

In this particular case, I would say that it's a matter of resteasy-reactive and bean-validation integration...