update 优化 接口文档 接口地址与服务地址不匹配问题

2.X
疯狂的狮子li 3 years ago
parent 52ad1ab899
commit 950bd8b905

@ -2,9 +2,11 @@ package com.ruoyi.common.swagger.config;
import cn.dev33.satoken.config.SaTokenConfig; import cn.dev33.satoken.config.SaTokenConfig;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.swagger.config.properties.SwaggerProperties; import com.ruoyi.common.swagger.config.properties.SwaggerProperties;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -37,6 +39,9 @@ public class SwaggerAutoConfiguration {
@Autowired @Autowired
private SaTokenConfig saTokenConfig; private SaTokenConfig saTokenConfig;
@Value("${spring.application.name}")
private String appName;
/** /**
* Spring Boot * Spring Boot
*/ */
@ -75,7 +80,7 @@ public class SwaggerAutoConfiguration {
return builder.build() return builder.build()
.securitySchemes(securitySchemes()) .securitySchemes(securitySchemes())
.securityContexts(securityContexts()) .securityContexts(securityContexts())
.pathMapping("/"); .pathMapping(StringUtils.substring(appName, appName.indexOf("-") + 1));
} }
/** /**

Loading…
Cancel
Save