Request body descriptions are not shown when the input type is a file upload
Q&A (please complete the following information)
- Swagger-UI version: 3.23.11
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
"requestBody": {
"description": "A zip file containing files that will be unzipped",
"content": {
"application/octet-stream": {
"schema": {
"type": "string",
"format": "binary",
"nullable": true
}
}
},
"required": true
}
Describe the bug you're encountering
When a request body is a type that causes the UI to use an input type=file box, then the description is not shown, and instead a message about examples is shown (even if no examples are specified in the openapi json). The message is:
Example values are not available for application/octet-stream media types.
Changing the type to something like text/plain results in the description being shown.
Expected behavior
The description should be shown above the file input box. The warning about examples shouldn't be shown if none are specified.
Additional context or thoughts
Maybe there should be support for per-content-type descriptions (e.g. via the schema's title attribute) so you can explain the differences between different upload types.
Indeed, looks like our predicate that controls the Example value warning is too broad:
https://github.com/swagger-api/swagger-ui/blob/77f4651cbf5b3767f0d79c91fd337de82b6ddee6/src/core/plugins/oas3/components/request-body.jsx#L82-L95
Looks like I inadvertently introduced this in https://github.com/swagger-api/swagger-ui/pull/4705.
Likewise, it looks like this control flow branch lacks the requestBodyDescription handling that the branch below it has.
Can u pls assign me
Hey @shaman-004 👋
I can confirm this bug is still reproducible 😞
But the good news is that therefore I can assign you to it 😅
Looking forward to PR! 💟