https://gist.github.com/benson-basis/69ef04e9543fe04ac9f5
Here I have a service that picks up a POST'ed body via Jackson. We use
the provider, rather than just declaring the parameter as InputStream,
to get Swagger to be useful. But the punishment is severe in the event
of an error. Can I do something with exception mapping to cut down the
noise?
@POST
@Path("/extract")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Descriptions({
@Description(value = "Extract text from given content",
target = DocTarget.METHOD),
@Description(value = "Extracted text", target = DocTarget.RETURN),
@Description(value = WADL_INPUT_DESC_TEXT, target =
DocTarget.REQUEST),
@Description(value = "Response in JSON, {text: \"sample
text\"}", target = DocTarget.RESPONSE),
@Description(value = "Text extraction service", target =
DocTarget.RESOURCE)
})
@ApiOperation(value = "Extract text from given content", notes =
WADL_INPUT_DESC_TEXT + "<p>" + ADM_RESPONSE_DESC_TEXT)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST,
message = BAD_REQUEST_FORMAT),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN,
message = NO_PROFILE_DATA)
})
public Response extractText(
@ApiParam(name = "profileId", value =
AnnotationGlossary.PROFILE_ID_DESC) @QueryParam("profileId") String
profileId,
@ApiParam(name = "debug", value =
AnnotationGlossary.DEBUG_DESC) @QueryParam("debug") boolean debug,
@ApiParam(name = "data", value =
AnnotationGlossary.REQUEST_DATA_DESC, required = true)
RaasRequestTextData data) {
...
Here I have a service that picks up a POST'ed body via Jackson. We use
the provider, rather than just declaring the parameter as InputStream,
to get Swagger to be useful. But the punishment is severe in the event
of an error. Can I do something with exception mapping to cut down the
noise?
@POST
@Path("/extract")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Descriptions({
@Description(value = "Extract text from given content",
target = DocTarget.METHOD),
@Description(value = "Extracted text", target = DocTarget.RETURN),
@Description(value = WADL_INPUT_DESC_TEXT, target =
DocTarget.REQUEST),
@Description(value = "Response in JSON, {text: \"sample
text\"}", target = DocTarget.RESPONSE),
@Description(value = "Text extraction service", target =
DocTarget.RESOURCE)
})
@ApiOperation(value = "Extract text from given content", notes =
WADL_INPUT_DESC_TEXT + "<p>" + ADM_RESPONSE_DESC_TEXT)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST,
message = BAD_REQUEST_FORMAT),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN,
message = NO_PROFILE_DATA)
})
public Response extractText(
@ApiParam(name = "profileId", value =
AnnotationGlossary.PROFILE_ID_DESC) @QueryParam("profileId") String
profileId,
@ApiParam(name = "debug", value =
AnnotationGlossary.DEBUG_DESC) @QueryParam("debug") boolean debug,
@ApiParam(name = "data", value =
AnnotationGlossary.REQUEST_DATA_DESC, required = true)
RaasRequestTextData data) {
...