-
Notifications
You must be signed in to change notification settings - Fork 14
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
Optional in interface not supported #106
Comments
I don't really know how to handle this case since we often consider "Optional" as a java syntaxic sugar - not translated into json. For example, with Spring MVC with a default configuration, if you return an optional in a controller : it return the original object or null. Do you have the use case only for you Dtos? Or for your api body/return contracts declarations also? * Example for the second case : |
I think that there is a misunderstanding. If I have an optional in class it's being unpacked to concrete type. On the other side optional in interfaces are not unpacked. I would like to see the same behavior in interfaces as we have with classes |
Oh, got it! Indeed, I got it wrong. This is a fine request, added to the todo. :) |
Same problem would appear in parameters: public String optionalParameter(@RequestParam("optional") Optional<String> optional) {
return optional.orElse("default");
} parameters:
- name: optional
in: query
required: true # HERE!
schema:
type: object
properties:
value:
type: string |
Are you sure it is linked to class vs interface? I could not reproduce this bug. For me the only unwrapping actually in the app is if an Optional is used as a webservice response. Everywhere else, there is no unwrapping. (before the PR I'm working on) |
Here you have code to reproduce it magx2/openapi-maven-plugin-error@198880c It's not a problem of not unpacking Optional in interface but rather not setting required to false. I thought it's similar code space so I've pointed it here. If you want you can create new issue |
Ok, got it. No, it's ok, no worries, I'll keep working on my current MR. |
Hello Martin. Thank you very much by advance. ;) |
Works for me :). LGTM!
sob., 24 lut 2024 o 16:13 Kévin Buntrock ***@***.***>
napisał(a):
… Hello Martin.
Do you mind testing if you have the time the current version on the "dev"
branch? And check if it fix this bug well for you?
Thank you very much by advance. ;)
—
Reply to this email directly, view it on GitHub
<#106 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAWTLHQN5LH65DC2NUJR66LYVH7Q3AVCNFSM6AAAAABAWCR4MSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSGM4TOOBZGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Pozdrawiam
Martin Grześlowski
|
Nice, thank you :) |
I just found that if you have
Optional
in interface it does not get unpacked:Produces this YML:
instead of unpacked Optional:
If you want to reproduce it you can look at my repo: https://github.com/magx2/openapi-maven-plugin-error
The text was updated successfully, but these errors were encountered: