Description
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
"requestBody": {
"content": {
"application/json": { "schema": { "$ref": "#/components/schemas/BodyDto" } }
}
}
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:
BodyDto: BodyDto,
but if I set required: false
manually in the OpenApi spec the backend provides it does generate as optional:
BodyDto?: BodyDto,
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?
- Do not have the required in the requestBody
- The schema object doesn't generate as optional
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