SpringBoot入門到精通-通過Token獲取當前用戶,但是Swagger當成參數處理,如何隱藏

添加@LoginUser

 

Swagger-ui顯示如下

特別的醜,不能忍

百度一下,馬上有了

需要在swagger配置的時候添加忽略類即可

show my code 如下

@Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //加了ApiOperation註解的類,才生成接口文檔
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build()
                .securitySchemes(security())
                .ignoredParameterTypes(LoginUser.class);
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章