fixed api url context

This commit is contained in:
Radek Davidek 2026-02-19 12:54:18 +01:00
parent b77f50c3e3
commit 3107c62627

View File

@ -21,6 +21,8 @@ import cz.trask.migration.util.CredentialsDecoder;
public class ApiDefinitionMapper32to45 {
private static final String CONTEXT_VERSION_TEMPLATE = "/{version}";
public static ApiDefinition45 map(ApiDefinition32 oldApi, String swagger) throws Exception {
if (oldApi == null)
return null;
@ -45,7 +47,7 @@ public class ApiDefinitionMapper32to45 {
data.setProvider(oldApi.getId() != null ? oldApi.getId().getProviderName() : null);
// data.setContext(swaggerData.get("basePath") != null ?
// swaggerData.get("basePath").toString() : "");
data.setContext(oldApi.getContext());
data.setContext(getContext(oldApi.getContext(), oldApi.getContextTemplate(), oldApi.getId().getVersion()));
data.setLifeCycleStatus(oldApi.getStatus());
data.setDefaultVersion(oldApi.isDefaultVersion());
data.setRevision(false);
@ -158,6 +160,16 @@ public class ApiDefinitionMapper32to45 {
return newApi;
}
private static String getContext(String context, String contextTemplate, String version) {
if (contextTemplate != null && !contextTemplate.isEmpty()) {
return contextTemplate.replace(CONTEXT_VERSION_TEMPLATE, "");
}
if (context != null && !context.isEmpty()) {
return context.replace(version, "");
}
return context;
}
private static Map mapEndpointConfig(Map endpointConfig) {
if (endpointConfig == null || endpointConfig.isEmpty())
return new HashMap();