Swagger-core: Swagger-maven-plugin generates first OpenAPI spec when executed twice

Created on 21 Nov 2018  路  1Comment  路  Source: swagger-api/swagger-core

We have a project that implements two different OpenAPI specs and these are done in two separate resource packages. When we run the swagger-maven-plugin we want it to generate two separate spec files, one from each resource package. However the plugin will produce the same spec file, the one for the resource package that is run first.

For example in the example below, the spec files generated all use the resource package "first.resource.package".

<plugin>
    <groupId>io.swagger.core.v3</groupId>
    <artifactId>swagger-maven-plugin</artifactId>
    <version>2.0.5</version>
    <executions>
        <execution>
            <configuration>
                <outputFileName>openapi-1</outputFileName>
                <outputPath>${project.build.directory}/generated-docs</outputPath>
                <outputFormat>JSONANDYAML</outputFormat>
                <openapiFilePath>${project.basedir}/src/main/resources/openapi-info.json</openapiFilePath>
                <resourcePackages>
                    <package>first.resource.package</package>
                </resourcePackages>
                <readAllResources>false</readAllResources>
                <prettyPrint>TRUE</prettyPrint>
            </configuration>
            <id>first</id>
            <phase>compile</phase>
            <goals>
                <goal>resolve</goal>
            </goals>
        </execution>
        <execution>
            <configuration>
                <outputFileName>openapi-2</outputFileName>
                <outputPath>${project.build.directory}/generated-docs</outputPath>
                <outputFormat>JSONANDYAML</outputFormat>
                <openapiFilePath>${project.basedir}/src/main/resources/openapi-info.json</openapiFilePath>
                <resourcePackages>
                    <package>second.resource.package</package>
                </resourcePackages>
                <readAllResources>false</readAllResources>
                <prettyPrint>TRUE</prettyPrint>
            </configuration>
            <id>second</id>
            <phase>compile</phase>
            <goals>
                <goal>resolve</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Please note that I have tried this in 2.0.6-SNAPSHOT and it produces the same results.

Most helpful comment

Please try with 2.0.6 version, providing a different contextId param in each execution e.g.

<execution>
 <configuration>
  <outputFileName>openapi-1</outputFileName>
  <contextId>openapi-1</contextId>
...
<execution>
 <configuration>
  <outputFileName>openapi-2</outputFileName>
  <contextId>openapi-2</contextId>
...

>All comments

Please try with 2.0.6 version, providing a different contextId param in each execution e.g.

<execution>
 <configuration>
  <outputFileName>openapi-1</outputFileName>
  <contextId>openapi-1</contextId>
...
<execution>
 <configuration>
  <outputFileName>openapi-2</outputFileName>
  <contextId>openapi-2</contextId>
...
Was this page helpful?
0 / 5 - 0 ratings