override the generated url by swagger

This commit is contained in:
Michele Artini 2022-09-08 15:15:13 +02:00
parent 7a83fb8c67
commit 6c3b7d6e7c
8 changed files with 38 additions and 0 deletions

View File

@ -1,6 +1,9 @@
server.servlet.context-path=/bioschemas-api
server.port=8281
server.public_url = http://localhost:8281/bioschemas-api
server.public_desc = API Base URL
spring.profiles.active=garr
logging.file.name = /var/log/bioschemas-api/bioschemas.log

View File

@ -1,5 +1,8 @@
spring.profiles.active = dev,openaire
server.public_url =
server.public_desc = API Base URL
#logging.level.root=DEBUG
maven.pom.path = /META-INF/maven/eu.dnetlib.dhp/dhp-broker-application/effective-pom.xml

View File

@ -1,5 +1,8 @@
spring.profiles.active = dev,openaire
server.public_url =
server.public_desc = API Base URL
#logging.level.root=DEBUG
maven.pom.path = /META-INF/maven/eu.dnetlib.dhp/dhp-broker-public-application/effective-pom.xml

View File

@ -1,5 +1,8 @@
spring.main.banner-mode = console
server.public_url =
server.public_desc = API Base URL
logging.level.root = INFO
maven.pom.path = /META-INF/maven/eu.dnetlib.dhp/dhp-mdstore-manager/effective-pom.xml

View File

@ -2,6 +2,9 @@
server.servlet.context-path = /openaire
server.port = 8080
server.public_url =
server.public_desc = API Base URL
spring.datasource.driverClassName = org.postgresql.Driver
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQL9Dialect
spring.jpa.show-sql = false

View File

@ -1,5 +1,8 @@
server.port=8480
server.public_url = http://localhost:8480
server.public_desc = API Base URL
spring.profiles.active=dev
maven.pom.path = /META-INF/maven/eu.dnetlib.dhp/dnet-orgs-database-application/effective-pom.xml

View File

@ -1,5 +1,8 @@
spring.main.banner-mode = console
server.public_url =
server.public_desc = API Base URL
logging.level.root = INFO
dhp.swagger.api.host = localhost:8080
#dhp.swagger.api.host = api.scholexplorer.openaire.eu

View File

@ -19,9 +19,11 @@ import org.springframework.core.io.ClassPathResource;
import io.micrometer.core.instrument.ImmutableTag;
import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.util.StringUtils;
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.servers.Server;
import io.swagger.v3.oas.models.tags.Tag;
public abstract class AbstractDnetApp {
@ -35,6 +37,12 @@ public abstract class AbstractDnetApp {
@Value("${maven.pom.path}")
private ClassPathResource pom;
@Value("${server.public_url}")
private String serverPublicUrl;
@Value("${server.public_desc}")
private String serverPublicDesc;
private static final Logger log = LoggerFactory.getLogger(AbstractDnetApp.class);
@PostConstruct
@ -57,7 +65,16 @@ public abstract class AbstractDnetApp {
@Bean
public OpenAPI newSwaggerDocket() {
final List<Server> servers = new ArrayList<>();
if (StringUtils.isNotBlank(serverPublicUrl)) {
final Server server = new Server();
server.setUrl(serverPublicUrl);
server.setDescription(serverPublicDesc);
servers.add(server);
}
return new OpenAPI()
.servers(servers)
.info(getSwaggerInfo())
.tags(swaggerTags());
}