我在apache cxf项目中使用了swagger,使用了@Api和@ApiOperations以及@ApiParam注释,并为其余服务生成了api doc.
但我想从Models属性或完整的模块或属性属性中排除一些字段,如EntityTag,StatusType和MediaType等.
怎么做?
我从db获取数据并将其设置为用户对象并将该用户对象传递给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;
}
Run Code Online (Sandbox Code Playgroud)
现在我没有看到Swagger中的User对象字段或属性返回了json格式.
我的服务类方法响应是:
@GET
@ApiOperation(value = "xxx", httpMethod …Run Code Online (Sandbox Code Playgroud) 我们实现了 2.6.1 版的 spring fox swagger 2,我想为 HTTP GET METHOD 而不是 POST METHOD 显示资源的特定属性,我还没有找到任何使用 swagger 2 的方法。请帮助谢谢。
例如:
Class Employee{
Integer id;
String name;
}
Run Code Online (Sandbox Code Playgroud)
请求 URI: GET /api/employee/{id} 我应该看到 swagger 请求文档为
{
id:"",
name:""
}
Run Code Online (Sandbox Code Playgroud)
请求 URI: POST /api/employee 我应该看到 swagger 请求示例为
{
name:""
}
Run Code Online (Sandbox Code Playgroud)