【发布时间】:2017-09-05 11:40:57
【问题描述】:
我正在使用 swagger 来记录我的 REST 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>
【问题讨论】: