使用Swagger记录HttpServletRequest

时间:2015-04-10 18:13:03

标签: java rest resteasy swagger swagger-ui

我有一个用于POST数据的REST端点。到目前为止,我已经记录了如下使用swagger。

@POST
@OPTIONS
@Path("{serviceVersion}/{dataType}")
@Produces({MediaType.TEXT_PLAIN})
@Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
@ApiOperation(value = "Post to Application", 
notes = "End Point to post Data")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
        @ApiResponse(code = 400, message = "Bad Request"),
        @ApiResponse(code = 500, message = "Internal server error (NON-retryable)") })
public String postData(@Context HttpServletRequest req,
        @Context HttpServletResponse resp,
        @ApiParam(value = "Service Version. Ex: v1", required = true, defaultValue="v1") @PathParam("serviceVersion")String serviceVersion,
        @ApiParam(value = "Topic Name", required = true, defaultValue="topic") @PathParam("dataType")String dataType,
        @ApiParam(value = "Delivery Mode", required = false) @QueryParam("deliveryMode")@DefaultValue("persistent") String deliveryMode,
        @Context UriInfo uriInfo);

我如何记录@Context HttpServletRequest req?我需要这个,因为我想让用户从swagger-UI提交数据。

PS:实际从请求中读取数据的方式是request.getReader();request.getInputStream();

0 个答案:

没有答案