我正在使用swagger來記錄我的REST api。Swagger沒有生成api模型值
我不想自動生成文檔,所以我使用帶註釋的swagger-jaxrs。
@GET
@Path("/news/{id}")
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "News found", response = NewsEntry.class)})
NewsEntry是我的模型,它的設置好的起來如下:
@ApiModel("News Entry")
public class NewsEntry {
@ApiModelProperty(value = "the id of the item", required = true)
private static long id;
@ApiModelProperty(value = "content", required = true)
private static String content;
}
幾個測試後,我發現,如果沒有在NewsEntry getter/setter方法,它不崩潰,但是,它會產生一個空的模型...任何想法我做錯了什麼?
這是我的POM:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey-jaxrs</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.8 </version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<version>1.5.8 </version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<version>1.5.8 </version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.8 </version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>2.1.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.1.4.Final</version>
</dependency>