diff --git a/src/main/java/io/github/easybill/Controllers/ValidationController.java b/src/main/java/io/github/easybill/Controllers/ValidationController.java index 8e4f511..18dcc4f 100644 --- a/src/main/java/io/github/easybill/Controllers/ValidationController.java +++ b/src/main/java/io/github/easybill/Controllers/ValidationController.java @@ -33,24 +33,19 @@ public ValidationController(IValidationService validationService) { description = "The submitted XML is valid " ), @APIResponse( - responseCode = "400", - description = "Schematron validation for the submitted XML failed. Response will contain the failed assertions" + responseCode = "422", + description = "The provided XML could not be used for validation" ), } ) public RestResponse<@NonNull ValidationResult> validation( InputStream xmlInputStream ) throws Exception { - ValidationResult result = validationService.validateXml(xmlInputStream); - - if (result.isValid()) { - return RestResponse.ResponseBuilder - .ok(result, MediaType.APPLICATION_JSON) - .build(); - } - return RestResponse.ResponseBuilder - .create(RestResponse.Status.BAD_REQUEST, result) + .create( + RestResponse.Status.OK, + validationService.validateXml(xmlInputStream) + ) .type(MediaType.APPLICATION_JSON) .build(); } diff --git a/src/test/java/io/github/easybill/ValidationControllerTest.java b/src/test/java/io/github/easybill/ValidationControllerTest.java index 8e2e8f0..c5bcbe1 100644 --- a/src/test/java/io/github/easybill/ValidationControllerTest.java +++ b/src/test/java/io/github/easybill/ValidationControllerTest.java @@ -203,7 +203,7 @@ void testValidationEndpointWithInvalidPayload( .when() .post("/validation") .then() - .statusCode(400) + .statusCode(200) .contentType(ContentType.JSON) .body("is_valid", equalTo(false)) .body("errors", not(empty()));