企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
**1. 类的文档: `@Tag`** ```java @RestController @Tag(name = "账号接口") public class AccountController { ... } ``` ![](https://img.kancloud.cn/c3/ad/c3ad9cf3138d013c204698d7af0711ee_2160x255.png) <br/> **2. 方法的文档:`@Operation`** ```java @Operation(summary = "根据账号id查找账号") @GetMapping("/account/getById/{id}") public String getById(@PathVariable("id") Integer id) { return "" + id; } ``` ![](https://img.kancloud.cn/f2/0e/f20e303ee17f07a1a66fbdde758450e9_1782x96.png) <br/> **3. 参数的文档:`@Parameter`** ```java @Operation(summary = "根据账号id查找账号") @GetMapping("/account/getById/{id}") public String getById(@Parameter(description = "账号id", example = "1000") @PathVariable("id") Integer id) { return "" + id; } ``` ![](https://img.kancloud.cn/2f/f0/2ff0dd21698b6c36f1198facee5ac199_1795x482.png) <br/> **4. 参数的文档:`@Parameters`** ```java @Parameters( { @Parameter(name = "id", description = "账号id", example = "1000"), @Parameter(name = "username", description = "账号名", example = "zhangsan") } ) @Operation(summary = "根据账号id和账号名查找账号") @GetMapping("/account/getByIdAndUsername") public String getByIdAndUsername(@RequestParam("id") Integer id, @RequestParam("username") String username) { return id + "." + username; } ``` ![](https://img.kancloud.cn/50/ee/50eeab9eb12864e6ada88f974f2d74aa_1607x700.png) <br/> **5. 实体的文档:`@Schema`** ```java @Schema(description = "账号实体") public class Account { @Schema(description = "账号id", example = "1000") private Integer id; @Schema(description = "账号名", example = "zhangsan") private String username; @Schema(description = "密码", example = "123456") private String password; } ``` ![](https://img.kancloud.cn/ee/17/ee17e854d0532987d33e669776278096_1939x484.png) >[info]提醒:实体只有被 controller 层引用才能生成文档。 ```java /** * Account 被 controller 层用做参数,或返回值 */ @PostMapping("/account/getAcoount") public Account getAccount(@RequestBody Account account) { return account; } ```