答案 0 :(得分:1)
要在Swagger API中隐藏请求字段,只需使用以下注释:)
@ApiModelProperty(hidden = true)
private String id;
这将是蜂巢
答案 1 :(得分:0)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@ApiModelProperty(readOnly = true)
private String id;
答案 2 :(得分:0)
您可以将@Hidden与Swagger Core 2.X一起使用
@Hidden-隐藏资源,操作或属性
上面链接的示例:将给定的资源,类或bean类型标记为隐藏,在读取/解析时跳过。
@Path("/user")
@Produces({"application/json", "application/xml"})
public class HiddenAnnotatedUserResourceMethodAndData {
UserData userData = new UserData();
@POST
@Hidden
@Operation(summary = "Create user",
description = "This can only be done by the logged in user.")
@Path("/1")
public Response createUser(
@Parameter(description = "Created user object", required = true) User user) {
userData.addUser(user);
return Response.ok().entity("").build();
}
@POST
@Operation(summary = "Create user",
description = "This can only be done by the logged in user.")
@Path("/2")
public Response createUserWithHiddenBeanProperty(
@Parameter(description = "Created user object", required = true) UserResourceBean user) {
return Response.ok().entity("").build();
}
}
以上输出
openapi: 3.0.1
paths:
/user/2:
post:
summary: Create user
description: This can only be done by the logged in user.
operationId: createUserWithHiddenBeanProperty
requestBody:
description: Created user object
content:
'*/*':
schema:
$ref: '#/components/schemas/UserResourceBean'
required: true
responses:
default:
description: default response
components:
schemas:
UserResourceBean:
type: object
properties:
foo:
type: string