<dependency> <groupId>io.swagger.core.v3</groupId> <artifactId>swagger-annotations</artifactId> <version>2.1.3</version> </dependency> @Api(tags = "User API") public class UserController { @ApiOperation(value = "Get user by ID", notes = "Requires the user ID as input") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of user details"), @ApiResponse(code = 404, message = "User not found") }) @GetMapping("/user/{id}") public ResponseEntity<User> getUserById(@PathVariable("id") Long id) { // Your code here } // Other API methods } @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("com.example.api")) .build(); } // Other configuration methods }


上一篇:
下一篇:
切换中文