Validation with assigned response fails for empty body
Issue #38
wontfix
com.atlassian.oai.validator.restassured.SwaggerValidationFilter$SwaggerValidationException: Validation failed. [ERROR] GET on path '/customers/' defines a response schema but no response body found.
@ApiOperation(value = "Customers")
@ApiResponses({
@ApiResponse(code = 200, message = "getCustomer", response = Customer.class),
@ApiResponse(code = 400, message = "Parsing error", response = ErrorResponse.class),
@ApiResponse(code = 500, message = "Internal error", response = ErrorResponse.class)
})
public Response getCustomer(
I rechecked and empty response body is always allowed, why does the validation fail here?
Comments (3)
-
-
From the spec https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#responseObject
A definition of the response structure. It can be a primitive, an array or an object. If this field does not exist, it means no content is returned as part of the response.
My reading of this agrees with @sdoeringNew - if a response type is specified the response must be of that type.
-
- changed status to wontfix
- Log in to comment
An empty response body is allowed if and only if the schema for the response is not specified.
As I'm seeing a response type in your @ApiResponse annotation the schema is specified, so the response body shall not be empty. At least it should contain an empty JSON: "{}"