Skip to content

Commit

Permalink
[type:refactor] add ApiDocRegistrar in new design (apache#5226)
Browse files Browse the repository at this point in the history
* [type:refactor] add ApiDocRegistrar in new design

* fix
  • Loading branch information
tian-pengfei authored Oct 14, 2023
1 parent d5fbac3 commit 9585f94
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.shenyu.client.core.register.extractor.RpcApiBeansExtractor;
import org.apache.shenyu.client.core.register.matcher.ApiDocProcessorImpl;
import org.apache.shenyu.client.core.register.matcher.ApiRegisterProcessor;
import org.apache.shenyu.client.core.register.registrar.ApiDocRegistrarImpl;
import org.apache.shenyu.client.core.register.registrar.ApiRegistrar;
import org.apache.shenyu.client.core.register.registrar.MateDataApiRegistrarImpl;
import org.apache.shenyu.register.client.api.ShenyuClientRegisterRepository;
Expand All @@ -50,7 +51,7 @@ public ClientApiRefreshedEventListener apiListener(final List<RpcApiBeansExtract
}

/**
* register.
* mate date register.
*
* @param clientRegisterConfig clientRegisterConfig
* @param processor processor
Expand All @@ -64,6 +65,23 @@ public MateDataApiRegistrarImpl mateDataApiRegistrarImpl(final ClientRegisterCon
}
return apiRegistrarImpl;
}

/**
* api doc register.
*
* @param clientRegisterConfig clientRegisterConfig
* @param processor processor
* @return register
*/
@Bean
public ApiDocRegistrarImpl apiDocRegistrarImpl(final ClientRegisterConfig clientRegisterConfig, final List<ApiRegisterProcessor> processor) {
final ApiDocRegistrarImpl apiRegistrarImpl = new ApiDocRegistrarImpl(clientRegisterConfig);
for (ApiRegisterProcessor apiProcessor : processor) {
apiRegistrarImpl.addApiProcessor(apiProcessor);
}
return apiRegistrarImpl;
}


/**
* apiDocProcessor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
*
* @see ApiDocRegisterDTO
*/
public class ApiDocRegistrarImplImpl extends BaseApiRegistrarImpl {
public class ApiDocRegistrarImpl extends BaseApiRegistrarImpl {

private final ShenyuClientRegisterEventPublisher publisher = ShenyuClientRegisterEventPublisher.getInstance();

private final ClientRegisterConfig clientRegisterConfig;

public ApiDocRegistrarImplImpl(final ClientRegisterConfig clientRegisterConfig) {
public ApiDocRegistrarImpl(final ClientRegisterConfig clientRegisterConfig) {
this.clientRegisterConfig = clientRegisterConfig;
}

Expand Down Expand Up @@ -178,15 +178,15 @@ private String getPath(final ApiBean.ApiDefinition api) {

private String getProduce(final ApiBean.ApiDefinition api) {
final String produce = api.getPropertiesValue("produce");
if (StringUtils.isNotBlank(produce)) {
if (StringUtils.isBlank(produce)) {
return ShenyuClientConstants.MEDIA_TYPE_ALL_VALUE;
}
return produce;
}

private static String getConsume(final ApiBean.ApiDefinition api) {
final String consume = api.getPropertiesValue("consume");
if (StringUtils.isNotBlank(consume)) {
if (StringUtils.isBlank(consume)) {
return ShenyuClientConstants.MEDIA_TYPE_ALL_VALUE;
}
return consume;
Expand Down

0 comments on commit 9585f94

Please sign in to comment.