openapi-tools / swagger-maven-plugin

Maven plugin to activate the Swagger Core library to generate OpenAPI documentation.
MIT License
72 stars 46 forks source link

Generate failed: Cannot invoke "java.util.Map.size()" because "map" is null #109

Open dorus-private opened 1 year ago

dorus-private commented 1 year ago

Describe the bug After configured the plugin in my pom.xml, by invoking "mvn clean install" the build is falling with the following error:

[ERROR] Failed to execute goal io.openapitools.swagger:swagger-maven-plugin:2.1.5:generate (default) on project IBANValidator: Execution default of goal io.openapitools.swagger:swagger-maven-plugin:2.1.5:generate failed: Cannot invoke "java.util.Map.size()" because "map" is null

To Reproduce I am using java 17 and the following plugin configuration:

            <plugin>
                <groupId>io.openapitools.swagger</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <version>${swagger.maven.plugin}</version>
                <configuration>
                    <resourcePackages>
                        <resourcePackage>com.mypackage.restcontroller</resourcePackage>
                    </resourcePackages>
                    <outputDirectory>${basedir}/target/</outputDirectory>
                    <outputFilename>swagger.out</outputFilename>
                    <outputFormats>JSON,YAML</outputFormats>
                    <prettyPrint>true</prettyPrint>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

swagger.maven.plugin has value 2.1.5, the same is happening for version 2.1.6.

Expected behavior I expected to have 2 generated files.

Additional context

lehnert-andre commented 1 year ago

Hi, have the same problem after updating to Jakarta EE 10.

[ERROR] Failed to execute goal io.openapitools.swagger:swagger-maven-plugin:2.1.6:generate (default) on project <project-placeholder>: Execution default of goal io.openapitools.swagger:swagger-maven-plugin:2.1.6:generate failed: Cannot invoke "java.util.Map.size()" because "map" is null -> [Help 1]

I´m using the Wildfly BOM

<dependency>
  <groupId>org.wildfly.bom</groupId>
  <artifactId>wildfly-ee</artifactId>
  <version>27.0.1.Final</version>
  <type>pom</type>
  <scope>import</scope>
</dependency>

with JAX-RS

 <dependency>
  <groupId>jakarta.ws.rs</groupId>
  <artifactId>jakarta.ws.rs-api</artifactId>
  <scope>provided</scope>
</dependency>
ShubhamShekhar1996 commented 1 year ago

Is there any update on this issue?

htr3n commented 1 year ago

Got the same error with the plugin when using Jakarta. It seems the plugin is built or linked against Java EE as I ran the specific plugin goal as following

mvn io.openapitools.swagger:swagger-maven-plugin:generate

got this exception

[ERROR] Failed to execute goal io.openapitools.swagger:swagger-maven-plugin:2.1.5:generate (default-cli) on project swagger-jakarta: Execution default-cli of goal io.openapitools.swagger:swagger-maven-plugin:2.1.5:generate failed: A required class was missing while executing io.openapitools.swagger:swagger-maven-plugin:2.1.5:generate: javax/servlet/ServletConfig

Updated: I looked into the POM, it seems to use Java EE JAX-RS instead of Jakarta EE JAX-RS.

nobody102 commented 1 year ago

Any update on this?

salake commented 1 year ago

I'm getting the same error

sofyenne commented 5 months ago

I have resolved this issue by replacing the true and the by the path to your rest class