From 6d79bf210f30dc79a552755a4e0cc6b811c09d19 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Wed, 29 Sep 2021 15:25:09 +0300 Subject: [PATCH] Add API Documentation properties. Remove swagger profile --- README.md | 10 ++--- pom.xml | 6 +++ .../DnetRoleManagementApplication.java | 3 +- .../config/properties/APIProperties.java | 38 +++++++++++++++++++ .../config/security/SwaggerConfig.java | 23 ++++++----- src/main/resources/registry.properties | 7 +++- 6 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 src/main/java/eu/dnetlib/dnetrolemanagement/config/properties/APIProperties.java diff --git a/README.md b/README.md index 0282f1e..e2c9356 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# dnet-role-management +# DNET Role Management -Dnet Role Management is a service which is communicating with AAI Registry -service providing methods to get users information, assign roles to users or +DNET Role Management is a service which is communicating with AAI Registry +service and provides methods to retrieve users information, assign roles to users or revoke roles from them. # Configuration @@ -22,7 +22,5 @@ revoke roles from them. ### Use Swagger -Project supports swagger UI in order to make testing easy to the developers. -In order to disable swagger for production environment, -a specific profile named "swagger" must be used on dev mode. +Project supports swagger UI documentation diff --git a/pom.xml b/pom.xml index f43615c..18815c3 100644 --- a/pom.xml +++ b/pom.xml @@ -88,6 +88,12 @@ + + + src/main/resources + true + + maven-war-plugin diff --git a/src/main/java/eu/dnetlib/dnetrolemanagement/DnetRoleManagementApplication.java b/src/main/java/eu/dnetlib/dnetrolemanagement/DnetRoleManagementApplication.java index fee3b97..1042a44 100644 --- a/src/main/java/eu/dnetlib/dnetrolemanagement/DnetRoleManagementApplication.java +++ b/src/main/java/eu/dnetlib/dnetrolemanagement/DnetRoleManagementApplication.java @@ -1,5 +1,6 @@ package eu.dnetlib.dnetrolemanagement; +import eu.dnetlib.dnetrolemanagement.config.properties.APIProperties; import eu.dnetlib.dnetrolemanagement.config.properties.RedisProperties; import eu.dnetlib.dnetrolemanagement.config.properties.RegistryProperties; import org.springframework.boot.SpringApplication; @@ -13,7 +14,7 @@ import org.springframework.context.annotation.PropertySources; @PropertySource("classpath:registry.properties"), @PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true) }) -@EnableConfigurationProperties({RegistryProperties.class, RedisProperties.class}) +@EnableConfigurationProperties({RegistryProperties.class, RedisProperties.class, APIProperties.class}) public class DnetRoleManagementApplication { public static void main(String[] args) { diff --git a/src/main/java/eu/dnetlib/dnetrolemanagement/config/properties/APIProperties.java b/src/main/java/eu/dnetlib/dnetrolemanagement/config/properties/APIProperties.java new file mode 100644 index 0000000..570bf53 --- /dev/null +++ b/src/main/java/eu/dnetlib/dnetrolemanagement/config/properties/APIProperties.java @@ -0,0 +1,38 @@ +package eu.dnetlib.dnetrolemanagement.config.properties; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties("api") +public class APIProperties { + + private String title; + private String description; + private String version; + + public APIProperties() { + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } +} diff --git a/src/main/java/eu/dnetlib/dnetrolemanagement/config/security/SwaggerConfig.java b/src/main/java/eu/dnetlib/dnetrolemanagement/config/security/SwaggerConfig.java index e4822c8..7e3e2b9 100644 --- a/src/main/java/eu/dnetlib/dnetrolemanagement/config/security/SwaggerConfig.java +++ b/src/main/java/eu/dnetlib/dnetrolemanagement/config/security/SwaggerConfig.java @@ -1,7 +1,10 @@ package eu.dnetlib.dnetrolemanagement.config.security; +import eu.dnetlib.dnetrolemanagement.config.properties.APIProperties; +import eu.dnetlib.dnetrolemanagement.config.properties.RedisProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; @@ -24,15 +27,20 @@ import java.util.List; * Swagger configuration class */ @Configuration -@Profile({"swagger"}) @EnableSwagger2 public class SwaggerConfig { - private Logger logger = LoggerFactory.getLogger(SwaggerConfig.class); + private final Logger logger = LoggerFactory.getLogger(SwaggerConfig.class); + private final APIProperties apiProperties; + + @Autowired + public SwaggerConfig(APIProperties apiProperties) { + this.apiProperties = apiProperties; + } + @Bean public Docket createRestApi() { - logger.info("SwaggerConfig for Dnet Role Management"); return new Docket(DocumentationType.SWAGGER_2) .globalOperationParameters(globalParameterList()) .apiInfo(apiInfo()) @@ -43,13 +51,10 @@ public class SwaggerConfig { } private ApiInfo apiInfo() { - logger.info("SwaggerConfig Dnet Role Management API information"); return new ApiInfoBuilder() - .title("Dnet Role Management Document") // title - .description("Api documentation") // description - .version("1.0") // version - .contact(new Contact("Konstantinos Triantafyllou", - "https://code-repo.d4science.org/MaDgIK/dnet-role-management/", "k.triantafyllou@di.uoa.gr")) // contact information + .title(this.apiProperties.getTitle()) + .description(this.apiProperties.getDescription()) + .version(this.apiProperties.getVersion()) .build(); } diff --git a/src/main/resources/registry.properties b/src/main/resources/registry.properties index 23cd36b..cd62565 100644 --- a/src/main/resources/registry.properties +++ b/src/main/resources/registry.properties @@ -1,10 +1,15 @@ +## Registry Properties registry.coid=2 registry.issuer=https://openaire-dev.aai-dev.grnet.gr/registry/ registry.user=user registry.password=pass registry.version=1.0 server.port=8090 +## Redis Properties redis.host = localhost redis.port = 6379 redis.password = -webbapp.front.domain=.di.uoa.gr \ No newline at end of file +## API Documentation Properties +api.title = DNET Role Management Documentation +api.description = DNET Role Management is a service which is communicating with AAI Registry service and provides methods to retrieve users information, assign roles to users or revoke roles from them. +api.version = ${project.version} \ No newline at end of file