我正在研究Spring Boot v2.2.6.RELEASE和Open API集成示例。该示例可以使用20个不同的参数进行搜索。因此,此POJO类拥有CustomSearchDto
这20个不同的值。
在POJO中,我使用了orgName,但是@parameter(in = ParameterIn.QUERY, name = "orgizationName",
和某种程度上我想覆盖变量名。我必须那样做。有什么办法吗?
@Parameter(in = ParameterIn.QUERY, name = "orgizationName", schema = @Schema(type = "string"))
@Parameter(in = ParameterIn.QUERY, name = "employeeId", schema = @Schema(type = "string"))
@Parameter(in = ParameterIn.QUERY, name = "emailId", schema = @Schema(type = "string"))
@Parameter(in=ParameterIn.QUERY, name="page", description="Results page you want to retrieve (0..N)", schema=@Schema(defaultValue = "0"))
@Parameter(in=ParameterIn.QUERY, name="size", description="Number of records per page.", schema=@Schema(defaultValue = "30"))
@GetMapping(value = "/employees/organizations")
public ResponseEntity<PagedModel<Employees>> search(CustomSearchDto requestparams,
@Parameter(hidden=true) Pageable pageRequest) {
......
........
return new ResponseEntity<>(model, HttpStatus.OK);
}
这是我自定义的DTO类
public class CustomSearchDto {
@Schema(description = "", type = "string", example = " ")
private String orgName;
@Schema(description = "", type = "string", example = " ")
private String empId;
@Schema(description = "", type = "integer", example = "null")
private Integer email;
.........
..............
.............
}
答案 0 :(得分:0)
您可以直接将对象CustomSearchDto传递给带有注释@ParameterObject
的对象。
以下是文档的链接: