swagger maven plgin executions do not run independant

296 views Asked by At

I use the latest swagger-maven-plugin from the io.swagger.core.v3 to generate my static swagger api documentation. In my project, I have to separate apis so I want to get a json and yml representation for each api within one package process.

             <plugin>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <version>2.2.6</version>
                <configuration>
                    <outputPath>${basedir}/target/</outputPath>
                    <outputFormat>JSONANDYAML</outputFormat>
                    <prettyPrint>true</prettyPrint>
                </configuration>
                <executions>
                    <execution>
                        <id>1</id>  
                        <goals>
                            <goal>resolve</goal>
                        </goals>
                        <configuration>
                            <resourcePackages>
                                <resourcePackage>de.test.rest</resourcePackage>
                            </resourcePackages>
                            <outputFileName>swagger</outputFileName>
                            <configurationFilePath>${basedir}/src/main/resources/openApiConfig.yml</configurationFilePath> 
                        </configuration>
                        
                </execution>
                <execution>
                    <id>2</id>
                    <goals>
                        <goal>resolve</goal>
                    </goals>
                    <configuration>
                        <resourcePackages>
                            <resourcePackage>de.test.secondAPI</resourcePackage>
                        </resourcePackages>
                        <outputFileName>secondAPI</outputFileName>
                        <configurationFilePath>${basedir}/src/main/resources/secondOpenApiConfig.yml</configurationFilePath> 
                        
                    </configuration>
                </execution>
                </executions>
            </plugin>

PROBLEM: the execution creates the expected json and yml files for each execution

  • swagger.yml
  • swagger.json
  • secondAPI.yml
  • secondAPI.json

The problem is, that the seconAPI files are a copy of the swagger files. I've read the documentation and I thought that configuration in the plugin root is shared between multiple executions. Configurations within the execution tag are individually used per execution.

Is there a way to run the executions in parallel with individual configuration? Or is it a problem with the plugin itself?

EDIT: Each execution works as expected when there is only one execution defined in the executions tag.

1

There are 1 answers

1
Antoni Nadal On

I have same problem !!! :-(

Work-Around: use this another plugin for the second configuration:

<plugin>
              <groupId>io.openapitools.swagger</groupId>
              <artifactId>swagger-maven-plugin</artifactId>
              <configuration>
                <resourcePackages>
                  <package>es.caib.carpeta.api.externa.certificats</package>
                  <package>es.caib.carpeta.api.externa.config</package>
                </resourcePackages>
                <outputDirectory>${project.basedir}/openapi/</outputDirectory>
                <outputFilename>openapi_certificat</outputFilename>
                <outputFormats>JSON,YAML</outputFormats>
                <prettyPrint>true</prettyPrint>
              </configuration>
              <executions>
                <execution>
                  <goals>
                    <goal>generate</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>