swagger-core
swagger-core copied to clipboard
GenericOpenApiScanner not working as expected - swagger maven plugin
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:-
- 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.
- 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