-
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.
Merge pull request #11 from europeana/EA-3669_AddFewConfigs
EA-3669 added info endpoint and swagger
- Loading branch information
Showing
14 changed files
with
245 additions
and
35 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
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
45 changes: 45 additions & 0 deletions
45
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,45 @@ | ||
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 | ||
* @author Sristhti Singh | ||
* @since 26 Feb 2024 | ||
*/ | ||
@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; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
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; | ||
|
||
/** | ||
* Initialises Spring doc configurations | ||
* @author Sristhti Singh | ||
* @since 26 Feb 2024 | ||
*/ | ||
@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
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
Oops, something went wrong.