kbuntrock / openapi-maven-plugin

Generate openapi documentation for SpringMVC or JaxRS/JakartaRS projects.
https://kbuntrock.github.io/openapi-maven-plugin/
MIT License
13 stars 8 forks source link

Error when running plugin #89

Closed magx2 closed 6 months ago

magx2 commented 7 months ago

Hey,

I took you plugin configuration from quick start and run the mvn compile phase. Sadly I'm getting and error: Cannot invoke "java.lang.Class.isAssignableFrom(java.lang.Class)" because "superClass" is null

Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Class.isAssignableFrom(java.lang.Class)" because "superClass" is null
    at io.github.kbuntrock.model.DataObject.getContextualType (DataObject.java:346)
    at io.github.kbuntrock.TagLibrary.inspectObject (TagLibrary.java:113)
    at io.github.kbuntrock.TagLibrary.exploreDataObject (TagLibrary.java:77)
    at io.github.kbuntrock.TagLibrary.exploreDataObject (TagLibrary.java:84)
    at io.github.kbuntrock.TagLibrary.inspectObject (TagLibrary.java:114)
    at io.github.kbuntrock.TagLibrary.exploreDataObject (TagLibrary.java:77)
    at io.github.kbuntrock.TagLibrary.exploreDataObject (TagLibrary.java:84)
    at io.github.kbuntrock.TagLibrary.exploreTagObjects (TagLibrary.java:60)
    at io.github.kbuntrock.TagLibrary.addTag (TagLibrary.java:39)

Class that has implementation for endpoint:

@Slf4j
@RestController
@RequiredArgsConstructor
public class Foo implements Boo {

  @Override
  public ResponseEntity<Collection<AppInfo>> getDeployedApplications(ILoginName loginName) {
    // ...
  }

}

Interface:

@RequestMapping(API_PREFIX)
public interface Boo {

  String API_PREFIX = "/api";

  // @RequestBody ILoginName loginName
  @PreAuthorize("isAuthenticated()")
  @PostMapping(path = "/available-applications")
  ResponseEntity<Collection<AppInfo>> getDeployedApplications(
      @RequestBody ILoginName loginName);

}
kbuntrock commented 7 months ago

Hello @magx2 , than you for your bug report.

I was not able to reproduce the bug with the given informations. Could you create a minimal project containing the error + host it on github to help me fix your problem?

I would also like to know which version of java is executing maven (available with "mvn --version").

Kind regards, Kevin

magx2 commented 7 months ago

I'm using Java 17 + Maven 3.9.4

kbuntrock commented 6 months ago

Nothing suspicious about theses versions. To guide you, I suspect the bug is related to the structure of the "AppInfo" or "ILoginName" classes. Maybe you can give me more informations about them before creating a minimal project?

Kind regards, Kevin

magx2 commented 6 months ago

I've took it from your quick start:

   <plugin>
    <groupId>io.github.kbuntrock</groupId>
    <artifactId>openapi-maven-plugin</artifactId>
    <version>0.0.15</version>
    <executions>
     <execution>
      <id>documentation</id>
      <goals>
       <goal>documentation</goal>
      </goals>
     </execution>
    </executions>
    <configuration>
     <verbose>true</verbose>
     <!-- This section defines the general configuration, which can be overriden for each generated document. -->
     <apiConfiguration>
      <library>SPRING_MVC</library> <!-- Default value, here this tag could be deleted. -->
      <tagAnnotations> <!-- Only useful if you use Spring MVC -->
       <!-- RestController is the default value, but can be replaced by RequestMapping -->
       <annotation>RestController</annotation>
      </tagAnnotations>
     </apiConfiguration>
     <!-- This section defines which folders contains the source code to be read to extract the javadoc. -->
     <javadocConfiguration>
      <scanLocations>
       <!-- Other 'location' tag can be added to reference javadoc in other modules. -->
       <!-- Path is relative to the project root path. -->
       <location>src/main/java</location>
      </scanLocations>
     </javadocConfiguration>
     <!-- This section defines a list of documentations to generate. In this exemple, only one is generated. -->
     <apis>
      <api>
       <locations>
        <!-- Replace here by a package relevant for your project. -->
        <location>my.package</location>
       </locations>
      </api>
     </apis>
    </configuration>
   </plugin>
   <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <!-- Potentially adapt to stay on the version already used by your project -->
    <version>3.10.1</version>
    <configuration>
     <compilerArgs>
      <arg>-parameters</arg>
     </compilerArgs>
    </configuration>
   </plugin>
   <plugin>
