swagger-maven-plugin
swagger-maven-plugin copied to clipboard
Cannot invoke "java.util.Map.size()" because "map" is null
wildfly 27. Using swagger maven plugin, with JDK 21, and getting the above error.
<configuration>
<resourcePackages>
<resourcePackage>com.hsntech.bannerjwt.rest</resourcePackage>
</resourcePackages>
<outputDirectory>${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}</outputDirectory>
<outputFilename>openapi</outputFilename>
<outputFormats>
<outputFormat>JSON</outputFormat>
<outputFormat>YAML</outputFormat>
</outputFormats>
<prettyPrint>true</prettyPrint>
<swaggerConfig>
<servers>
<server>
<url>/SecurityService/rest</url>
<description>Endpoint URL for Banner Security Service API's</description>
</server>
</servers>
<info>
<title>Security Service - OpenAPI</title>
<version>1.0.0</version>
<description>REST API Framework designed to allow third party vendors the ability to
access Banner client data without having to go through the Banner UI Framework.</description>
</info>
</swaggerConfig>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- Download Swagger UI webjar. -->
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>${swagger-ui.version}</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/swagger-ui</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- Add Swagger UI resources to the war file. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<webResources combine.children="append">
<resource>
<directory>${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}</directory>
<includes>
<include>**/*.*</include>
</includes>
<targetPath>swagger-ui</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<!-- Replace the OpenAPI specification example URL with the local one. -->
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>${replacer.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}/index.html</file>
<replacements>
<replacement>
<token>http://petstore.swagger.io/v2/swagger.json</token>
<!-- value>/api/openapi.json</value -->
<!-- value>'http://localhost:8080/SecurityService/openapi.json'</value -->
<value>openapi.yaml</value>
</replacement>
</replacements>
</configuration>
</plugin>
</plugins>
</build>
Same issue here
Same here
Ah got it, used already jakarta but this plugin searches for javax :/
@ataraxus seems to be quite annoying, anybody knows about someone fixing this ?
@ataraxus so this library can't be used to generate for jakarta apis.Did you got any other plugin to generate open api spec
I wrote a custom plugin. My API Definitions are in a separate Module and my plugin, stubs them all during compiletime and generates the openApi spec using this plugin.
I do not know if this is the exact issue we ran into, but it sounds so similar that maybe this info helps.
We saw this exact same error and the reason seems to be that when there are no classes with @Path
annotations in the package defined in <resourcePackage>
of the plugin.
At first I thought the workaround was adding more <resoucePackage>
to the plugins config, but we just needed to add the following to the config:
<useResourcePackagesChildren>true</useResourcePackagesChildren>
I wrote a custom plugin. My API Definitions are in a separate Module and my plugin, stubs them all during compiletime and generates the openApi spec using this plugin.
Could you share that custom plugin that you wrote or atleast a working example. I am running into this issue now and it seems like the fix hasn't been merged yet by the mainainer.
I do not know if this is the exact issue we ran into, but it sounds so similar that maybe this info helps.
We saw this exact same error and the reason seems to be that when there are no classes with
@Path
annotations in the package defined in<resourcePackage>
of the plugin.At first I thought the workaround was adding more
<resoucePackage>
to the plugins config, but we just needed to add the following to the config:<useResourcePackagesChildren>true</useResourcePackagesChildren>
I tried this but it didn't work for me unfortunantly.
Same issue in JDK 17