我在apache cxf項目中使用了swagger,使用了@Api和@ApiOperations和@ApiParam註釋,併爲其餘服務生成了api文檔。從swagger響應中排除模型或屬性
但我想從模型屬性或完整的模塊或屬性屬性中排除一些像EntityTag,StatusType和MediaType等字段。
如何做到這一點?
我從數據庫中獲取數據並將其設置爲用戶對象並將該用戶對象傳遞給JAX-RS響應構建器。
下面是我的DTO對象之一:
@ApiModel
public class User{
private String name;
private String email;
@ApiModelProperty(position = 1, required = true, notes = "used to display user name")
public int getName() {
return name;
}
public void setName(String name) {
this.name= name;
}
@ApiModelProperty(position = 2, required = true, notes = "used to display user email")
public int getEmail() {
return email;
}
public void setEmail(String email) {
this.email= email;
}
現在我看不到裏面揚鞭用戶對象字段或屬性返回的JSON格式。
我的服務類方法迴應是:
所有的@GET
@ApiOperation(value = "xxx", httpMethod = "GET", notes = "user details", response = Response.class)
public Response getUserInfo(){
User userdto = userdaoimpl.getUserDetails();
ResponseBuilder builder = Response.ok(user, Status.OK), MediaType.APPLICATION_JSON);
builder.build();
}
<bean id="swaggerConfig" class="com.wordnik.swagger.jaxrs.config.BeanConfig">
<property name="resourcePackage" value="com.services.impl" />
<property name="version" value="1.0.0" />
<property name="basePath" value="http://localhost:8080/api" />
<property name="license" value="Apache 2.0 License" />
<property name="licenseUrl"
value="http://www.apache.org/licenses/LICENSE-2.0.html" />
<property name="scan" value="true" />
</bean>
你使用哪個版本的swagger-core? – Ron