Remove 'new' keyword from collection

This commit is contained in:
sunn
2018-06-24 00:28:53 +02:00
parent 36f4452351
commit 92a0e4e7d8
3 changed files with 7 additions and 5 deletions

View File

@@ -58,7 +58,7 @@ public class CodegenModel {
public Set<String> allMandatory;
public Set<String> imports = new TreeSet<String>();
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren;
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren, isCollectionModel;
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
public ExternalDocumentation externalDocumentation;

View File

@@ -218,7 +218,7 @@ public class DefaultCodegen implements CodegenConfig {
}
parent.getChildren().add(cm);
if (parent.getDiscriminator() == null) {
parent = allModels.get(parent.parent);
parent = allModels.get(parent.getParent());
} else {
parent = null;
}
@@ -1412,6 +1412,7 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isArraySchema(schema)) {
m.isArrayModel = true;
m.isCollectionModel = true;
m.arrayModelType = fromProperty(name, schema).complexType;
addParentContainer(m, name, schema);
} else if (schema instanceof ComposedSchema) {
@@ -1521,6 +1522,7 @@ public class DefaultCodegen implements CodegenConfig {
}
if (ModelUtils.isMapSchema(schema)) {
addAdditionPropertiesToCodeGenModel(m, schema);
m.isCollectionModel = true;
}
addVars(m, schema.getProperties(), schema.getRequired());
}

View File

@@ -56,7 +56,7 @@ namespace {{packageName}}.Models
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public {{#parent}} new {{/parent}}string ToJson()
public {{#parent}}{{^isCollectionModel}}new {{/isCollectionModel}}{{/parent}}string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
@@ -68,7 +68,7 @@ namespace {{packageName}}.Models
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals(({{classname}})obj);
}
@@ -80,7 +80,7 @@ namespace {{packageName}}.Models
/// <returns>Boolean</returns>
public bool Equals({{classname}} other)
{
if (ReferenceEquals(null, other)) return false;
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return {{#vars}}{{#isNotContainer}}