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

feat(springdoc-parameter-object): support with jakarta-query-param #1823

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

flyinfish
Copy link

proposal for support of @ParameterObject as discussed in
#1819

@flyinfish flyinfish force-pushed the feature/ISSUE-1819--support-spring-at-parameterobject branch from 97d2460 to 04e5ad4 Compare May 6, 2024 07:53
COOKIE_PARAM(SpringConstants.COOKIE_PARAM, Parameter.In.COOKIE, null, Parameter.Style.FORM);
COOKIE_PARAM(SpringConstants.COOKIE_PARAM, Parameter.In.COOKIE, null, Parameter.Style.FORM),
PARAMETER_OBJECT(SpringConstants.PARAMETER_OBJECT, null, null, null),
JAKARTA_QUERY_PARAM(SpringConstants.JAKARTA_QUERY_PARAM, Parameter.In.QUERY, null, Parameter.Style.FORM);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed ? (The Jakarta one)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

sonarcloud bot commented May 6, 2024

import jakarta.ws.rs.QueryParam;

public class GreetingParam {
@QueryParam("nameQuery") // "real" spring does not require this, but quarkus-spring-web does
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean neither the OpenAPI nor the actual web application work correctly without using the Jakarta REST @QueryParam annotation in this way?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that is right

@phillip-kruger this is the reason for having JAKARTA_QUERY_PARAM in SpringParameter.java

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did play around with https://github.com/flyinfish/spring-web-quickstart/compare/feature/adapt-to-patch?expand=1

HelloParamCheatedWithQueryParam has the same role there as GreetingParm above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does not seem right. At least the actual endpoint should work, even if openapi can not generate correctly. @geoand ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR, we don't support Spring's ParamObject, although we certainly could

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geoand - can you comment on this comment: #1823 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember how Spring behaves in this case, I would have to check and unfortunately I am short on time at the moment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, for an un-annotated POJO passed to a Spring GET method, the properties of the POJO should be used as query parameters. These should be added to the OpenAPI even without the SpringDoc annotation. For sure, the Spring scanner shouldn't use the Jakarta annotations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MikeEdgar if we were talking spring i would agree shat scanner should not use jakarta-annotations.

since we are talking quarkus (do we? is this project used outside quarkus?) i would not be too happy if the scanner generates an api which then does not work until i add the missing jakarta-annotations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being used in many other projects, not only Quarkus. I agree with @MikeEdgar, the fix should be that we handle the un-annotated case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants