@Override
    public ValidationError validate(Exchange exchange, ValidationContext validationContent) {
        OpenAPI openAPI = exchange.getProperty(Exchange.REST_OPENAPI, OpenAPI.class);
        if (openAPI == null) {
            return null;
        }

        String method = exchange.getMessage().getHeader(Exchange.HTTP_METHOD, String.class);
        String path = exchange.getMessage().getHeader(Exchange.HTTP_PATH, String.class);
        String accept = exchange.getMessage().getHeader("Accept", String.class);
        String contentType = ExchangeHelper.getContentType(exchange);
        String body = MessageHelper.extractBodyAsString(exchange.getIn());

        SimpleRequest.Builder builder = new SimpleRequest.Builder(method, path, false);
        if (contentType != null) {
            builder.withContentType(contentType);
        }
        if (accept != null) {
            builder.withAccept(accept);
        }
        if (body != null) {
            builder.withBody(body);
        }

        OpenApiInteractionValidator validator = OpenApiInteractionValidator.createFor(openAPI).build();
        ValidationReport report = validator.validateRequest(builder.build());
        if (report.hasErrors()) {
            String msg;
            if (accept != null && accept.contains("application/json")) {
                msg = JsonValidationReportFormat.getInstance().apply(report);
            } else {
                msg = SimpleValidationReportFormat.getInstance().apply(report);
            }
            return new ValidationError(400, msg);
        }
        return null;
    }
@Test
    public void testValidator() throws Exception {
        String data = IOHelper.loadText(OpenApiRestClientRequestValidatorTest.class.getResourceAsStream("/petstore-v3.json"));
        OpenAPIV3Parser parser = new OpenAPIV3Parser();
        SwaggerParseResult out = parser.readContents(data);
        OpenAPI openAPI = out.getOpenAPI();

        exchange.setProperty(Exchange.REST_OPENAPI, openAPI);
        exchange.setProperty(Exchange.CONTENT_TYPE, "application/json");
        exchange.getMessage().setHeader(Exchange.HTTP_METHOD, "PUT");
        exchange.getMessage().setHeader(Exchange.HTTP_PATH, "pet");
        exchange.getMessage().setHeader("Accept", "application/json");
        exchange.getMessage().setBody("");

        OpenApiRestClientRequestValidator validator = new OpenApiRestClientRequestValidator();

        RestClientRequestValidator.ValidationError error
                = validator.validate(exchange, new RestClientRequestValidator.ValidationContext(
                        "application/json", "application/json", true, null, null, null, null));

        Assertions.assertNotNull(error);
        Assertions.assertTrue(error.body().contains("A request body is required but none found"));

        exchange.getMessage().setBody("{ some body here }");

        error = validator.validate(exchange, new RestClientRequestValidator.ValidationContext(
                "application/json", "application/json", true, null, null, null, null));
        Assertions.assertNull(error);
    }