0

I'm using the springdoc-openapi-maven-plugin to generate a document_name.json file during the mvn clean install command, with the following plugin configuration:

 <plugin>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-maven-plugin</artifactId>
    <version>0.2</version>
    <executions>
        <execution>
            <phase>integration-test</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration> 
        <outputFileName>sentinel-openapi.json</outputFileName> 
        <outputDir>${project.build.directory/../../openapi-doc/}</outputDir> 
    </configuration>
    </plugin>

In addition, I'm using the spring-boot-maven-plugin to start and stop the application during integration testing:

 <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>pre-integration-test</id>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>post-integration-test</id>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

However, I need to generate the same document_name.json file using the ./mvnw package command instead. How can I configure the springdoc-openapi-maven-plugin and spring-boot-maven-plugin to achieve this?

1 Answers1

0

By default springdoc-openapi-maven-plugin generates the API docs in the port 8080(It assumes the application to be running on 8080), If the port your application is running is different then you will have to specify the apiDocsUrl in the configuration tag of openapi-maven-plugin

 <plugin>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-maven-plugin</artifactId>
    <version>1.4</version>
    <executions>
        <execution>
            <id>integration-test</id>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <apiDocsUrl>http://localhost:{YourApplicationPort}/v3/api-docs</apiDocsUrl>
        <outputFileName>swagger.json</outputFileName>
    </configuration>
</plugin>
T Rachana
  • 1
  • 1