Skip to content

Commit

Permalink
Use version from Maven configuration for Swagger UI
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkopp committed Nov 22, 2023
1 parent 91749d1 commit e7871b5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@

<build>
<finalName>t2-modulith</finalName>
<!-- Enable resource filtering to be able to get the project version as an env var-->
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/application*.yaml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.unistuttgart.t2.modulith.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand All @@ -10,12 +11,12 @@
@Configuration
public class OpenAPIConfiguration {

@Value("${T2_COMMON_VERSION:0.0.1}")
@Value("${info.app.version:unknown}")
private String version;

@Bean
public io.swagger.v3.oas.models.OpenAPI customOpenAPI() {
return new io.swagger.v3.oas.models.OpenAPI().components(new Components()).info(new Info()
public OpenAPI customOpenAPI() {
return new OpenAPI().components(new Components()).info(new Info()
.title("T2 Modulith API")
.description("API of the T2-Project's modulith implementation.")
.version(version));
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Default profile (some values will be overwritten by other profiles)
info:
app:
version: '@project.version@'

spring:
data:
rest:
Expand Down

0 comments on commit e7871b5

Please sign in to comment.