Skip to content

Commit

Permalink
Revamp: Endpoint Config update for API import via APICTL and REST
Browse files Browse the repository at this point in the history
  • Loading branch information
BLasan committed Aug 17, 2024
1 parent 110deef commit c0e6fcb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2915,7 +2915,8 @@ public static void validateAPIEndpointConfig(Object endpointConfigObject, String
if (endpointConfigMap.containsKey("endpoint_type") && APIConstants.ENDPOINT_TYPE_SEQUENCE.equals(
endpointConfigMap.get(APIConstants.API_ENDPOINT_CONFIG_PROTOCOL_TYPE))
&& !APIConstants.APITransportType.GRAPHQL.toString().equalsIgnoreCase(apiType)
&& !APIConstants.API_TYPE_HTTP.equalsIgnoreCase(apiType)) {
&& !APIConstants.API_TYPE_HTTP.equalsIgnoreCase(apiType)
&& !APIConstants.API_TYPE_SOAPTOREST.equalsIgnoreCase(apiType)) {
throw new APIManagementException("Invalid endpoint configuration provided for the API " + apiName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ public static ImportedAPIDTO importApi(String extractedFolderPath, APIDTO import
// if a valid one then update the sequence file path
if (endpointConfig != null && APIConstants.ENDPOINT_TYPE_SEQUENCE.equals(
endpointConfig.get(APIConstants.API_ENDPOINT_CONFIG_PROTOCOL_TYPE))) {
String sequenceFileName = endpointConfig.get("sequence").toString();
String sequenceFileName = endpointConfig.get("sequence_path").toString();
String path = extractedFolderPath + File.separator + sequenceFileName;
endpointConfig.put("sequence", path);
endpointConfig.put("sequence_path", path);
importedApiDTO.setEndpointConfig(endpointConfig);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ private static API prepareForUpdateApi(API originalAPI, APIDTO apiDtoToUpdate, A
if (APIConstants.ENDPOINT_TYPE_SEQUENCE.equals(
endpointConfig.get(APIConstants.API_ENDPOINT_CONFIG_PROTOCOL_TYPE))) {
try {
if (endpointConfig.get("sequence") != null) {
String pathToSequence = endpointConfig.get("sequence").toString();
if (endpointConfig.get("sequence_path") != null) {
String pathToSequence = endpointConfig.get("sequence_path").toString();
String sequence = FileUtils.readFileToString(new File(pathToSequence),
Charset.defaultCharset());
endpointConfig.put("sequence", sequence);
Expand Down Expand Up @@ -951,8 +951,8 @@ public static API addAPIWithGeneratedSwaggerDefinition(APIDTO apiDto, String oas
if (APIConstants.ENDPOINT_TYPE_SEQUENCE.equals(
endpointConfig.get(APIConstants.API_ENDPOINT_CONFIG_PROTOCOL_TYPE))) {
try {
if (endpointConfig.get("sequence") != null) {
String pathToSequence = endpointConfig.get("sequence").toString();
if (endpointConfig.get("sequence_path") != null) {
String pathToSequence = endpointConfig.get("sequence_path").toString();
String sequence = FileUtils.readFileToString(new File(pathToSequence),
Charset.defaultCharset());
endpointConfig.put("sequence", sequence);
Expand Down

0 comments on commit c0e6fcb

Please sign in to comment.