Open m-titov opened 1 month ago
It looks like it works for /file1
endpoint if we make the following changes:
openapi: 3.1.0
info:
title: OpenAPI definition
version: v0
servers:
- description: Generated server url
url: http://localhost:8080
paths:
/file1:
post:
operationId: handleFileUpload
requestBody:
content:
multipart/form-data:
schema:
type: object
example: null
properties:
file:
type: string
format: binary
example: null
responses:
"200":
content:
'*/*':
schema:
type:
- string
example: null
description: OK
/file2:
post:
operationId: handleFileUpload2
requestBody:
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/FileUpload"
example: null
responses:
"200":
content:
'*/*':
schema:
type:
- string
example: null
description: OK
components:
schemas:
FileUpload:
example: null
properties:
file:
type:
- string
format: binary
example: null
When using springdoc.api-docs.version=openapi_3_1, the Swagger UI does not display the "Choose File" button for file upload endpoints. Instead, it shows a text area for inputting the Request Body. This issue is observed for both endpoints in the provided sample code. In contrast, with springdoc.api-docs.version=openapi_3_0, the "Choose File" button appears as expected. To Reproduce
Steps to reproduce the behavior:
Configuration:
Configure your application.properties with the following settings: properties
Use the following Java code for file upload endpoints:
Add the following dependencies and plugin configuration:
Observation:
Access Swagger UI at http://localhost:8080/swagger-ui.html. For the /file1 and /file2 endpoints, observe that the Swagger UI displays a text area for inputting the Request Body instead of the "Choose File" button. Expected behavior
For endpoints that support file uploads, Swagger UI should display the "Choose File" button, allowing users to select and upload files through the Swagger interface.
Screenshots![image](https://github.com/user-attachments/assets/11c7876c-37da-481e-9eea-cc47371578ae)
Additional context
The issue is specific to
springdoc.api-docs.version=openapi_3_1
Withspringdoc.api-docs.version=openapi_3_0
, the Swagger UI correctly displays the "Choose File" button for file upload endpoints. It may be related to changes or differences in how OpenAPI 3.1 specifications handle file uploads compared to OpenAPI 3.0.