Я хочу использовать плагин swagger и maven для создания документации в json-from из моего restful приложения. Файл json создан, но отсутствуют данные из API со всеми описаниями моего кода.
Это мой pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.baintern.infoplattform</groupId>
<artifactId>infoplattform</artifactId>
<version>1.0</version>
</parent>
<artifactId>infoplattform-services</artifactId>
<name>infoplattform-services</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId> 3.2
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.22</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.7</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.3-M1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.3.0-alpha4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.3.0-alpha4</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.7</version>
<configuration>
<apiSources>
<apiSource>
<locations>
<location>services.myServices</location>
</locations>
<schemes>
<scheme>http</scheme>
<scheme>https</scheme>
</schemes>
<host>localhost:7001</host>
<basePath>/info-services</basePath>
<info>
<title>Swagger documentation</title>
<version>v1</version>
<description>swagger documentation</description>
<termsOfService>
http://localhost:7001/info-services/
</termsOfService>
<contact>
<email>info.email@domaine.de</email>
<name>Info-Box</name>
<url>https:mydomain.de/</url>
</contact>
<license>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<name>Apache 2.0</name>
</license>
</info>
<swaggerDirectory>generated/swagger-ui</swaggerDirectory>
<swaggerFileName>info-services</swaggerFileName>
<outputFormats>json</outputFormats>
<attachSwaggerArtifact>true</attachSwaggerArtifact>
<swaggerUIDocBasePath>http://localhost:7001/info-services/doc</swaggerUIDocBasePath>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Это мой код Java:
@Path("/themen")
@Api(value = "/themen", description = "Service-Methoden von Thema")
public class ThemaServices extends EjBFactoryAndUtils {
@GET
@Path("/findAllThemen")
@Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Liefert alle Themen", notes = "Liest alle Themen aus der Datenbank ein nach bestimmten Parametern. Die Liste wird mit Parametern eingelesen.Alle diese Parameter sind optional.", produces = MediaType.APPLICATION_JSON, httpMethod = "GET", responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Not Found.", response = List.class) })
public Response findAllThemen(
@ApiParam(value = "Bestimmt ob die zugeordnete Elemente,wie Dokumente oder Themengruppen angezeigt werden.", required = false, name = "skipZuordnungen") @DefaultValue("true") @QueryParam("skipZuordnungen") Boolean skipZuordnungen,
@ApiParam(value = "Startposition der einzulesenden Daten", required = false, name = "startPosition") @QueryParam("startPosition") Integer startPosition,
@ApiParam(value = "Maximale Anzahl der einzulesenden Daten", required = false, name = "maxResult") @QueryParam("maxResult") Integer maxResult) {
.......
}
и сгенерированный файл json выглядит так:
"/themen/findAllThemen" : {
"get" : {
"operationId" : "findAllThemen",
"produces" : [ "application/json" ],
"parameters" : [ {
"name" : "skipZuordnungen",
"in" : "query",
"required" : false,
"type" : "boolean",
"default" : true
}, {
"name" : "startPosition",
"in" : "query",
"required" : false,
"type" : "integer",
"format" : "int32"
}, {
"name" : "maxResult",
"in" : "query",
"required" : false,
"type" : "integer",
"format" : "int32"
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
В этом файле Json отсутствует информация из @ApiOperation, @ApiResponses и @ApiParam. Плагин не анализирует содержимое Apag по неизвестной причине.
Может кто-нибудь помочь мне правильно сгенерировать этот файл с отсутствующим содержимым?