-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
File and FileUpload result in different OpenAPI spec, upload button missing #39950
Comments
/cc @EricWittmann (openapi), @MikeEdgar (openapi), @geoand (kotlin), @phillip-kruger (openapi) |
Indeed FileUpload should be treated like File |
I can confirm that the workaround at least fixes the incorrect type/format. @POST
@Path("/fileupload")
fun postFileUpload(@RestForm @Schema(implementation = BinaryStringSchema::class) fileUpload: FileUpload): String {
// Do nothing
return "FileUpload"
}
@Schema(type = SchemaType.STRING, format = "binary")
interface BinaryStringSchema Results in ---
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/BinaryStringSchema'
responses:
"200":
description: OK
content:
text/plain:
schema:
type: string
components:
schemas:
BinaryStringSchema:
format: binary
type: string
FileUpload:
type: object Which at least adds the upload button in the Swagger UI. But the following is missing required:
- fileUpload And there is an unused (?) schema component: FileUpload:
type: object |
This has been fixed in upstream smallrye, @MikeEdgar please close here once new version of SmallRye openapi is included in Quarkus. Thanks :) |
The fix for this was included in #41037 |
🙏 |
Describe the bug
The following:
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:
Output of
uname -a
orver
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
orgradlew --version
)Gradle 8.6
Additional information
OpenAPI spec:
The text was updated successfully, but these errors were encountered: