769 Star 6.6K Fork 1.4K

GVP萧明 / knife4j

 / 详情

SpringBoot3版本,knife4j文档请求异常

待办的
创建于  
2024-05-17 18:24

现象说明

本地启动通过ip+port能正常访问,线上访问失败(有nginx代理)
访问文档时报错:knife4j文档请求异常,通过查看接口请求,发现是/v3/api-docs/default访问404

版本信息

  • SpringCloud -> 2023.0.1
  • SpringBoot -> 3.2.5
  • JDK -> 21.0.3
  • knife4j -> 4.5.0

配置

  • application.yml配置
    springdoc:
      swagger-ui:
        path: /swagger-ui.html
        tags-sorter: alpha
        operations-sorter: alpha
      api-docs:
        path: /v3/api-docs
        enabled: true
      group-configs:
        - group: 'default'
          paths-to-match: '/**'
          packages-to-scan:
            - 'com.daryl.demo'
      default-flat-param-object: true
    knife4j:
      enable: true
      setting:
        language: zh_cn
        enable-footer-custom: true
        footer-custom-content: Apache License 2.0 | Copyright  2023
    
  • Configuration配置
    @SpringBootConfiguration
    public class Swagger2Config extends BaseSwaggerConfig {
    
        @Override
        public SwaggerProperties swaggerProperties() {
            return SwaggerProperties.builder()
                    .title("基础服务")
                    .description("基于REST接口风格接口文档")
                    .contactName("商业智能Beta")
                    .version("1.0")
                    .build();
        }
    }
    

重现步骤

输入图片说明
输入图片说明
输入图片说明
第二个default请求中间缺少/api路径,通过手动拼接(http://172.27.15.109/api/v3/api-docs/default)是能正常访问文档数据的
/api是线上的nginx进行转发的,在swagger2中是正常的,升级到swagger3后出现异常

评论 (0)

Tinu 创建了任务

登录 后才可以发表评论

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

搜索帮助

344bd9b3 5694891 D2dac590 5694891