I use swagger to create documentation for my REST API. However, I am having trouble specifying answers to some API calls.
This is my code:
@GET @Path("/self/activities") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "Get all activities created by this user", notes = "Returns the list that the authenticated user (JWT) has created", response = Activity.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 400, response = ErrorResponse.Error.class, responseContainer = "List", message = "There was something wrong in the request and therefore could not be processed (headers, json syntax/content)"), @ApiResponse(code = 500, response = ErrorResponse.Error.class, responseContainer = "List", message = "Unknown Internal server error")}) public void getActivities(...){...}
And this is the document that it generates:
"responses" : { "200" : { "description" : "successful operation", "schema" : { "type" : "array", "items" : { "$ref" : "#/definitions/Activity" } } }, "400" : { "description" : "There was something wrong in the request and therefore could not be processed (headers, json syntax/content)", "schema" : { "$ref" : "#/definitions/Error" } }, "500" : { "description" : "Unknown Internal server error", "schema" : { "$ref" : "#/definitions/Error" } } }
And I donβt understand why the error answers are not of the "Array" type, as the answer is "200". I want all answers to have the same format as 200 answers (array with elements):
"500" : { "description" : "Uknown interval server error", "schema" : { "type" : "array", "items" : { "$ref" : "#/definitions/Error" } } }
Thank you for your time.
source share