Set namedCredential file name from the property (#2937)

The namedCredential property is intended to override the namedCredentials name, but it wasn't being used. Instead, the title from the openapi spec file was used, and the namedCredential property wasn't used anywhere.

For backwards compatibility, this change also keeps the spec title as the default name if an override is not provided.
This commit is contained in:
Logan Moore
2019-05-21 01:28:58 +12:00
committed by William Cheng
parent 18b66ed28c
commit e30f0c9879

View File

@@ -21,6 +21,7 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.SupportingFile;
@@ -46,7 +47,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
private String classPrefix = "OAS";
private String apiVersion = "42.0";
private String buildMethod = "sfdx";
private String namedCredential = classPrefix;
private String namedCredential;
private String srcPath = "force-app/main/default/";
private String sfdxConfigPath = "config/";
private HashMap<String, Object> primitiveDefaults = new HashMap<String, Object>();
@@ -161,8 +162,10 @@ public class ApexClientCodegen extends AbstractApexCodegen {
@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
Info info = openAPI.getInfo();
String calloutLabel = info.getTitle();
String calloutLabel = openAPI.getInfo().getTitle();
if (StringUtils.isNotBlank(namedCredential)) {
calloutLabel = namedCredential;
}
additionalProperties.put("calloutLabel", calloutLabel);
String sanitized = sanitizeName(calloutLabel);
additionalProperties.put("calloutName", sanitized);