You can define the maven plugin to generate at build time the openapi.json
file.
Then the runtime is able to load it directly and merge it with the current runtime.
The big advantage is to be able to use it without the runtime for documentation purposes.
Here is how to define it:
<plugin>
<groupId>org.apache.geronimo</groupId>
<artifactId>geronimo-openapi-maven-plugin</artifactId>
<version>${openapi.version}</version>
<executions>
<execution>
<id>generate-openapi.json</id>
<goals>
<goal>openapi.json</goal>
</goals>
<configuration>
<application>com.test.MyApp</application>
<endpointClasses>
<endpointClass>com.test.SomeEndpoint</endpointClass>
<endpointClass>com.test.SomeOtherEndpoint</endpointClass>
</endpointClasses>
<info>
<version>1</version>
<title>My Title</title>
<description>Bla Bla</description>
</info>
</configuration>
</execution>
</executions>
</plugin>