From bac9ba719b9a578972d4fc44acbc2ca1d2a10ca6 Mon Sep 17 00:00:00 2001 From: Patrick Boos Date: Mon, 27 Oct 2025 17:28:26 +0100 Subject: [PATCH] fix: no violation logged on blocking validation --- .../validation/filter/OpenApiValidationInterceptor.java | 8 ++++++-- .../validation/filter/OpenApiValidationWebFilter.java | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/spring-boot-starter/spring-boot-starter-web/src/main/java/com/getyourguide/openapi/validation/filter/OpenApiValidationInterceptor.java b/spring-boot-starter/spring-boot-starter-web/src/main/java/com/getyourguide/openapi/validation/filter/OpenApiValidationInterceptor.java index df73fd61..1097463e 100644 --- a/spring-boot-starter/spring-boot-starter-web/src/main/java/com/getyourguide/openapi/validation/filter/OpenApiValidationInterceptor.java +++ b/spring-boot-starter/spring-boot-starter-web/src/main/java/com/getyourguide/openapi/validation/filter/OpenApiValidationInterceptor.java @@ -150,7 +150,9 @@ private List validateRequest( .validateRequestObjectAsync(requestMetaData, responseMetaData, requestBody, openApiViolationHandler); return List.of(); } else { - return validator.validateRequestObject(requestMetaData, requestBody); + var violations = validator.validateRequestObject(requestMetaData, requestBody); + violations.forEach(openApiViolationHandler::onOpenApiViolation); + return violations; } } @@ -185,7 +187,9 @@ private List validateResponse( .validateResponseObjectAsync(requestMetaData, responseMetaData, responseBody, openApiViolationHandler); return List.of(); } else { - return validator.validateResponseObject(requestMetaData, responseMetaData, responseBody); + var violations = validator.validateResponseObject(requestMetaData, responseMetaData, responseBody); + violations.forEach(openApiViolationHandler::onOpenApiViolation); + return violations; } } diff --git a/spring-boot-starter/spring-boot-starter-webflux/src/main/java/com/getyourguide/openapi/validation/filter/OpenApiValidationWebFilter.java b/spring-boot-starter/spring-boot-starter-webflux/src/main/java/com/getyourguide/openapi/validation/filter/OpenApiValidationWebFilter.java index e996ae79..b41cd0a8 100644 --- a/spring-boot-starter/spring-boot-starter-webflux/src/main/java/com/getyourguide/openapi/validation/filter/OpenApiValidationWebFilter.java +++ b/spring-boot-starter/spring-boot-starter-webflux/src/main/java/com/getyourguide/openapi/validation/filter/OpenApiValidationWebFilter.java @@ -141,7 +141,9 @@ private List validateRequest( } if (runType == RunType.SYNC) { - return validator.validateRequestObject(requestMetaData, responseMetaData, request.getCachedBody()); + var violations = validator.validateRequestObject(requestMetaData, responseMetaData, request.getCachedBody()); + violations.forEach(openApiViolationHandler::onOpenApiViolation); + return violations; } else { validator.validateRequestObjectAsync( requestMetaData, responseMetaData, request.getCachedBody(), openApiViolationHandler); @@ -160,7 +162,9 @@ private List validateResponse( } if (runType == RunType.SYNC) { - return validator.validateResponseObject(requestMetaData, responseMetaData, responseBody); + var violations = validator.validateResponseObject(requestMetaData, responseMetaData, responseBody); + violations.forEach(openApiViolationHandler::onOpenApiViolation); + return violations; } else { validator .validateResponseObjectAsync(requestMetaData, responseMetaData, responseBody, openApiViolationHandler);