openapi-tools / swagger-maven-plugin

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

a required class is missing during build #28

Closed wwang2016 closed 3 years ago

wwang2016 commented 5 years ago

Hi,

I got the following error while trying to build the project and generate the api document. The api document was not generated.

Execution default of goal io.openapitools.swagger:swagger-maven-plugin:2.0.3:generate failed: A required class was missing while executing io.openapitools.swagger:swagger-maven-plugin:2.0.3:generate: org/apache/deltaspike/data/api/EntityRepository

However, the class file EntityRepository exists

Do you see any reason?

Thanks,

Wayne

langecode commented 5 years ago

Can you run this with -X to get the entire stacktrace? I am a bit uncertain where in the process you get the exception. It might be a variation of #25

wwang2016 commented 5 years ago

Hi,

The following is the error:

[ERROR] Failed to execute goal io.openapitools.swagger:swagger-maven-plugin:2.0.3:generate (default) on project: Execution default of goal io.openapitools.swagger:swagger-maven-plugin:2.0.3:generate failed: A required class was missing while executing io.openapitools.swagger:swagger-maven-plugin:2.0.3:generate: org/apache/deltaspike/data/api/EntityRepository [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>io.openapitools.swagger:swagger-maven-plugin:2.0.3 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/C:/Users/wayne.wang/.m2/repository/io/openapitools/swagger/swagger-maven-plugin/2.0.3/swagger-maven-plugin-2.0.3.jar

Thanks,

Wayne

langecode commented 5 years ago

Can you test whether release 2.1.0 solves your problem. My guess is that #25 will solve this issue also.

wwang2016 commented 5 years ago

Hi, This time, it ran to completion and generated source codes. The following are some issues that requireds attention

(1) The generated api definition file does not conform to OpenAPI v3 for supporting inheritance. For example, the allOf should include all elements, and not just the reference to parent class. This issue is the same as the one from another project. It would be a plus if it can be corrected g : io.swagger.core.v3 a : swagger-maven-plugin

TextMessage:
  type: object
  properties:
    text:
      type: string
  allOf:
  - $ref: '#/components/schemas/Message'

should be:

TextMessage:
  allOf:
  - $ref: '#/components/schemas/Message'
  - type: object
    properties:
      text:
        type: string

(2) It would be better to have a configuration parameter to specify the resource class(es) so that I do not need to generate api document for all classes in the same package (resourcePackage). Note, the other solution support the sourceClasses parameter

I will continue investigate if there is any other issue

Thx!

FunkyFlapjacks commented 4 years ago

Hey, could you backport this (or, well, the fix to #25) to version 1.X? Getting the same error with 1.0.3 but working fine with 2.1.0+