@ApiImplicitParam注解使用说明
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api")
public class UserController {
@ApiOperation("获取用户信息")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "用户ID", dataType = "Long", paramType = "path", example = "1")
})
@GetMapping("/users/{id}")
public User getUser(@PathVariable Long id) {
// 根据用户ID查询用户信息
// ...
}
@ApiOperation("创建用户")
@ApiImplicitParams({
@ApiImplicitParam(name = "username", value = "用户名", dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "password", value = "密码", dataType = "String", paramType = "query")
})
@GetMapping("/users")
public User createUser(String username, String password) {
// 创建用户
// ...
}
}