swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API

Home Page:http://swagger.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

swagger-maven-plugin-jakarta is always using the resourceClasses from the first execution

ahoehma opened this issue · comments

I define multiple executions for swagger-maven-plugin-jakarta and it seems that the resourceClasses from the first execution is re-used in all following executions.

All the generated outputs have the same content :-)

<properties>
    <api.version>1.20</api.version>
    <api.version.new>${api.version}</api.version.new>
    <cc.openapi.configuration.new>cc-${api.version.new}-configuration</cc.openapi.configuration.new>
    <cc.openapi.history.new>cc-${api.version.new}-history</cc.openapi.history.new>
    <cc.openapi.history-analytics.new>cc-${api.version.new}-history-analytics</cc.openapi.history-analytics.new>
    <cc.openapi.products.new>cc-${api.version.new}-products</cc.openapi.products.new>
    <cc.openapi.brain.new>cc-${api.version.new}-brain</cc.openapi.brain.new>
    <cc.openapi.creation-cache.new>cc-${api.version.new}-creation-cache</cc.openapi.creation-cache.new>
    <cc.openapi.settings.new>cc-${api.version.new}-settings</cc.openapi.settings.new>
    <cc.openapi.vt.new>cc-${api.version.new}-vt</cc.openapi.vt.new>
  </properties>

<profiles>
    <profile>
      <id>generate-api</id>
      <build>
        <plugins>
          <plugin>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-maven-plugin-jakarta</artifactId>
            <version>2.2.21</version>
            <configuration>
              <outputFormat>JSONANDYAML</outputFormat>
              <encoding>UTF-8</encoding>
              <sortOutput>true</sortOutput>
              <prettyPrint>true</prettyPrint>
              <readAllResources>false</readAllResources>
              <!-- see src/main/resources/META-INF/cc-api-config.yaml - filtered by maven during build with some values from cc top-level pom!-->
              <openapiFilePath>${project.build.outputDirectory}/META-INF/cc-api-config.yaml</openapiFilePath>
              <openapi31>false</openapi31>
            </configuration>
            <executions>
              <execution>
                <id>generate-api-cc-configuration</id>
                <goals>
                  <goal>resolve</goal>
                </goals>
                <configuration>
                  <outputPath>${project.basedir}/target/openapi-generated/v${api.version.new}/</outputPath>
                  <outputFileName>${cc.openapi.configuration.new}</outputFileName>
<!------------------------ this one is used for all following executions ?! ------------------------------------->
                  <resourceClasses>com.siemens.spice.cc.rest.service.configuration.ConfigurationController</resourceClasses>
                </configuration>
              </execution>
              <execution>
                <id>generate-api-cc-configuration-history</id>
                <goals>
                  <goal>resolve</goal>
                </goals>
                <configuration>
                  <outputPath>${project.basedir}/target/openapi-generated/v${api.version.new}/</outputPath>
                  <outputFileName>${cc.openapi.history.new}</outputFileName>
<!------------------------ this one is completely ignored ?! ------------------------------------->
                  <resourceClasses>com.siemens.spice.cc.rest.api.HistoryControllerApi</resourceClasses>
                </configuration>
              </execution>
              <execution>
                <id>generate-api-cc-configuration-history-analytics</id>
                <goals>
                  <goal>resolve</goal>
                </goals>
                <configuration>
                  <outputPath>${project.basedir}/target/openapi-generated/v${api.version.new}/</outputPath>
                  <outputFileName>${cc.openapi.history-analytics.new}</outputFileName>
<!------------------------ this one is completely ignored ?! ------------------------------------->
                  <resourceClasses>com.siemens.spice.cc.rest.service.history.HistoryAnalyticsController</resourceClasses>
                </configuration>
              </execution>
              <execution>
                <id>generate-api-cc-configuration-products</id>
                <goals>
                  <goal>resolve</goal>
                </goals>
                <configuration>
                  <outputPath>${project.basedir}/target/openapi-generated/v${api.version.new}/</outputPath>
                  <outputFileName>${cc.openapi.products.new}</outputFileName>
