Skip to content

Commit

Permalink
Merge pull request #523 from Axway-API-Management-Plus/methodlevelscope
Browse files Browse the repository at this point in the history
Methodlevelscope
  • Loading branch information
rathnapandi authored Nov 23, 2024
2 parents 07f414d + 615bf80 commit f22b712
Show file tree
Hide file tree
Showing 10 changed files with 529 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,8 @@ public APISpecification setFilterConfig(APISpecificationFilter filterConfig) {
this.filterConfig = filterConfig;
return this;
}

public ObjectMapper getMapper() {
return mapper;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void saveAPILocally(ObjectMapper mapper, ExportAPI exportAPI, String conf
throw new AppException("Backend API Definition is not available for the API : " + exportAPI.getName() + ", hence use the option -useFEAPIDefinition to export API", ErrorCode.BACKEND_API_DEF_NA);
return;
}
writeSpec(mapper, apiDef, exportAPI, localFolder);
writeSpec(apiDef, exportAPI, localFolder);
Image image = exportAPI.getAPIImage();
if (image != null && (!EnvironmentProperties.PRINT_CONFIG_CONSOLE)) {
writeBytesToFile(image.getImageContent(), localFolder + File.separator + image.getBaseFilename());
Expand Down Expand Up @@ -143,22 +143,23 @@ private void storePrivateCerts(File localFolder, List<AuthenticationProfile> aut
}
}

public void writeSpec(ObjectMapper mapper, APISpecification apiDef, ExportAPI exportAPI, File localFolder) throws AppException {
public void writeSpec(APISpecification apiDef, ExportAPI exportAPI, File localFolder) throws AppException {
String targetFile = null;
try {
if (!(apiDef instanceof WSDLSpecification && EnvironmentProperties.RETAIN_BACKEND_URL) && (!EnvironmentProperties.PRINT_CONFIG_CONSOLE)) {
String fileName = Utils.replaceSpecialChars(exportAPI.getName());
String fileExtension = apiDef.getAPIDefinitionType().getFileExtension();
if(apiDef instanceof Swagger2xSpecification || apiDef instanceof OAS3xSpecification){
if (apiDef instanceof Swagger2xSpecification || apiDef instanceof OAS3xSpecification) {
ObjectMapper mapper = apiDef.getMapper();
if (mapper.getFactory() instanceof YAMLFactory) {
fileExtension = APISpecification.APISpecType.SWAGGER_API_20_YAML.getFileExtension();
}else {
fileExtension = APISpecification.APISpecType.SWAGGER_API_20.getFileExtension();
fileExtension = APISpecification.APISpecType.SWAGGER_API_20_YAML.getFileExtension();
} else {
fileExtension = APISpecification.APISpecType.SWAGGER_API_20.getFileExtension();
}
targetFile = localFolder.getCanonicalPath() + "/" + fileName + fileExtension;
Object spec = mapper.readValue(apiDef.getApiSpecificationContent(), Object.class);
mapper.writerWithDefaultPrettyPrinter().writeValue(new File(targetFile), spec);
}else {
} else {
targetFile = localFolder.getCanonicalPath() + "/" + fileName + fileExtension;
writeBytesToFile(apiDef.getApiSpecificationContent(), targetFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import com.axway.apim.api.API;
import com.axway.apim.api.model.*;
import com.axway.apim.config.model.APISecurity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@JsonPropertyOrder({"name", "path", "state", "version", "organization", "apiSpecification", "summary", "descriptionType", "descriptionManual", "vhost", "remoteHost",
"backendBasepath", "image", "inboundProfiles", "outboundProfiles", "securityProfiles", "authenticationProfiles", "tags", "customProperties",
Expand All @@ -16,12 +18,10 @@ public class APIConfig {
public static final String DEFAULT = "_default";
private final API api;
private final String apiDefinition;
private final Map<String, Object> securityProfiles;

public APIConfig(API api, String apiDefinition, Map<String, Object> securityProfiles) {
public APIConfig(API api, String apiDefinition) {
this.api = api;
this.apiDefinition = apiDefinition;
this.securityProfiles = securityProfiles;
}

public Map<String, OutboundProfile> getOutboundProfiles() {
Expand All @@ -46,15 +46,8 @@ public Map<String, OutboundProfile> getOutboundProfiles() {
}


public List<Map<String, Object>> getSecurityProfiles() {
if (securityProfiles.size() == 1) {
List<APISecurity> apiSecurities = (List<APISecurity>) securityProfiles.get("devices");
if (apiSecurities.get(0).getType().equals(DeviceType.passThrough.getName()))
return Collections.emptyList();
}
List<Map<String, Object>> list = new ArrayList<>();
list.add(securityProfiles);
return list;
public List<SecurityProfile> getSecurityProfiles() {
return api.getSecurityProfiles();
}

public String getPath() {
Expand Down
Loading

0 comments on commit f22b712

Please sign in to comment.