Description
openedon Apr 8, 2024
Describe the bug
The following:
@POST
@Path("/file")
fun postFile(@RestForm file: File): String {
// Do nothing
return "File"
}
@POST
@Path("/fileupload")
fun postFileUpload(@RestForm fileUpload: FileUpload): String {
// Do nothing
return "FileUpload"
}
Results in different OpenAPI specs for each endpoint, the upload button is missing in the SwaggerUI for the FileUpload endpoint.
File endpoint:
FileUpload endpoint:
I am not sure if this is intended behavior?
Expected behavior
I expected to be able to use File and FileUpload interchangeably (from OpenAPI point of view).
Actual behavior
File and FileUpload endpoints have vastly different OpenAPI specs. When using FileUpload there is no upload button in the SwaggerUI. When using File there is a file upload button.
How to Reproduce?
Reproducer: https://github.com/BrianSetz/quarkus-file-fileupload-reproducer (or use the above endpoint definitions in a Quarkus project with Reactive REST and OpenAPI)
Steps to reproduce the behavior:
- Run Quarkus app
- Open Quarkus Dev UI
- Navigate to Swagger UI
- Compare endpoints / OpenAPI spec
Output of uname -a
or ver
Linux p15v 6.5.0-26-generic #26-Ubuntu SMP PREEMPT_DYNAMIC Tue Mar 5 21:19:28 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
Java 17
Quarkus version or git rev
3.9.2
Build tool (ie. output of mvnw --version
or gradlew --version
)
Gradle 8.6
Additional information
OpenAPI spec:
---
openapi: 3.0.3
info:
title: demo API
version: 1.0-SNAPSHOT
paths:
/hello:
get:
tags:
- Example Resource
responses:
"200":
description: OK
content:
text/plain:
schema:
type: string
/hello/file:
post:
tags:
- Example Resource
requestBody:
content:
application/x-www-form-urlencoded:
schema:
required:
- file
type: object
properties:
file:
format: binary
type: string
responses:
"200":
description: OK
content:
text/plain:
schema:
type: string
/hello/fileupload:
post:
tags:
- Example Resource
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
fileUpload:
$ref: '#/components/schemas/FileUpload'
responses:
"200":
description: OK
content:
text/plain:
schema:
type: string
components:
schemas:
FileUpload:
type: object