Аннотации Swagger не показывают пример тела - PullRequest
0 голосов
/ 26 апреля 2018

При работе с аннотациями Swagger невозможно создать пример для тела запроса.

Generated Swagger page but the Json is missing

А вот и аннотации для ресурса / конечной точки RESTful:

 @POST
@Path("/{carId}/conversation")
@ApiImplicitParams({
        @ApiImplicitParam(name = "Authorization", value = "The AppJWT token", paramType = "header", required = true),
        @ApiImplicitParam(name = "ON-BEHALF", value = "The ConsumerJWS token", paramType = "header", required = true),
        @ApiImplicitParam(name = "v", value = "API version", defaultValue = "3", paramType = "query", required = true)
})
@ManagedAsync
@ApiOperation(value = "bla", notes = "")
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "bla", response = CreateBlaResponse.class, responseContainer = "List"),
        @ApiResponse(code = 400, message = "The input was invalid, please check.", response = GenericError.class),
        @ApiResponse(code = 401, message = "Unauthorized. Are the headers correct?"),
        @ApiResponse(code = 429, message = "Too many requests, please try again later", response = CreateConversationResBody.class)
})
public void createConversationBatchPOST(@ApiParam(value = "Car ID the action should apply to", required = true) @PathParam("carId") String carId,
                                        @ApiParam(name = "body", value = "The Json payload", required = true, examples = @Example(value = {@ExampleProperty(value = "{\"name\" : \"James\"}", mediaType = "application/json")}))
                                        @RequestBody String body,
                                        @Suspended final AsyncResponse asyncResponse) throws IOException {
//.... implementation
}

У вас есть идея, почему аннотация в сигнатуре метода

     @ApiParam(name = "body", value = "The Json payload", 
required = true, examples = @Example(value = {@ExampleProperty(value = "{\"name\" : \"James\"}", mediaType = "application/json")})) 
@RequestBody String body

не приводит к примеру Json?

...