title: How can I integrate POM build version into YAML generation using springdoc-openapi-maven-plugin?
body: <p>Is there a way to programmatically set the build version from the POM of my Spring Boot application into the OpenApi YAML generated by the springdoc-openapi-maven-plugin?</p>
  <p>How can I achieve it?</p>
  <p>Currently I have integrated the springdoc-openapi-maven-plugin this way:</p>
  <pre><code>    &lt;plugin&gt;
          &lt;groupId&gt;org.springdoc&lt;/groupId&gt;
          &lt;artifactId&gt;springdoc-openapi-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;1.1&lt;/version&gt;
          &lt;executions&gt;
              &lt;execution&gt;
                  &lt;id&gt;integration-test&lt;/id&gt;
                  &lt;goals&gt;
                      &lt;goal&gt;generate&lt;/goal&gt;
                  &lt;/goals&gt;
              &lt;/execution&gt;
          &lt;/executions&gt;
          &lt;configuration&gt;
              &lt;apiDocsUrl&gt;http://localhost:9090/v3/api-docs.yaml&lt;/apiDocsUrl&gt;
              &lt;outputFileName&gt;my_open_api_specification.yml&lt;/outputFileName&gt;
              &lt;outputDir&gt;${project.build.directory}/my_open_api_specification/&lt;/outputDir&gt;
              &lt;skip&gt;false&lt;/skip&gt;
          &lt;/configuration&gt;
      &lt;/plugin&gt;
  </code></pre>
  <p>I have an interface to annotate methods with OpenApi annotations:</p>
  <pre><code>@Tag(name = &quot;API Operationen&quot;)
  @RequestMapping
  public interface RestApi {
  ...
  
      @Bean
      default OpenAPI myOpenApi() {
      
          return new OpenAPI()
              .info(new Info()
                  .title(&quot;The title&quot;)
                  .version(&quot;1.0&quot;)           &lt;-- I want to dynamically set this version with the value coming from  BuildProperties (POM version).
                  .description(&quot;The description&quot;));
      }
  }
  </code></pre>
  <p>I found some information using spring-boot-maven-plugin but I didn't succeed:</p>
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
      &lt;!-- &lt;version&gt;2.5.4&lt;/version&gt; --&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;goals&gt;
                  &lt;goal&gt;build-info&lt;/goal&gt;
              &lt;/goals&gt;
          &lt;/execution&gt;
          &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  <hr />
  <h2>Update</h2>
  <hr />
  <p>In the meantime I moved the bean definition from the interface into a @Configuration file/class but when I start the application I get a NullPointerException  during the bean creation of <code>myOpenApi</code>:</p>
  <pre><code>@Configuration
  @ConfigurationPropertiesScan(&quot;xxx&quot;)
  @RequiredArgsConstructor
  public class OpenApiConfig {
  
      @Autowired    // &lt;-- was missing
      BuildProperties buildProperties;
  
      @Bean
      OpenAPI myOpenApi() {
  
          return new OpenAPI()
              .info(new Info()
                  .title(&quot;FooBar&quot;)
                  .version(buildProperties.getVersion())
                  .description(&quot;blablabla&quot;));
      }
  }
  </code></pre>
  <p>As far as I understood the BuildProperties gets created by the Maven plugin and is available when the <code>myOpenApi</code> is going to be created, but it seems as if this is not the case. (At least with my configuration.)</p>