Forum Discussion

Ramu's avatar
Ramu
New Contributor
5 years ago

How to remove/hide body parameter from Swagger UI in file upload API

Hello, I'm newbie to swagger UI development using jersey framework. I'm looking out for the resolution for below mentioned issue.

Issue: Unable to remove/hide body parameter from Swagger UI

Please find my Java source code:

@POST
@Path("/createSchedule")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(httpMethod = HttpMethod.POST, value = "Create a new export schedule(s)")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "Upload the template (.xlsx) to create schedule(s).", required = true, dataType = "file", paramType = "formData") })
public Response createSchedule(@FormDataParam(value="file") InputStream inputStream,
@FormDataParam(value="file") FormDataContentDisposition fileMetaData) throws ScheduleException {
}

I have used Jersey 2.29.1(jersey-container-servlet) & Swagger 1.5.0 (swagger-jaxrs) API's. Also do let me know how to allow only specific file extensions (like .xlsx) to upload from swagger ui.

 

Thanks in advance! Cheers!

 

  • You're using a very (very) old version of swagger-core. Please make sure to update to the latest, and follow the documentation to learn how to hide parameters.

  • Ramu's avatar
    Ramu
    5 years ago

    RonRatovsky - Thank you for your response. I have fixed the issue by doing below changes:

    1) Have changed the swagger maven dependency from "swagger-jaxrs" to "swagger-jersey2-jaxrs"

    2) Include "@ApiParam" swagger annotation with resource method parameter as "@ApiParam(hidden = true) @FormDataParam(value = "file") FormDataContentDisposition fileMetaData".

     
     

    Thanks, 🙂

     

  • You're using a very (very) old version of swagger-core. Please make sure to update to the latest, and follow the documentation to learn how to hide parameters.

    • Ramu's avatar
      Ramu
      New Contributor

      RonRatovsky - Thank you for your response. I have fixed the issue by doing below changes:

      1) Have changed the swagger maven dependency from "swagger-jaxrs" to "swagger-jersey2-jaxrs"

      2) Include "@ApiParam" swagger annotation with resource method parameter as "@ApiParam(hidden = true) @FormDataParam(value = "file") FormDataContentDisposition fileMetaData".

       
       

      Thanks, 🙂