When trying to incorporate swagger into my API I'm running into some issues.
My API is using Jersey 2.22 and the language is Scala. I've added the following dependencies to my pom:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.12</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-scala-module_2.11</artifactId>
<version>1.0.3</version>
</dependency>
My plugin is configured as follows:
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${kongchen.plugin.version}</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<apiSources>
<apiSource>
<locations>${swagger.locations}</locations>
<springmvc>false</springmvc>
<host>${swagger.host}</host>
<basePath>${base.path}</basePath>
<info>
<title>${swagger.title}</title>
<version>${project.version}</version>
<description>${swagger.description}</description>
</info>
<swaggerDirectory>${project.build.directory}/</swaggerDirectory>
<outputFormats>yaml,json</outputFormats>
</apiSource>
</apiSources>
</configuration>
</plugin>
When I'm running mvn compile, the following error occurs:
Exception in thread "main" java.util.ServiceConfigurationError: io.swagger.converter.ModelConverter: Provider io.swagger.scala.converter.SwaggerScalaModelConverter could not be instantiated
at java.util.ServiceLoader.fail(ServiceLoader.java:232)
at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at io.swagger.converter.ModelConverters.<clinit>(ModelConverters.java:114)
at com.github.kongchen.swagger.docgen.AbstractDocumentSource.loadModelModifier(AbstractDocumentSource.java:179)
at com.github.kongchen.swagger.docgen.mavenplugin.ApiDocumentMojo.execute(ApiDocumentMojo.java:71)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.VerifyError: Cannot inherit from final class
If I leave out the scala-swagger module, compile works fine and I'm getting a valid json (all resource descriptions are generated perfectly), but the fields in the scala case classes don't get generated:
@ApiModel("some model")
case class HelloModel(@(ApiModelProperty @field)(dataType = "Int", value = "some int", name = "tries") tries: Int)
Results in:
"definitions" : {
"some model" : {
"type" : "object"
}
}
Anyone got a clue?