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
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

View File

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

View File

@ -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) {

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;
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();
}

View File

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