-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EA-3669 added info endpoint and swagger
- Loading branch information
1 parent
0ef68a3
commit f254655
Showing
9 changed files
with
177 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
record-api-web/src/main/java/eu/europeana/api/record/config/BuildInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package eu.europeana.api.record.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.PropertySource; | ||
|
||
/** | ||
* Makes build information and the application name and description from the project's pom.xml available. | ||
* While generating a war file this data is written automatically to the build.properties file which is read here. | ||
* Note that the same information is also available in the Spring-Boot /actuator/info endpoint | ||
*/ | ||
@Configuration | ||
@PropertySource("classpath:build.properties") | ||
public class BuildInfo { | ||
|
||
@Value("${info.app.name}") | ||
private String appName; | ||
|
||
@Value("${info.app.version}") | ||
private String appVersion; | ||
|
||
@Value("${info.app.description}") | ||
private String appDescription; | ||
|
||
@Value("${info.build.number}") | ||
private String buildNumber; | ||
|
||
public String getAppName() { | ||
return appName; | ||
} | ||
|
||
public String getAppDescription() { | ||
return appDescription; | ||
} | ||
|
||
public String getAppVersion() { | ||
return appVersion; | ||
} | ||
|
||
public String getBuildNumber() { | ||
return buildNumber; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
record-api-web/src/main/java/eu/europeana/api/record/config/SpringDocConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package eu.europeana.api.record.config; | ||
|
||
import io.swagger.v3.oas.models.ExternalDocumentation; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Contact; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import io.swagger.v3.oas.models.info.License; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SpringDocConfig { | ||
|
||
private final BuildInfo buildInfo; | ||
|
||
/** | ||
* Initialize SpringDoc with API build information | ||
* @param buildInfo object for retrieving build information | ||
*/ | ||
public SpringDocConfig(BuildInfo buildInfo) { | ||
this.buildInfo = buildInfo; | ||
} | ||
|
||
@Bean | ||
public OpenAPI userServiceOpenAPI() { | ||
return new OpenAPI().info(new Info().title(buildInfo.getAppName()) | ||
.description(buildInfo.getAppDescription()) | ||
.version(buildInfo.getAppVersion() + " (build " + buildInfo.getBuildNumber() + ")") | ||
.contact(new Contact().name("API team").url("https://api.europeana.eu").email("[email protected]")) | ||
.termsOfService("https://www.europeana.eu/en/rights/api-terms-of-use") | ||
.license(new License().name("EUPL 1.2").url("https://www.eupl.eu"))) | ||
.externalDocs(new ExternalDocumentation() | ||
.description("Documentation") | ||
.url("https://pro.europeana.eu/page/intro#general")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#debug=true | ||
|
||
#Spring configs | ||
spring.application.name=Record API | ||
spring.main.allow-bean-definition-overriding=false | ||
info.app.name=${spring.application.name} | ||
info.app.version=${project.version} | ||
info.app.description=Europeana Record API retrieves record in different formats. | ||
|
||
#switch Spring boot logging to log4j (see https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.logging) | ||
org.springframework.boot.logging.LoggingSystem= org.springframework.boot.logging.log4j2.Log4J2LoggingSystem | ||
|
||
## management / actuator / swagger | ||
#springfox.documentation.swagger-ui.enabled=true | ||
management.security.enabled=false | ||
|
||
management.endpoints.web.exposure.include=health,info | ||
# for debugging conditioonal annotations locally the following configuration can be used | ||
management.info.build.enabled=true | ||
management.info.git.enabled=true | ||
management.health.probes.enabled=true | ||
|
||
### Configurations for swagger console | ||
#springdoc.paths-to-exclude=/error | ||
#springdoc.show-actuator=true | ||
|
||
## server configurations | ||
server.port = 8080 | ||
server.error.include-message=always | ||
server.error.include-stacktrace=on_param | ||
server.error.include-exception=false | ||
server.error.see-also=https://pro.europeana.eu/page/apis | ||
|
||
# compression: | ||
# enabled: true | ||
# min-response-size: 4096 | ||
# mime-types: application/json, application/ld+json, application/xml, text/html, text/xml, text/plain |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Template for application build and version information. If you use the Europeana Parent POM then all Maven properties | ||
# will be filled during a build by the Maven War plugin. | ||
# Properties that start with 'info.' will be displayed by Spring Actuator in the /actuator/info endpoint and can be | ||
# reused in the BuildInfo class | ||
|
||
info.app.name = ${project.name} | ||
info.app.version = ${project.version} | ||
info.app.description = ${project.description} | ||
|
||
info.build.branch = ${scmBranch} | ||
info.build.number = ${buildNumber} | ||
info.build.date = ${timestamp} | ||
|
||
|
||
## Default values for local testing. Will be ignored in war builds | ||
project.name = MyApi | ||
project.version = n/a | ||
project.description = No description available | ||
scmBranch = n/a | ||
buildNumber = local-build | ||
timestamp = n/a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
<html lang="en"> | ||
<head> | ||
<title>Europeana Record API</title> | ||
<meta http-equiv="refresh" content="0; url=/swagger-ui/index.html"> | ||
</head> | ||
<body> | ||
<h1>Europeana API</h1> | ||
<!--<li><a href="/actuator/info">Build information</a></li>--> | ||
<!--<li><a href="/swagger-ui/index.html">Swagger UI</a></li>--> | ||
</body> | ||
</html> |