-
-
Notifications
You must be signed in to change notification settings - Fork 411
Orval does not support optional by default requestBody that OpenAPI 3.0 specifies #2028
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
Comments
I think the decision was made by anymaniax to not follow the OpenAPI specification in the linked pr |
Agree with @AllieJonsson this is by design. |
The workaround is to explicitly add the required option in your OpenApi so it's explicit the intent. |
@melloware I think the decision to selectively follow the openapi specification is shortsighted will cause more issues like this. There are openapi json generators that follow the specification in this regard and do not output |
@anymaniax thoughts? |
Hi, the fix for #1111 did not support the optional by default which is in the OpenAPI 3.0 spec [1] as originally requested. It only seems to handle the
required: false
value.In my project, I have in the OpenApi Spec
The backend expects no body to have certain behavior happen. When the backend generates the OpenApi spec, it knows it's optional with no required field, so it always generates nothing for required.
Generating with "orval": "7.7.0" doesn't create my axios request function with an optional body:
but if I set
required: false
manually in the OpenApi spec the backend provides it does generate as optional:The issue is whenever the backend generates the OpenApi spec for the frontend it will overwrite the
require: false
so I think proper optional body support is needed.What are the steps to reproduce this issue?
What happens?
The request body is not optional.
What were you expecting to happen?
The request body to be optional.
Any logs, error output, etc?
No
Any other comments?
No
What versions are you using?
Package Version: 7.7.0
The text was updated successfully, but these errors were encountered: