From 143b8f99af9daa5ac1a77a69ab006ce46829b188 Mon Sep 17 00:00:00 2001 From: Andrii Landiak Date: Mon, 1 Dec 2025 12:17:22 +0200 Subject: [PATCH] Minor changes --- .../server/config/SwaggerConfiguration.java | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/config/SwaggerConfiguration.java b/application/src/main/java/org/thingsboard/server/config/SwaggerConfiguration.java index 42a29b8d74..f6851a5a71 100644 --- a/application/src/main/java/org/thingsboard/server/config/SwaggerConfiguration.java +++ b/application/src/main/java/org/thingsboard/server/config/SwaggerConfiguration.java @@ -383,24 +383,6 @@ public class SwaggerConfiguration { )); } - private void securityCustomization(Map.Entry entry, SecurityRequirement jwtBearerRequirement, SecurityRequirement apiKeyRequirement) { - var path = entry.getKey(); - - if (path.matches(securityPathRegex) - && !path.matches(nonSecurityPathRegex) - && !path.equals(LOGIN_ENDPOINT) - && !path.equals(REFRESH_TOKEN_ENDPOINT)) { - - entry.getValue() - .readOperationsMap() - .values() - .forEach(operation -> { - operation.addSecurityItem(jwtBearerRequirement); - operation.addSecurityItem(apiKeyRequirement); - }); - } - } - private Tag extractTagFromPath(Map.Entry entry) { var tagName = tagItemFromPathItem(entry.getValue()); return tagName != null ? tagFromTagItem(tagName) : null; @@ -439,19 +421,32 @@ public class SwaggerConfiguration { var responses = operation.getResponses(); if (responses == null) { - responses = new ApiResponses(); - operation.setResponses(responses); + responses = errorResponses; + } else { + ApiResponses updated = responses; + errorResponses.forEach((key, apiResponse) -> { + if (!updated.containsKey(key)) { + updated.put(key, apiResponse); + } + }); } - - ApiResponses finalResponses = responses; - errorResponses.forEach((code, response) -> { - if (!finalResponses.containsKey(code)) { - finalResponses.put(code, response); - } - }); + operation.setResponses(responses); }); } + private void securityCustomization(Map.Entry entry, SecurityRequirement jwtBearerRequirement, SecurityRequirement apiKeyRequirement) { + var path = entry.getKey(); + if (path.matches(securityPathRegex) && !path.matches(nonSecurityPathRegex) && !path.equals(LOGIN_ENDPOINT) && !path.equals(REFRESH_TOKEN_ENDPOINT)) { + entry.getValue() + .readOperationsMap() + .values() + .forEach(operation -> { + operation.addSecurityItem(jwtBearerRequirement); + operation.addSecurityItem(apiKeyRequirement); + }); + } + } + private static ApiResponses loginResponses() { ApiResponses apiResponses = new ApiResponses(); apiResponses.addApiResponse("200", new ApiResponse().description("OK")