From 3fa9f8f7a14480d16cd31b0a18fee8d70c9c335c Mon Sep 17 00:00:00 2001 From: SebClem Date: Fri, 17 Jun 2022 18:19:58 +0200 Subject: [PATCH] :ambulance: Fix swagger url --- .../net/Broken/Api/OpenApi/OpenApiConfig.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/Broken/Api/OpenApi/OpenApiConfig.java b/src/main/java/net/Broken/Api/OpenApi/OpenApiConfig.java index 0117dca..8ea91a8 100644 --- a/src/main/java/net/Broken/Api/OpenApi/OpenApiConfig.java +++ b/src/main/java/net/Broken/Api/OpenApi/OpenApiConfig.java @@ -1,33 +1,35 @@ package net.Broken.Api.OpenApi; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; @Configuration public class OpenApiConfig { + @Bean + public OpenAPI customOpenAPI() { + final String securitySchemeName = "JWT"; - @Bean - public OpenAPI customOpenAPI() { - final String securitySchemeName = "JWT"; - // final String apiTitle = String.format("%s API", StringUtils.capitalize(moduleName)); - return new OpenAPI() - .addSecurityItem(new SecurityRequirement().addList(securitySchemeName)) - .components( - new Components() - .addSecuritySchemes(securitySchemeName, - new SecurityScheme() - .name(securitySchemeName) - .type(SecurityScheme.Type.HTTP) - .scheme("bearer") - .bearerFormat("JWT") + // final String apiTitle = String.format("%s API", StringUtils.capitalize(moduleName)); + return new OpenAPI() + .addSecurityItem(new SecurityRequirement().addList(securitySchemeName)) + .components( + new Components() + .addSecuritySchemes(securitySchemeName, + new SecurityScheme() + .name(securitySchemeName) + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT") + ) ) - ); - } + .addServersItem(new Server().url("/").description("Default")); + } } \ No newline at end of file