<!------------------------ this one is completely ignored ?! ------------------------------------->
                  <resourceClasses>com.siemens.spice.cc.rest.service.products.ProductsController</resourceClasses>
                </configuration>
              </execution>
              <execution>
                <id>generate-api-cc-configuration-brain</id>
                <goals>
                  <goal>resolve</goal>
                </goals>
                <configuration>
                  <outputPath>${project.basedir}/target/openapi-generated/v${api.version.new}/</outputPath>
                  <outputFileName>${cc.openapi.brain.new}</outputFileName>
<!------------------------ this one is completely ignored ?! ------------------------------------->
                  <resourceClasses>com.siemens.spice.cc.rest.api.BrainControllerApi</resourceClasses>
                </configuration>
              </execution>
              <execution>
                <id>generate-api-cc-configuration-creation-cache</id>
                <goals>
                  <goal>resolve</goal>
                </goals>
                <configuration>
                  <outputPath>${project.basedir}/target/openapi-generated/v${api.version.new}/</outputPath>
                  <outputFileName>${cc.openapi.creation-cache.new}</outputFileName>
<!------------------------ this one is completely ignored ?! ------------------------------------->
                  <resourceClasses>com.siemens.spice.cc.rest.service.cache.CreationCacheController</resourceClasses>
                </configuration>
              </execution>
              <execution>
                <id>generate-api-cc-configuration-vt</id>
                <goals>
                  <goal>resolve</goal>
                </goals>
                <configuration>
                  <outputPath>${project.basedir}/target/openapi-generated/v${api.version.new}/</outputPath>
                  <outputFileName>${cc.openapi.vt.new}</outputFileName>
<!------------------------ this one is completely ignored ?! ------------------------------------->
                  <resourceClasses>com.siemens.spice.cc.rest.service.vt.VariantTableController</resourceClasses>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
[INFO] --- swagger:2.2.21:resolve (generate-api-cc-configuration) @ rest-service ---
[INFO] Resolving OpenAPI specification..
[INFO] JSON output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-configuration.json
[INFO] YAML output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-configuration.yaml
[INFO]
[INFO] --- swagger:2.2.21:resolve (generate-api-cc-configuration-history) @ rest-service ---
[INFO] Resolving OpenAPI specification..
[INFO] JSON output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-history.json
[INFO] YAML output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-history.yaml
[INFO]
[INFO] --- swagger:2.2.21:resolve (generate-api-cc-configuration-history-analytics) @ rest-service ---
[INFO] Resolving OpenAPI specification..
[INFO] JSON output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-history-analytics.json
[INFO] YAML output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-history-analytics.yaml
[INFO]
[INFO] --- swagger:2.2.21:resolve (generate-api-cc-configuration-products) @ rest-service ---
[INFO] Resolving OpenAPI specification..
[INFO] JSON output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-products.json
[INFO] YAML output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-products.yaml
[INFO]
[INFO] --- swagger:2.2.21:resolve (generate-api-cc-configuration-brain) @ rest-service ---
[INFO] Resolving OpenAPI specification..
[INFO] JSON output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-brain.json
[INFO] YAML output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-brain.yaml
[INFO]
[INFO] --- swagger:2.2.21:resolve (generate-api-cc-configuration-creation-cache) @ rest-service ---
[INFO] Resolving OpenAPI specification..
[INFO] JSON output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-creation-cache.json
[INFO] YAML output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-creation-cache.yaml
[INFO]
[INFO] --- swagger:2.2.21:resolve (generate-api-cc-configuration-vt) @ rest-service ---
[INFO] Resolving OpenAPI specification..
[INFO] JSON output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-vt.json
[INFO] YAML output: D:\Dev\git\coc\spice-configuration-cluster\rest-service\target\openapi-generated\v1.20\cc-1.20-vt.yaml

May there is a wrong data-handling in the plugin, i,e static variable or something?!

I found the "problem" :) It has nothing todo with the maven plugin itself and how it read/merge the config. This is all fine. Its all about the "context-id" :-) (Singletons are ugly)

This line in io.swagger.v3.oas.integration.GenericOpenApiContextBuilder is causing the trouble:

OpenApiContext ctx = OpenApiContextLocator.getInstance().getOpenApiContext(ctxId);

If no context-id is given then the maven plugin is using ${project.artifactId} as default. So also in case multiple executions with different settings are expected which results at end in using the same open-api-context again and again.

So its not really a bug or something ... its more a missing hint in the documentation.