-
Notifications
You must be signed in to change notification settings - Fork 89
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
Response for individual operations #426
Conversation
Signed-off-by: Helber Belmiro <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution @mzellho.
I left a few comments and I think we also need tests for vendorExtensions.x-java-is-response-void = true.
integration-tests/return-response/src/main/resources/application.properties
Show resolved
Hide resolved
...ts/return-response/src/test/java/io/quarkiverse/openapi/generator/it/ReturnResponseTest.java
Outdated
Show resolved
Hide resolved
@mzellho I'm just waiting for a test case related to vendorExtensions.x-java-is-response-void = true. Something like: @Test
void testXJavaIsResponseVoidReturnResponseFalseVoid() throws NoSuchMethodException {
var method = XJavaIsReturnResponseVoidReturnResponseFalseVoidApi.class.getMethod("hello");
assertThat(method.getReturnType())
.isEqualTo(Void.TYPE);
} The rest looks good to me. |
Hi @hbelmiro, I spent a lot of time thinking about how to test the vendor extension - long story short: I can't. As stated in my debugging notes in #386, we always end up in an Now, having slept over this, I really think that this PR at the very least should not be based on the vendor extension but compare for But, to be completely honest, I even think that we shouldn't add behavior that cannot be configured here. I feel that it would be a lot better and more importantly more user-friendly to revert what we did here and either: a) provide a new config property ( or b) provide a new config property (List) to "name operations that should return Of course, the generator feature WDYT? |
Hi @mzellho.
It makes sense to me.
Or even change the current ...return-response = true # return `Response` for all operations
...return-response = false # return type/void for all operations
...return-response = op1,op2,op3 # return `Response` only for op1, op2, and op3 WDYT? |
Hey @hbelmiro, thanks for the feedback. I would also prefer (b) and am confident that there'll be some time for it before the weekend. As quarkus.openapi-generator.codegen.spec.myspec_yaml.responses.op1=jakarta.ws.rs.core.Response # override Response
quarkus.openapi-generator.codegen.spec.myspec_yaml.responses.op3=void If |
@mzellho |
@hbelmiro Just to be safe, isn't |
@mzellho It is. And then we read its value in the qute template, just how we do with other custom properties. |
I don't think it is more user-friendly to have an additional option for this. I get the point that this behavior possibly diverges from standard openapi-generator behavior. But then again, since this project is using it's own qute templates, you could argue that it's already diverging from standard openapi-generator behavior. Correct me if I'm wrong, but I don't think this PR, as it is, would break any expectations or worsen developer experience in any way. If you don't care for the response, there's no difference in having a void method or simply discarding the return value. On the other hand, if you do care for the response (and there is no type info given) its much more user-friendly to already have the As for fixing the tests, I feel this would actually suffice:
|
* Improved return-response tests Signed-off-by: Helber Belmiro <[email protected]> * Return `Response` instead of `void` (#386) * Apply suggestions from code review * Apply suggestions from code review --------- Signed-off-by: Helber Belmiro <[email protected]> Co-authored-by: Helber Belmiro <[email protected]>
https://github.com/all-contributors please add @mzellho for code |
* Response for individual operations (#426) * Improved return-response tests Signed-off-by: Helber Belmiro <[email protected]> * Return `Response` instead of `void` (#386) * Apply suggestions from code review * Apply suggestions from code review --------- Signed-off-by: Helber Belmiro <[email protected]> Co-authored-by: Helber Belmiro <[email protected]> * Replaced jakarta with javax --------- Signed-off-by: Helber Belmiro <[email protected]> Co-authored-by: Maximilian Zellhofer <[email protected]> Co-authored-by: Helber Belmiro <[email protected]>
This PR fixes the return of
Response
forvoid
operations (Issue #424).