Add API Documentation properties. Remove swagger profile

This commit is contained in:
Konstantinos Triantafyllou 2021-09-29 15:25:09 +03:00
parent 16ff047f4a
commit 6d79bf210f
6 changed files with 70 additions and 17 deletions

View File

@ -1,7 +1,7 @@
# dnet-role-management # DNET Role Management
Dnet Role Management is a service which is communicating with AAI Registry DNET Role Management is a service which is communicating with AAI Registry
service providing methods to get users information, assign roles to users or service and provides methods to retrieve users information, assign roles to users or
revoke roles from them. revoke roles from them.
# Configuration # Configuration
@ -22,7 +22,5 @@ revoke roles from them.
### Use Swagger ### Use Swagger
Project supports swagger UI in order to make testing easy to the developers. Project supports swagger UI documentation
In order to disable swagger for production environment,
a specific profile named "swagger" must be used on dev mode.

View File

@ -88,6 +88,12 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>

View File

@ -1,5 +1,6 @@
package eu.dnetlib.dnetrolemanagement; package eu.dnetlib.dnetrolemanagement;
import eu.dnetlib.dnetrolemanagement.config.properties.APIProperties;
import eu.dnetlib.dnetrolemanagement.config.properties.RedisProperties; import eu.dnetlib.dnetrolemanagement.config.properties.RedisProperties;
import eu.dnetlib.dnetrolemanagement.config.properties.RegistryProperties; import eu.dnetlib.dnetrolemanagement.config.properties.RegistryProperties;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
@ -13,7 +14,7 @@ import org.springframework.context.annotation.PropertySources;
@PropertySource("classpath:registry.properties"), @PropertySource("classpath:registry.properties"),
@PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true) @PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true)
}) })
@EnableConfigurationProperties({RegistryProperties.class, RedisProperties.class}) @EnableConfigurationProperties({RegistryProperties.class, RedisProperties.class, APIProperties.class})
public class DnetRoleManagementApplication { public class DnetRoleManagementApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -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;
}
}

View File

@ -1,7 +1,10 @@
package eu.dnetlib.dnetrolemanagement.config.security; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
@ -24,15 +27,20 @@ import java.util.List;
* Swagger configuration class * Swagger configuration class
*/ */
@Configuration @Configuration
@Profile({"swagger"})
@EnableSwagger2 @EnableSwagger2
public class SwaggerConfig { 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 @Bean
public Docket createRestApi() { public Docket createRestApi() {
logger.info("SwaggerConfig for Dnet Role Management");
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
.globalOperationParameters(globalParameterList()) .globalOperationParameters(globalParameterList())
.apiInfo(apiInfo()) .apiInfo(apiInfo())
@ -43,13 +51,10 @@ public class SwaggerConfig {
} }
private ApiInfo apiInfo() { private ApiInfo apiInfo() {
logger.info("SwaggerConfig Dnet Role Management API information");
return new ApiInfoBuilder() return new ApiInfoBuilder()
.title("Dnet Role Management Document") // title .title(this.apiProperties.getTitle())
.description("Api documentation") // description .description(this.apiProperties.getDescription())
.version("1.0") // version .version(this.apiProperties.getVersion())
.contact(new Contact("Konstantinos Triantafyllou",
"https://code-repo.d4science.org/MaDgIK/dnet-role-management/", "k.triantafyllou@di.uoa.gr")) // contact information
.build(); .build();
} }

View File

@ -1,10 +1,15 @@
## Registry Properties
registry.coid=2 registry.coid=2
registry.issuer=https://openaire-dev.aai-dev.grnet.gr/registry/ registry.issuer=https://openaire-dev.aai-dev.grnet.gr/registry/
registry.user=user registry.user=user
registry.password=pass registry.password=pass
registry.version=1.0 registry.version=1.0
server.port=8090 server.port=8090
## Redis Properties
redis.host = localhost redis.host = localhost
redis.port = 6379 redis.port = 6379
redis.password = redis.password =
webbapp.front.domain=.di.uoa.gr ## 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}