From b6f9c1dc7cd1ba3c5df658bb2d30bce96e75a95e Mon Sep 17 00:00:00 2001 From: "Badr.NassLahsen" Date: Sat, 2 Dec 2023 13:13:56 +0100 Subject: [PATCH] A question about resource path processing. Fixes #2348 --- .../webflux/ui/SwaggerResourceResolver.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerResourceResolver.java b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerResourceResolver.java index 11ee7dbad..343227120 100644 --- a/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerResourceResolver.java +++ b/springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerResourceResolver.java @@ -30,23 +30,29 @@ public SwaggerResourceResolver(SwaggerUiConfigProperties swaggerUiConfigProperti @Override public Mono resolveResource(ServerWebExchange exchange, String requestPath, List locations, ResourceResolverChain chain) { - Mono resolved = chain.resolveResource(exchange, requestPath, locations); - if (!Mono.empty().equals(resolved)) { - String webJarResourcePath = findWebJarResourcePath(requestPath); - if (webJarResourcePath != null) - return chain.resolveResource(exchange, webJarResourcePath, locations); - } - return resolved; + return chain.resolveResource(exchange, requestPath, locations) + .switchIfEmpty(Mono.defer(() -> { + String webJarsResourcePath = findWebJarResourcePath(requestPath); + if (webJarsResourcePath != null) { + return chain.resolveResource(exchange, webJarsResourcePath, locations); + } + else { + return Mono.empty(); + } + })); } @Override - public Mono resolveUrlPath(String resourcePath, List locations, ResourceResolverChain chain) { - Mono path = chain.resolveUrlPath(resourcePath, locations); - if (!Mono.empty().equals(path)) { - String webJarResourcePath = findWebJarResourcePath(resourcePath); - if (webJarResourcePath != null) - return chain.resolveUrlPath(webJarResourcePath, locations); - } - return path; + public Mono resolveUrlPath(String resourceUrlPath, List locations, ResourceResolverChain chain) { + return chain.resolveUrlPath(resourceUrlPath, locations) + .switchIfEmpty(Mono.defer(() -> { + String webJarResourcePath = findWebJarResourcePath(resourceUrlPath); + if (webJarResourcePath != null) { + return chain.resolveUrlPath(webJarResourcePath, locations); + } + else { + return Mono.empty(); + } + })); } } \ No newline at end of file