fix:fix app starting failed when user using custom OpenAPI bean. (#1398)

Co-authored-by: Haotian Zhang <skyebefreeman@qq.com>
pull/1400/head
Fishtail 3 months ago committed by GitHub
parent 95b708289e
commit 2fbbde4ab0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -20,3 +20,4 @@
- [feat:support consul config.](https://github.com/Tencent/spring-cloud-tencent/pull/1394)
- [feat:add trace report support.](https://github.com/Tencent/spring-cloud-tencent/pull/1396)
- [feat:support consul service update task.](https://github.com/Tencent/spring-cloud-tencent/pull/1397)
- [fix:fix app starting failed when user using custom OpenAPI bean.](https://github.com/Tencent/spring-cloud-tencent/pull/1398)

@ -89,7 +89,7 @@
<properties>
<!-- Project revision -->
<revision>1.14.0-2020.0.6-SNAPSHOT</revision>
<revision>2.0.0.0-2020.0.6-SNAPSHOT</revision>
<!-- Spring Framework -->
<spring.framework.version>5.3.25</spring.framework.version>

@ -46,7 +46,7 @@ public class PolarisContractProperties implements ContractProperties {
/**
* Group to create swagger docket.
*/
private String group = "default";
private String group = "polaris";
/**
* Base paths to be scanned. Split by ",".
*/

@ -83,6 +83,7 @@ public class PolarisSwaggerAutoConfiguration {
}
@Bean
@ConditionalOnMissingBean
public OpenAPI polarisOpenAPI() {
return new OpenAPI()
.info(new Info()

@ -39,7 +39,7 @@ public class TsfContractProperties implements ExtendedContractProperties {
@Value("${tsf.swagger.enabled:true}")
private boolean enabled;
@Value("${tsf.swagger.group:default}")
@Value("${tsf.swagger.group:polaris}")
private String groupName;
@Value("${tsf.swagger.basePath:/**}")

@ -22,10 +22,10 @@ import com.tencent.cloud.common.constant.OrderConstant;
import com.tencent.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.cloud.polaris.router.config.properties.PolarisNearByRouterProperties;
import com.tencent.polaris.api.config.consumer.ServiceRouterConfig;
import com.tencent.polaris.api.plugin.route.LocationLevel;
import com.tencent.polaris.factory.config.ConfigurationImpl;
import com.tencent.polaris.plugins.router.healthy.RecoverRouterConfig;
import com.tencent.polaris.plugins.router.nearby.NearbyRouterConfig;
import com.tencent.polaris.specification.api.v1.traffic.manage.RoutingProto;
import org.apache.commons.lang.StringUtils;
/**
@ -53,7 +53,8 @@ public class RouterConfigModifier implements PolarisConfigModifier {
.setPluginConfig(ServiceRouterConfig.DEFAULT_ROUTER_RECOVER, recoverRouterConfig);
if (StringUtils.isNotBlank(polarisNearByRouterProperties.getMatchLevel())) {
LocationLevel locationLevel = LocationLevel.valueOf(polarisNearByRouterProperties.getMatchLevel());
RoutingProto.NearbyRoutingConfig.LocationLevel locationLevel =
RoutingProto.NearbyRoutingConfig.LocationLevel.valueOf(StringUtils.upperCase(polarisNearByRouterProperties.getMatchLevel()));
NearbyRouterConfig nearbyRouterConfig = configuration.getConsumer().getServiceRouter().getPluginConfig(
ServiceRouterConfig.DEFAULT_ROUTER_NEARBY, NearbyRouterConfig.class);
nearbyRouterConfig.setMatchLevel(locationLevel);

@ -71,10 +71,10 @@
<properties>
<!-- Project revision -->
<revision>1.14.0-2020.0.6-SNAPSHOT</revision>
<revision>2.0.0.0-2020.0.6-SNAPSHOT</revision>
<!-- Polaris SDK version -->
<polaris.version>1.15.8-SNAPSHOT</polaris.version>
<polaris.version>2.0.0.0-SNAPSHOT</polaris.version>
<!-- Dependencies -->
<guava.version>32.0.1-jre</guava.version>

@ -20,8 +20,8 @@ package com.tencent.cloud.polaris.context;
import com.tencent.cloud.common.metadata.StaticMetadataManager;
import com.tencent.polaris.api.plugin.common.ValueContext;
import com.tencent.polaris.api.plugin.route.LocationLevel;
import com.tencent.polaris.client.api.SDKContext;
import com.tencent.polaris.specification.api.v1.traffic.manage.RoutingProto;
import org.apache.commons.lang.StringUtils;
/**
@ -39,13 +39,13 @@ public class PostInitPolarisSDKContext {
ValueContext valueContext = sdkContext.getValueContext();
if (StringUtils.isNotBlank(region)) {
valueContext.setValue(LocationLevel.region.name(), region);
valueContext.setValue(RoutingProto.NearbyRoutingConfig.LocationLevel.REGION.name(), region);
}
if (StringUtils.isNotBlank(zone)) {
valueContext.setValue(LocationLevel.zone.name(), zone);
valueContext.setValue(RoutingProto.NearbyRoutingConfig.LocationLevel.ZONE.name(), zone);
}
if (StringUtils.isNotBlank(campus)) {
valueContext.setValue(LocationLevel.campus.name(), campus);
valueContext.setValue(RoutingProto.NearbyRoutingConfig.LocationLevel.CAMPUS.name(), campus);
}
}
}

@ -19,8 +19,8 @@ package com.tencent.cloud.polaris.context;
import com.tencent.cloud.common.metadata.StaticMetadataManager;
import com.tencent.polaris.api.plugin.common.ValueContext;
import com.tencent.polaris.api.plugin.route.LocationLevel;
import com.tencent.polaris.client.api.SDKContext;
import com.tencent.polaris.specification.api.v1.traffic.manage.RoutingProto;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ -55,9 +55,9 @@ public final class PostInitPolarisSDKContextTest {
when(staticMetadataManager.getCampus()).thenReturn(CAMPUS);
new PostInitPolarisSDKContext(sdkContext, staticMetadataManager);
String regionName = valueContext.getValue(LocationLevel.region.name());
String zoneName = valueContext.getValue(LocationLevel.zone.name());
String campusName = valueContext.getValue(LocationLevel.campus.name());
String regionName = valueContext.getValue(RoutingProto.NearbyRoutingConfig.LocationLevel.REGION.name());
String zoneName = valueContext.getValue(RoutingProto.NearbyRoutingConfig.LocationLevel.ZONE.name());
String campusName = valueContext.getValue(RoutingProto.NearbyRoutingConfig.LocationLevel.CAMPUS.name());
Assertions.assertThat(regionName).isEqualTo(REGION);
Assertions.assertThat(zoneName).isEqualTo(ZONE);

Loading…
Cancel
Save