From 6520c810c01df1454bfbe66f2dc5ace6d8310a7e Mon Sep 17 00:00:00 2001 From: JuanfeSanahuja Date: Mon, 13 Jan 2025 18:06:09 +0100 Subject: [PATCH] Added token to services if it is provided #TASK-5914 --- .../server/generator/openapi/JsonOpenApiGenerator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/generator/openapi/JsonOpenApiGenerator.java b/opencga-server/src/main/java/org/opencb/opencga/server/generator/openapi/JsonOpenApiGenerator.java index 9308776584..d876e0d41f 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/generator/openapi/JsonOpenApiGenerator.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/generator/openapi/JsonOpenApiGenerator.java @@ -86,11 +86,12 @@ public Swagger generateJsonOpenApi(ApiCommons apiCommons, String token) { javax.ws.rs.Path methodPathAnnotation = wsmethod.getAnnotation(javax.ws.rs.Path.class); String fullPath = basePath + (methodPathAnnotation != null ? methodPathAnnotation.value() : ""); method.setOperationId(methodPathAnnotation != null ? methodPathAnnotation.value() : ""); + List tokens = new ArrayList<>(); if(StringUtils.isEmpty(token)){ - List tokens = new ArrayList<>(); - tokens.add(token); - method.setSecurity(Collections.singletonList(Collections.singletonMap("BearerAuth", tokens))); + tokens.add("Bearer "+token); } + method.setSecurity(Collections.singletonList(Collections.singletonMap("BearerAuth", tokens))); + // Crear o actualizar el Path paths.put(fullPath, new HashMap<>()); paths.get(fullPath).put(httpMethod, method);