Spring boot @project.version@ variable not working with openApi

Viewed 3496

i try to use my old code from swagger-ui 2.5.0 in openApi 1.4.3,

<!-- SWAGGER -->
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    <version>1.4.3</version>
</dependency>
<!--         <dependency> -->
<!--             <groupId>io.springfox</groupId> -->
<!--             <artifactId>springfox-swagger2</artifactId> -->
<!--             <version>2.5.0</version> -->
<!--             <exclusions> -->
<!--                 <exclusion> -->
<!--                     <artifactId>jackson-annotations</artifactId> -->
<!--                     <groupId>com.fasterxml.jackson.core</groupId> -->
<!--                 </exclusion> -->
<!--             </exclusions> -->
<!--         </dependency> -->
<!--         <dependency> -->
<!--             <groupId>io.springfox</groupId> -->
<!--             <artifactId>springfox-swagger-ui</artifactId> -->
<!--             <version>2.5.0</version> -->
<!--         </dependency> -->

currently when i run my web service, it's faild, without error, and after many debugging, i noticed that openApi don't accept the syntax @project.version@ !

i use this syntax to get with spring boot the project version from pom.xml. this syntax work in swagger 2.5.0, and not in 2.9.2.

i'm using yml file.

swagger:
  enabled: true
  title: REST APIs for breakdown calculator
  description: REST APIs for breakdown calculator
  version: @project.version@
  terms-url:
  license:
  license-url:
  name: WORLD-LIST-REG
  email: lis@soc.mn
  url:

Did you have an idea ?

Thank you in advance.

1 Answers

The syntax @project.version@ is just a filter from your maven configuration.

This is the sample code:

@SpringBootApplication
public class SpringdocApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringdocApplication.class, args);
    }

    @Bean
    public OpenAPI customOpenAPI(@Value("${springdoc.version}") String appVersion) {
        return new OpenAPI()
                .components(new Components())
                .info(new Info().title("Books API").version(appVersion)
                        .license(new License().name("Apache 2.0").url("http://springdoc.org")));
    }
}

And on your configuration application.properties file :

project.version= @project.version@

Note also, you need to follow the migration steps as follow:

Related