I have a DropWizard project with jersey 2.17, with a simple form submission endpoint:
@Path("forms/{form_id}")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@ApiOperation(value = "Submit a form", response = SubmittedForm.class)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Valid request - form submitted", response = SubmittedForm.class)
})
public Response submitForm(@PathParam("form_id") String formId, MultivaluedMap<String, String> parameters) {
...
}
I'm using Swagger (swagger-jersey2-jaxrs 1.5.4) to document my API. However, for this endpoint there is no documentation generated for form parameters. If I change MultivaluedMap<String, String>
to MultivaluedStringMap
then there is doc generated but it is recognised as a body parameter.
I cannot use @PathParam
for the form parameters, as this endpoint will support multiple form definitions, so keys are not known.
Is there any way to document form submission endpoint (with url-encoded params) properly using Swagger?
An arbitrary map is not permitted in the swagger specification, and therefore it won't be detected when scanning the operation. Per the spec, only serializable types are supported for Form params.