Fix basePath set to null when generating API files. (#4304)

This commit is contained in:
Sreenidhi Sreesha 2016-11-30 23:46:44 -08:00 committed by wing328
parent 0a97b9c568
commit af0d217c38

View File

@ -78,18 +78,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
generateApis = System.getProperty("apis") != null ? true:null;
generateModels = System.getProperty("models") != null ? true: null;
generateSupportingFiles = System.getProperty("supportingFiles") != null ? true:null;
// model/api tests and documentation options rely on parent generate options (api or model) and no other options.
// They default to true in all scenarios and can only be marked false explicitly
generateModelTests = System.getProperty("modelTests") != null ? Boolean.valueOf(System.getProperty("modelTests")): true;
generateModelDocumentation = System.getProperty("modelDocs") != null ? Boolean.valueOf(System.getProperty("modelDocs")):true;
generateApiTests = System.getProperty("apiTests") != null ? Boolean.valueOf(System.getProperty("apiTests")): true;
generateApiDocumentation = System.getProperty("apiDocs") != null ? Boolean.valueOf(System.getProperty("apiDocs")):true;
if(generateApis == null && generateModels == null && generateSupportingFiles == null) {
if (generateApis == null && generateModels == null && generateSupportingFiles == null) {
// no specifics are set, generate everything
generateApis = generateModels = generateSupportingFiles = true;
}
else {
} else {
if(generateApis == null) {
generateApis = false;
}
@ -100,6 +93,14 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
generateSupportingFiles = false;
}
}
// model/api tests and documentation options rely on parent generate options (api or model) and no other options.
// They default to true in all scenarios and can only be marked false explicitly
generateModelTests = System.getProperty("modelTests") != null ? Boolean.valueOf(System.getProperty("modelTests")): true;
generateModelDocumentation = System.getProperty("modelDocs") != null ? Boolean.valueOf(System.getProperty("modelDocs")):true;
generateApiTests = System.getProperty("apiTests") != null ? Boolean.valueOf(System.getProperty("apiTests")): true;
generateApiDocumentation = System.getProperty("apiDocs") != null ? Boolean.valueOf(System.getProperty("apiDocs")):true;
// Additional properties added for tests to exclude references in project related files
config.additionalProperties().put(CodegenConstants.GENERATE_API_TESTS, generateApiTests);
config.additionalProperties().put(CodegenConstants.GENERATE_MODEL_TESTS, generateModelTests);
@ -117,6 +118,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
if (swagger.getVendorExtensions() != null) {
config.vendorExtensions().putAll(swagger.getVendorExtensions());
}
contextPath = config.escapeText(swagger.getBasePath() == null ? "" : swagger.getBasePath());
basePath = config.escapeText(getHost());
basePathWithoutHost = config.escapeText(swagger.getBasePath());
}
private void configureSwaggerInfo() {
@ -581,9 +587,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
if (swagger.getHost() != null) {
bundle.put("host", swagger.getHost());
}
contextPath = config.escapeText(swagger.getBasePath() == null ? "" : swagger.getBasePath());
basePath = config.escapeText(getHost());
basePathWithoutHost = config.escapeText(swagger.getBasePath());
bundle.put("swagger", this.swagger);
bundle.put("basePath", basePath);
bundle.put("basePathWithoutHost",basePathWithoutHost);