Skip to content

Commit

Permalink
Merge pull request #5 from easybill/v0.2.2
Browse files Browse the repository at this point in the history
v0.2.2
  • Loading branch information
BolZer authored Oct 29, 2024
2 parents a39b487 + 38104f4 commit 7600164
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down

0 comments on commit 7600164

Please sign in to comment.