如何在 spring 启动时从 swagger 中删除身份验证参数?

How can I delete Authentication parameter from swagger in spring boot?

我有一个 spring 引导项目,它同时使用 spring 安全性和 swagger UI。

主要问题是当我像这样在控制器方法的参数中使用身份验证时

    @PutMapping("/")
    public UserRestDTo update(Authentication auth, @RequestBody UserRestDTo user) {
        ...
    }

我在swagger-UI的请求参数中获取到Authentication对象是这样的 swagger result

最后:感谢help:D。

我找到了解决方案:

@PutMapping("/")
    public UserRestDTo update(@RequestBody UserRestDTo user) throws AbstractWebException {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        ...
    }

但我想知道旧方法 是否会对我的项目的安全性产生严重影响 或者它只是一个自大的错误。