From 0017434e91f6efe1100d3c30e307f3cbf26c30d9 Mon Sep 17 00:00:00 2001 From: Erling Jahr Date: Thu, 7 Dec 2023 14:56:18 +0100 Subject: [PATCH] FKS-550 #comment enabled swagger with authentication, cleaning #done --- build.gradle | 6 ++-- src/main/java/no/fintlabs/Application.java | 34 ++++++++++++++++++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index a501bca..2123ed6 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' - //implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0' + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0' implementation 'io.netty:netty-resolver-dns-native-macos:4.1.82.Final:osx-aarch_64' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' @@ -42,15 +42,13 @@ dependencies { runtimeOnly 'org.postgresql:postgresql' implementation 'org.springframework.kafka:spring-kafka' implementation 'no.fintlabs:fint-kafka:3.0.0-rc-1' - implementation 'no.fintlabs:fint-antlr:1.1.1' implementation 'no.fintlabs:fint-resource-server-security:1.1.0' implementation 'no.fintlabs:fint-kontroll-authorization:1.1.6' implementation 'no.fint:fint-model-resource:0.4.1' implementation 'io.projectreactor:reactor-core' implementation 'org.apache.commons:commons-collections4:4.4' implementation 'org.modelmapper:modelmapper:3.1.1' - implementation 'org.springdoc:springdoc-openapi-ui:1.6.15' - implementation 'org.springdoc:springdoc-openapi-security:1.6.15' + compileOnly 'org.projectlombok:lombok' runtimeOnly 'io.micrometer:micrometer-registry-prometheus' diff --git a/src/main/java/no/fintlabs/Application.java b/src/main/java/no/fintlabs/Application.java index 2780fce..e06e442 100644 --- a/src/main/java/no/fintlabs/Application.java +++ b/src/main/java/no/fintlabs/Application.java @@ -1,18 +1,46 @@ package no.fintlabs; -import no.fint.antlr.EnableFintFilter; +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.context.annotation.Bean; -@EnableFintFilter @ConfigurationPropertiesScan @SpringBootApplication public class Application { public static void main(String[] args) { + SpringApplication.run(Application.class, args); } + @Bean + public OpenAPI openAPIDescription() { + return new OpenAPI() + .info(new Info() + .title("FINT Kontroll user management") + .version("1.0.0") + .description("API's for retrieving user objects") + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))) + .components(new Components() + .addSecuritySchemes("bearer-jwt", new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT") + .in(SecurityScheme.In.HEADER) + .description("Auth key") + .name("Authorization")) + ) + .addSecurityItem(new SecurityRequirement() + .addList("bearer-jwt")) + ; + } + }