kbuntrock commented 6 months ago

Yes, le configuration looks normal. I meant informations about those two classes used as input and output in your webservice :

magx2 commented 6 months ago
public interface AppInfo {

  IApplicationName getApplicationName();

  Collection<FleetNameIdentifiers> getAvailableFleets();
}
public interface ILoginName extends IName {
}
public interface IName {
    String getValue();
}
kbuntrock commented 6 months ago

Hello @magx2.

It was still not enough information to enable me to reproduce your bug over the weekend. I'll need a sample project with the bug to help my investigation.

Wish you a nice day.

Kind regards, Kevin

magx2 commented 6 months ago

Let me try to build something tommorow

pon., 23 paź 2023, 18:29 użytkownik Kévin Buntrock @.***> napisał:

Hello @magx2 https://github.com/magx2.

It was still not enough information to enable me to reproduce your bug over the weekend. I'll need a sample project with the bug to help my investigation.

Wish you a nice day.

Kind regards, Kevin

— Reply to this email directly, view it on GitHub https://github.com/kbuntrock/openapi-maven-plugin/issues/89#issuecomment-1775571407, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWTLHS7KFO4EJBGZ6RHF63YA2LMZAVCNFSM6AAAAAA6G74AMOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZVGU3TCNBQG4 . You are receiving this because you were mentioned.Message ID: @.***>

magx2 commented 6 months ago

Got it! The problem is with generics (extending and more generics...).

PS. Do not think to much about the model. It does not make sense (in this project). In my project it makes more sense 😁

https://github.com/magx2/openapi-maven-plugin-error

kbuntrock commented 6 months ago

Perfect, I confirm you that I can reproduce the bug now. :)

Starting to think how to handle properly this problem, I keep you updated.

kbuntrock commented 6 months ago

Fixed, TU is done, and I tested the new version on your demo project.

I will make a new release in the following days as I want to integrate some small evolutions into v0.0.16.

magx2 commented 6 months ago

Ok. Waiting for new version. Please do not wait too long cause I needto use it in my company project 😁

śr., 25 paź 2023, 22:54 użytkownik Kévin Buntrock @.***> napisał:

Closed #89 https://github.com/kbuntrock/openapi-maven-plugin/issues/89 as completed.

— Reply to this email directly, view it on GitHub https://github.com/kbuntrock/openapi-maven-plugin/issues/89#event-10772264654, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWTLHULHBA2MGLLZ5NH4J3YBF4BLAVCNFSM6AAAAAA6G74AMOVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQG43TEMRWGQ3DKNA . You are receiving this because you were mentioned.Message ID: @.*** com>

kbuntrock commented 6 months ago

Ok. Waiting for new version. Please do not wait too long cause I needto use it in my company project 😁 śr., 25 paź 2023, 22:54 użytkownik Kévin Buntrock @.> napisał: Closed #89 <#89> as completed. — Reply to this email directly, view it on GitHub <#89 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWTLHULHBA2MGLLZ5NH4J3YBF4BLAVCNFSM6AAAAAA6G74AMOVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQG43TEMRWGQ3DKNA . You are receiving this because you were mentioned.Message ID: @. com>

Pinky swear! ;) if tomorrow evening I see that I take more than an evening to code what I'm planning to add : I'll ship the version as it is.

kbuntrock commented 6 months ago

@magx2 : Version 0.0.16 is alive and available in Maven Central. :)

magx2 commented 6 months ago

Works 🎉. Thanks!