swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

GenericOpenApiScanner not working as expected - swagger maven plugin

Open fxviking opened this issue 3 years ago • 0 comments

Hello, I have a java application Jee not using any javax.rs annotation or Spring , I was using swagger maven plugin latest release to generate OpenAPI file. If i add javax annotations in the code on operation methods like @Path , @Get etc. then the generation happens. If i remove those annotations it does not generate any openapi specs even if the @Operation annotations are used in the java file.

So My question are:-

  1. Is my understanding of the GenericOpenApiScanner proper, i.e. it should generate specs for Open API annotations even if javax.* annotations are not used in the code.
  2. I tried using my own Scanner implementaation, but it gives Null pointer in execution, DO i need to also implement the Custom Reader also in that case?? For me the error It looks like the OpenAPI configurations were not getting loaded in this case.

Plugin configuration

<plugin>
          <groupId>io.swagger.core.v3</groupId>
          <artifactId>swagger-maven-plugin</artifactId>
            <version>2.2.2</version>
          <configuration>
             <resourceClasses>com.test.AbandonXXX</resourceClasses>
            <outputPath>${basedir}/target/</outputPath>
            <configurationFilePath>${project.basedir}/src/main/resources/openapi-configuration.yaml</configurationFilePath>
            <scannerClass>io.swagger.v3.oas.integration.GenericOpenApiScanner</scannerClass>
            <outputFormat>JSONANDYAML</outputFormat>
            <outputFileName>openapi</outputFileName>
            <readAllResources>true</readAllResources>
            <prettyPrint>true</prettyPrint>
          </configuration>
            <executions>
              <execution>
                <phase>compile</phase>
                <goals>
                  <goal>resolve</goal>
                </goals>
              </execution>
            </executions>

Java File

@Operation(operationId = "operationId",summary = "Abandon", description = "Abandon") @Override public void execute() {

openapi configuration yaml

openapi : 3.0.3
resourcePackages:
  - com.test
prettyPrint: true
cacheTTL: 0
openAPI:
  info:
    version: '1.0'
    title:  App Config File
    description: 'This is the API for  App Module'
    termsOfService: http://swagger.io/terms/
    contact:
      email: [email protected]
    license:
      name: Apache 2.0
      url: http://www.apache.org/licenses/LICENSE-2.0.html

fxviking avatar Sep 09 '22 07:09 fxviking