bartekbudz
6 years agoNew Member
debugging swagger gradle plugin is a nightmare
Anoyne can provide any hints on how to debug issues with the gradle plugin for swagger?
I want to generate OpenAPI documentation based on java code.
When running resolve task I constantly get gradle exception... with no message.
> Task :module-name:resolve FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':module-name:resolve'. > org.gradle.api.GradleException (no error message)
Here is my gradle build config:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "io.swagger.core.v3:swagger-gradle-plugin:2.0.8"
}
}
apply plugin: "io.swagger.core.v3.swagger-gradle-plugin"
apply plugin: 'java'
...
resolve {
outputFileName = 'ModuleNameAPI'
outputFormat = 'YAML'
prettyPrint = 'TRUE'
classpath = sourceSets.main.runtimeClasspath
resourcePackages = ['com.company.moduleName.services']
outputPath = docsDir
}
Here is an example rest service code:
import javax.validation.constraints.NotNull;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.info.Info;
import org.springframework.beans.factory.annotation.Required;
@Path("serviceName/v1.1")
@OpenAPIDefinition(
info = @Info( title = "ServiceNameRS", version = "1.1" )
)
public class ServiceNameRS{
...
@GET
@Path("/someOperation")
@Produces({"application/json", "application/xml"})
@Operation
public ServiceResponse someOperationImpl(@QueryParam("parameterName") boolean parameterName) {
...
}