knife4j官方文档:https://doc.xiaominfo.com/docs/quick-start/start-knife4j-version
增强模式文档:https://doc.xiaominfo.com/docs/features/enhance
1.用法
(1)控制层 @Tag(name = “用户信息管理”)
@Tag(name = "用户信息管理")
@RestController
@RequestMapping("/test/user")
public class TestController {
}
(2)方法 @Operation(summary = “获取用户列表”),@Parameter(name = “userId”)
@Operation(summary = "获取用户列表")
@GetMapping("/list")
public R<List<UserEntity>> userList() {List<UserEntity> userList = new ArrayList<UserEntity>(users.values());return R.ok(userList);
}@Operation(summary = "获取用户详细")
@Parameter(name = "userId", description = "用户ID", required = true)
@GetMapping("/{userId}")
public R<UserEntity> getUser(@PathVariable Integer userId) {if (!users.isEmpty() && users.containsKey(userId)) {return R.ok(users.get(userId));} else {return R.fail("用户不存在");}
}
(3)实体
@Tag(name = "UserEntity", description = "用户实体")
class UserEntity {@Schema(name = "用户ID")private Integer userId;
}