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

@FormParam OpenAPI not displayed properly in Resteasy Reactive #26461

Closed
abuelgasimsaadeldin opened this issue Jun 30, 2022 · 13 comments · Fixed by #26839
Closed

@FormParam OpenAPI not displayed properly in Resteasy Reactive #26461

abuelgasimsaadeldin opened this issue Jun 30, 2022 · 13 comments · Fixed by #26839
Assignees
Labels
Milestone

Comments

@abuelgasimsaadeldin
Copy link

abuelgasimsaadeldin commented Jun 30, 2022

Describe the bug

Enquiry regarding the request dto, previously before migrating to resteasy reactive I used to have the @FormParam annotation providing the KEY value for the request and String variable for the variable initialization, however I noticed that now the KEY value is using the variable name if that makes sense.

For example:

    @FormParam("destination_country")
    @PartType(MediaType.TEXT_PLAIN)
    private String destinationCountry;

and in Swagger instead of setting the KEY to "destination_country" (which is required) it instead uses "desinationCountry" which gives out errors so I had to initialize my variables with String destination_country which I believe is not common practice and instead should be using camelCase, hence your input in this is highly appreciated. Thanks.

Expected behavior

Expected behavior swagger UI when setting @FormParam("destination_country") and String destinationCountry::**
image

Actual behavior

Actual behavior swagger UI when setting @FormParam("destination_country") and String destinationCountry:
image

How to Reproduce?

CountryRequst.java (dto):

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CountryRequest {
    @NotNull(message = "destination country is required")
    @NotBlank(message = "destination country cannot be blank")
    @FormParam("destination_country")
    @PartType(MediaType.TEXT_PLAIN)
    private String destinationCountry;

CountryResource.java (resource):

@Path("/api/v1/country")
@Tag(name = "Country", description = "Countryendpoints")
public class CountryResource {

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response getRate(@Valid @MultipartForm CountryRequest countryRequest) {
CountryResponse countryResponse = new CountryResponse();

double rate = logisticService.getCountryRate(countryRequest);  // Some service to get the rate for a country
countryResponse.rate = rate;

return Response.ok(new Base(countryResponse,true, "successful")).build();
}

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

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

No response

Additional information

No response

@abuelgasimsaadeldin abuelgasimsaadeldin added the kind/bug Something isn't working label Jun 30, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 30, 2022

/cc @FroMage, @geoand, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Jun 30, 2022

@phillip-kruger do we have special RESTEasy Reactive support in our OpenAPI integration?

@geoand geoand changed the title @FormParam not working properly in Resteasy Reactive @FormParam OpenAPI not displayed properly in Resteasy Reactive Jun 30, 2022
@phillip-kruger
Copy link
Member

Not really no, the normal JAX-RS module works for both. Is this issue Reactive specific ?

@phillip-kruger
Copy link
Member

Ok I read the issue again, seems like this used to work in the Non-reactive way. So this must be a bug

@geoand
Copy link
Contributor

geoand commented Jun 30, 2022

Yeah, because it's about our Multipart support. Essentially Multipart objects are just POJOs, very similar actually to @BeanParam

@phillip-kruger
Copy link
Member

@abuelgasimsaadeldin - do you have a small reproducer ? @MikeEdgar any comments ?

@abuelgasimsaadeldin
Copy link
Author

abuelgasimsaadeldin commented Jun 30, 2022

@phillip-kruger, yes sure

CountryRequst.java (dto):

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CountryRequest {
    @NotNull(message = "destination country is required")
    @NotBlank(message = "destination country cannot be blank")
    @FormParam("destination_country")
    @PartType(MediaType.TEXT_PLAIN)
    private String destinationCountry;

CountryResource.java (resource):

@Path("/api/v1/country")
@Tag(name = "Country", description = "Countryendpoints")
public class CountryResource {

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response getRate(@Valid @MultipartForm CountryRequest countryRequest) {
CountryResponse countryResponse = new CountryResponse();

double rate = logisticService.getCountryRate(countryRequest);  // Some service to get the rate for a country
countryResponse.rate = rate;

return Response.ok(new Base(countryResponse,true, "successful")).build();
}

Expected swagger UI:
image

@MikeEdgar
Copy link
Contributor

I'm looking into this in smallrye/smallrye-open-api#1173, please feel free to assign to me.

@geoand
Copy link
Contributor

geoand commented Jul 10, 2022

Thanks, done

@abuelgasimsaadeldin
Copy link
Author

@gsmet @MikeEdgar

Hi there, I see that this issue has already been resolved, may I know what changes are needed in the pom.xml (if any) to be able to get the expected behavior? Thanks!

@MikeEdgar
Copy link
Contributor

@abuelgasimsaadeldin - prior to the release of Quarkus 2.12, you can add the following to the <dependencyManagement> section of you pom.xml. Bure sure to remove it when you do upgrade, or you risk using an outdated version of the OpenAPI library in the future.

<dependency>
    <groupId>io.smallrye</groupId>
    <artifactId>smallrye-open-api</artifactId>
    <version>2.1.23</version>
</dependency>

@abuelgasimsaadeldin
Copy link
Author

Hi @MikeEdgar, I see, thanks for the response, I've just tried adding the following smallrye-open-api dependency to my pom.xml, however my problem still persists (not sure if I'm doing something wrong) as for the Quarkus version, I am currently using version 2.10.0.Final and searching in the maven central repository it seems like 2.10.2.Final (again I could be wrong).

Your input is highly appreciated. Thanks again!

@MikeEdgar
Copy link
Contributor

@abuelgasimsaadeldin , sorry I gave you the wrong dependency. If this doesn't work, you may need to tinker with the quarkus-maven-plugin's dependencies. @phillip-kruger - what's the best way to managed the version of the JAX-RS OpenAPI extension being used?

<dependency>
    <groupId>io.smallrye</groupId>
    <artifactId>smallrye-open-api-core</artifactId>
    <version>2.1.23</version>
</dependency>

@gsmet gsmet modified the milestones: 2.12 - main, 2.11.1.Final Jul 26, 2022
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.

5 participants