better warning, default value (#1492)

This commit is contained in:
William Cheng 2018-11-19 20:55:29 +08:00 committed by GitHub
parent b9949e1a8e
commit 363b095721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 10 deletions

View File

@ -297,7 +297,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
}
if (projectDescription == null) {
// when projectDescription is not specified, use info.description
projectDescription = sanitizeName(info.getDescription());
if (StringUtils.isEmpty(info.getDescription())) {
projectDescription = "JS API client generated by OpenAPI Generator";
} else {
projectDescription = sanitizeName(info.getDescription());
}
}
// when licenceName is not specified, use info.license
@ -506,13 +510,18 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
private String getNameUsingModelPropertyNaming(String name) {
switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) {
case original: return name;
case camelCase: return org.openapitools.codegen.utils.StringUtils.camelize(name, true);
case PascalCase: return org.openapitools.codegen.utils.StringUtils.camelize(name);
case snake_case: return org.openapitools.codegen.utils.StringUtils.underscore(name);
default: throw new IllegalArgumentException("Invalid model property naming '" +
name + "'. Must be 'original', 'camelCase', " +
"'PascalCase' or 'snake_case'");
case original:
return name;
case camelCase:
return org.openapitools.codegen.utils.StringUtils.camelize(name, true);
case PascalCase:
return org.openapitools.codegen.utils.StringUtils.camelize(name);
case snake_case:
return org.openapitools.codegen.utils.StringUtils.underscore(name);
default:
throw new IllegalArgumentException("Invalid model property naming '" +
name + "'. Must be 'original', 'camelCase', " +
"'PascalCase' or 'snake_case'");
}
}
@ -871,7 +880,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
codegenModel.getVendorExtensions().put("x-itemType", getSchemaType(ModelUtils.getAdditionalProperties(model)));
} else {
String type = model.getType();
if (isPrimitiveType(type)){
if (isPrimitiveType(type)) {
codegenModel.vendorExtensions.put("x-isPrimitive", true);
}
}

View File

@ -179,7 +179,7 @@ public class URLPathUtils {
LOGGER.warn("'scheme' not defined in the spec (2.0). Default to [http] for server URL [{}]", url);
} else if (url.startsWith("/")) {
url = LOCAL_HOST + url;
LOGGER.warn("'host' not defined in the spec (2.0). Default to [{}] for server URL [{}]", LOCAL_HOST, url);
LOGGER.warn("'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [{}] for server URL [{}]", LOCAL_HOST, url);
} else if (!url.matches("[a-zA-Z][0-9a-zA-Z.+\\-]+://.+")) {
// Add http scheme for urls without a scheme.
// 2.0 spec is restricted to the following schemes: "http", "https", "ws", "wss"