This commit is contained in:
wing328
2016-06-21 22:27:56 +08:00
14 changed files with 293 additions and 11 deletions

View File

@@ -37,6 +37,7 @@ public class CodegenModel {
public Set<String> imports = new TreeSet<String>();
public Boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, isArrayModel;
public Boolean hasOnlyReadOnly = true; // true if all properties are read-only
public ExternalDocs externalDocs;
public Map<String, Object> vendorExtensions;

View File

@@ -2592,6 +2592,11 @@ public class DefaultCodegen {
m.hasEnums = true;
}
// set model's hasOnlyReadOnly to false if the property is read-only
if (!Boolean.TRUE.equals(cp.isReadOnly)) {
m.hasOnlyReadOnly = false;
}
if (i+1 != totalCount) {
cp.hasMore = true;
// check the next entry to see if it's read only

View File

@@ -259,7 +259,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
// check to see if model name is same as the property name
// which will result in compilation error
// if found, prepend with _ to workaround the limitation
if (var.name.equals(cm.name)) {
if (var.name.equalsIgnoreCase(cm.name)) {
var.name = "_" + var.name;
}
}
@@ -615,8 +615,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
enumName = camelize(enumName) + "Enum";
LOGGER.info("toEnumVarName = " + enumName);
if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {