xbentu
5 years agoNew Contributor
I'm trying to add an upload file button in Swagger-UI using annotations with swagger-jaxrs2
Can someone please provide example code on how to add a upload file button in the swagger-ui with annotations using swagger-jaxrs2 library? I've tried many things to no success.
This is one of the formats I tried:
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Path("/upload")
@Operation(
summary = "summary",
description = "description"
responses = {@ApiResponse(
responseCode = "200",
description = "OK"
)}
)
public Response uploadFile(
@FormDataParam("file") InputStream inputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail
)throws RestException{
//process file code
}
This is the request body that gets produced by swagger-jaxrs2 for file upload with the above code:
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
$ref: '#/components/schemas/FormDataContentDisposition'