forked from loafle/openapi-generator-original
Remove 'new' keyword from collection
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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}}
|
||||
|
||||
Reference in New Issue
Block a user