Open aortiztala opened 2 years ago
Thanks for reporting this. While this should certainly not happen it seems to be a result of no endpoints being discovered. Do you have any JAX-RS annotated resources in com.example.my.service.common
or com.example.my.service.controller
?
I'll make sure we do a NPE for this. The 2.1.3 introduced sorting of the resource paths (and other things) to ensure a deterministic output from running the generation and this indeed seems to be an issue from the sorting when no resource paths has been discovered.
No, I don't have any JAX-RS annotated resources. I thought maybe this plugin would work with @Api* annotated classes, now I know it doesn't.
It is intended to work with JAX-RS annotations - the same as Swagger basically. But shouldn't be throwing around NPE's anyway :)
Before hitting #96 I was running into this issue, but I cannot really tell at what point unfortunately. This definitely is affecting a couple of folks.
Edit: Could reproduce by just using it:
<plugin>
<groupId>io.openapitools.swagger</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>2.1.4</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
I'm using JAX-RS.
It looks like resourcePackage
is not recursive?
That may be a common misconception and then nothing gets picked up, resulting in the NPE.
I find it irritating that there is not activity on this project?
I would glady prefer this plugin over smallrye-open-api
plugin since this plugin picks up the Swagger Annotations.
(I am yet to compare the YAML output to see which works better - especially for generating client code).
As for the NPE, my fix was to actually configure resourcePackage
explicitly to the packages containing class files with annotations (assuming that resourcePackage
does not recurse).
Caused by: java.lang.NullPointerException
at java.util.TreeMap.putAll (TreeMap.java:312)
at java.util.TreeMap.<init> (TreeMap.java:185)
at io.openapitools.swagger.OpenAPISorter.sortPaths (OpenAPISorter.java:50)
at io.openapitools.swagger.OpenAPISorter.sort (OpenAPISorter.java:41)
at io.openapitools.swagger.GenerateMojo.execute (GenerateMojo.java:127)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:515)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
at java.lang.Thread.run (Thread.java:829)
With 2.1.2 version, the result is only this:
openapi: 3.0.1
info:
title: My Title
description: My Descrition
version: 1.0.0
With 2.1.3 up to 2.1.5, the result is Nullpointer
.
I had similar issue at java.util.Map.size(), switching to 2.1.2 resolved the issue. Now I have swagger.json generated as annotated in the @OpenAPIDefinition { "openapi" : "3.0.1", "info" : { "title" : "OpenAS2 ", "description" : "OpenAS2 OpenAPI Implementeation", "version" : "1.0.0" }, "servers" : [ { "url" : "http://localhost:8080/api", "description" : "Test server", "variables" : { } } ] }
Describe the bug I'm getting a NullPointerException at java.util.TreeMap.putAll (TreeMap:312) after adding the plugin to my project.
To Reproduce This is how I defined the plugin in my POM file:
Expected behavior I expected the project to build properly and generate the JSON and YAML files.
Additional context I'm experiencing this issue with versions from 2.1.3 to 2.1.6 (latest as of report date). It works with 2.1.2.