SpringBoot Swagger 出现 Unable to infer base url. This is common....

在项目中Swagger-ui出现:
> Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if the api is available at http://example.org/api/v2/api-docs then the base url is http://example.org/api/. Please enter the location manually: ...

原因是拦截器或者Shiro等其他拦截错误。由于笔者使用的是Swagger-ui3,需要将以下地址放行:

  • /swagger-ui/**
  • /swagger-resources/**
  • /v3/api-docs/**

Shiro示例:

        filterChainDefinitionMap.put("/swagger-ui/**","anon");
        filterChainDefinitionMap.put("/swagger-resources/**","anon");
        filterChainDefinitionMap.put("/v3/api-docs/**","anon");


        filterChainDefinitionMap.put("/**", "authc");
        bean.setFilterChainDefinitionMap(filterChainDefinitionMap);

        return bean;