Skip to content

Commit

Permalink
fix:fix app starting failed when user using custom OpenAPI bean. (#1398)
Browse files Browse the repository at this point in the history
Co-authored-by: Haotian Zhang <skyebefreeman@qq.com>
  • Loading branch information
fuyuwei01 and SkyeBeFreeman authored Aug 19, 2024
1 parent 95b7082 commit 2fbbde4
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
- [feat:add Tencent Cloud TSF support.](https://github.com/Tencent/spring-cloud-tencent/pull/1391)
- [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)
- [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)
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",".
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public GroupedOpenApi polarisGroupedOpenApi(PolarisContractProperties polarisCon
}

@Bean
@ConditionalOnMissingBean
public OpenAPI polarisOpenAPI() {
return new OpenAPI()
.info(new Info()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:/**}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
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;

/**
Expand Down Expand Up @@ -53,7 +53,8 @@ public void modify(ConfigurationImpl configuration) {
.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);
Expand Down
4 changes: 2 additions & 2 deletions spring-cloud-tencent-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

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;

/**
Expand All @@ -39,13 +39,13 @@ public PostInitPolarisSDKContext(SDKContext sdkContext, StaticMetadataManager st

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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

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;
Expand Down Expand Up @@ -55,9 +55,9 @@ public void testConstructor() {
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);
Expand Down

0 comments on commit 2fbbde4

Please sign in to comment.