forked from loafle/openapi-generator-original
Fix basePath set to null when generating API files. (#4304)
This commit is contained in:
parent
0a97b9c568
commit
af0d217c38
@ -78,18 +78,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
generateApis = System.getProperty("apis") != null ? true:null;
|
generateApis = System.getProperty("apis") != null ? true:null;
|
||||||
generateModels = System.getProperty("models") != null ? true: null;
|
generateModels = System.getProperty("models") != null ? true: null;
|
||||||
generateSupportingFiles = System.getProperty("supportingFiles") != 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
|
// no specifics are set, generate everything
|
||||||
generateApis = generateModels = generateSupportingFiles = true;
|
generateApis = generateModels = generateSupportingFiles = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if(generateApis == null) {
|
if(generateApis == null) {
|
||||||
generateApis = false;
|
generateApis = false;
|
||||||
}
|
}
|
||||||
@ -100,6 +93,14 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
generateSupportingFiles = false;
|
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
|
// 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_API_TESTS, generateApiTests);
|
||||||
config.additionalProperties().put(CodegenConstants.GENERATE_MODEL_TESTS, generateModelTests);
|
config.additionalProperties().put(CodegenConstants.GENERATE_MODEL_TESTS, generateModelTests);
|
||||||
@ -117,6 +118,11 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
if (swagger.getVendorExtensions() != null) {
|
if (swagger.getVendorExtensions() != null) {
|
||||||
config.vendorExtensions().putAll(swagger.getVendorExtensions());
|
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() {
|
private void configureSwaggerInfo() {
|
||||||
@ -581,9 +587,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
if (swagger.getHost() != null) {
|
if (swagger.getHost() != null) {
|
||||||
bundle.put("host", swagger.getHost());
|
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("swagger", this.swagger);
|
||||||
bundle.put("basePath", basePath);
|
bundle.put("basePath", basePath);
|
||||||
bundle.put("basePathWithoutHost",basePathWithoutHost);
|
bundle.put("basePathWithoutHost",basePathWithoutHost);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user