From 296af61ecd2791599266083f2fe5461147adb376 Mon Sep 17 00:00:00 2001 From: "Badr.NassLahsen" Date: Sat, 2 Dec 2023 16:52:22 +0100 Subject: [PATCH] SpringdocRouteBuilder.onError is overriding last route defined. Fixes #2399 --- .../webflux/core/fn/SpringdocRouteBuilder.java | 12 ++++-------- .../webmvc/core/fn/SpringdocRouteBuilder.java | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/springdoc-openapi-starter-webflux-api/src/main/java/org/springdoc/webflux/core/fn/SpringdocRouteBuilder.java b/springdoc-openapi-starter-webflux-api/src/main/java/org/springdoc/webflux/core/fn/SpringdocRouteBuilder.java index 84c88249c..21ba89ac7 100644 --- a/springdoc-openapi-starter-webflux-api/src/main/java/org/springdoc/webflux/core/fn/SpringdocRouteBuilder.java +++ b/springdoc-openapi-starter-webflux-api/src/main/java/org/springdoc/webflux/core/fn/SpringdocRouteBuilder.java @@ -651,12 +651,10 @@ public SpringdocRouteBuilder after(BiFunction predicate, BiFunction> responseProvider, Consumer operationsConsumer) { - Builder builder = getOperationBuilder(operationsConsumer); - this.delegate.onError(predicate, responseProvider).withAttribute(OPERATION_ATTRIBUTE, builder); + public SpringdocRouteBuilder onError(Predicate predicate, BiFunction> responseProvider) { + this.delegate.onError(predicate, responseProvider); return this; } @@ -667,12 +665,10 @@ public SpringdocRouteBuilder onError(Predicate predicate, BiF * @param the type parameter * @param exceptionType the exception type * @param responseProvider the response provider - * @param operationsConsumer the operations consumer * @return the springdoc route builder */ - public SpringdocRouteBuilder onError(Class exceptionType, BiFunction> responseProvider, Consumer operationsConsumer) { - Builder builder = getOperationBuilder(operationsConsumer); - this.delegate.onError(exceptionType, responseProvider).withAttribute(OPERATION_ATTRIBUTE, builder); + public SpringdocRouteBuilder onError(Class exceptionType, BiFunction> responseProvider) { + this.delegate.onError(exceptionType, responseProvider); return this; } diff --git a/springdoc-openapi-starter-webmvc-api/src/main/java/org/springdoc/webmvc/core/fn/SpringdocRouteBuilder.java b/springdoc-openapi-starter-webmvc-api/src/main/java/org/springdoc/webmvc/core/fn/SpringdocRouteBuilder.java index 1208a8173..1a6be0f2a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/main/java/org/springdoc/webmvc/core/fn/SpringdocRouteBuilder.java +++ b/springdoc-openapi-starter-webmvc-api/src/main/java/org/springdoc/webmvc/core/fn/SpringdocRouteBuilder.java @@ -651,12 +651,10 @@ public SpringdocRouteBuilder after(BiFunction predicate, BiFunction responseProvider, Consumer operationsConsumer) { - Builder builder = getOperationBuilder(operationsConsumer); - this.delegate.onError(predicate, responseProvider).withAttribute(OPERATION_ATTRIBUTE, builder); + public SpringdocRouteBuilder onError(Predicate predicate, BiFunction responseProvider) { + this.delegate.onError(predicate, responseProvider); return this; } @@ -667,12 +665,10 @@ public SpringdocRouteBuilder onError(Predicate predicate, BiFunction< * @param the type parameter * @param exceptionType the exception type * @param responseProvider the response provider - * @param operationsConsumer the operations consumer * @return the springdoc route builder */ - public SpringdocRouteBuilder onError(Class exceptionType, BiFunction responseProvider, Consumer operationsConsumer) { - Builder builder = getOperationBuilder(operationsConsumer); - this.delegate.onError(exceptionType, responseProvider).withAttribute(OPERATION_ATTRIBUTE, builder); + public SpringdocRouteBuilder onError(Class exceptionType, BiFunction responseProvider) { + this.delegate.onError(exceptionType, responseProvider); return this; }