762 Star 6.6K Fork 1.4K

GVP萧明 / knife4j

 / 详情

OAuth2模式问题

待办的
创建于  
2023-04-11 16:03

版本信息

提供Knife4j、Spring Boot、Springfox、Springdoc-openapi等相关版本号信息

            <dependency>
                <groupId>com.github.xiaoymin</groupId>
                <artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
                <version>4.1.0</version>
            </dependency>

阅读issue:#IZUCU:Knife4j 提ISSUES必看

...

重现步骤

提供所有作者能复现此问题的步骤,包括不局限:代码、贴图、错误日志、相关中间件版本等等

    @Bean
    public OpenAPI openApi() {
        HashMap<String, SecurityScheme> map = new HashMap<>();
        map.put("clientCredentials",
                new SecurityScheme().type(SecurityScheme.Type.OAUTH2)
                        .flows(new OAuthFlows().clientCredentials(
                                new OAuthFlow().tokenUrl("http://localhost:10001/oauth2/token")
                                        .scopes(new Scopes().addString("font", "font"))
                        )));
        map.put("password", new SecurityScheme().type(SecurityScheme.Type.OAUTH2)
                .flows(new OAuthFlows().password(
                        new OAuthFlow().tokenUrl("http://localhost:10001/oauth2/token")
                                .scopes(new Scopes().addString("sys", "sys"))
                )));
        return new OpenAPI().info(new Info()
                        .title(TITLE).description(DESCRIPTION)
                        .termsOfService(SITE).contact(new Contact().name(DEVELOPER).url(SITE).email(EMAIL))
                        .version("1.0.0"))
                .components(new Components().securitySchemes(map))
                .addSecurityItem(new SecurityRequirement().addList("clientCredentials").addList("password"));
    }

...
Swagger文档效果
Swagger文档效果

Knife4j文档效果
Knife4j文档效果
配置信息已返回

出现问题:
1:未展示Scopes选项
2:未展示多模式

...

评论 (1)

Leek 创建了任务
Leek 修改了描述
展开全部操作日志

我也遇到这个问题,有没有解决?

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
5262487 wwj gitee 1581478542
Java
1
https://gitee.com/xiaoym/knife4j.git
git@gitee.com:xiaoym/knife4j.git
xiaoym
knife4j
knife4j

搜索帮助