Contributions
Re: I'm trying to add an upload file button in Swagger-UI using annotations with swagger-jaxrs2
I finally found the solution after 3 weeks of swapping Annotation combinations. @Parameter(schema = @Schema(name = "file", type = "string", format = "binary")) This is needed for the InputStream@FormDataParam annotation. @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( @Parameter(name = "file", type = "string", format = "binary") @FormDataParam("file") InputStream inputStream, @FormDataParam("file") FormDataContentDisposition fileDetail )throws RestException{ //process file code }2.8KViews0likes0CommentsI'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'2.8KViews0likes1Comment