Skip to content

Commit 9990ddb

Browse files
authored
Merge pull request #385 from etherealjoy/fix_new_keyword_collection
[aspnetcore] Fix new keyword collection
2 parents 0eb385c + f45ec31 commit 9990ddb

9 files changed

Lines changed: 18 additions & 17 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class CodegenModel {
5858
public Set<String> allMandatory;
5959

6060
public Set<String> imports = new TreeSet<String>();
61-
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren;
61+
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren, isMapModel;
6262
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
6363
public ExternalDocumentation externalDocumentation;
6464

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
218218
}
219219
parent.getChildren().add(cm);
220220
if (parent.getDiscriminator() == null) {
221-
parent = allModels.get(parent.parent);
221+
parent = allModels.get(parent.getParent());
222222
} else {
223223
parent = null;
224224
}
@@ -1521,6 +1521,7 @@ public CodegenModel fromModel(String name, Schema schema, Map<String, Schema> al
15211521
}
15221522
if (ModelUtils.isMapSchema(schema)) {
15231523
addAdditionPropertiesToCodeGenModel(m, schema);
1524+
m.isMapModel = true;
15241525
}
15251526
addVars(m, schema.getProperties(), schema.getRequired());
15261527
}

modules/openapi-generator/src/main/resources/aspnetcore/model.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace {{packageName}}.Models
5656
/// Returns the JSON string presentation of the object
5757
/// </summary>
5858
/// <returns>JSON string presentation of the object</returns>
59-
public {{#parent}} new {{/parent}}string ToJson()
59+
public {{#parent}}{{^isMapModel}}{{^isArrayModel}}new {{/isArrayModel}}{{/isMapModel}}{{/parent}}string ToJson()
6060
{
6161
return JsonConvert.SerializeObject(this, Formatting.Indented);
6262
}
@@ -68,7 +68,7 @@ namespace {{packageName}}.Models
6868
/// <returns>Boolean</returns>
6969
public override bool Equals(object obj)
7070
{
71-
if (ReferenceEquals(null, obj)) return false;
71+
if (obj is null) return false;
7272
if (ReferenceEquals(this, obj)) return true;
7373
return obj.GetType() == GetType() && Equals(({{classname}})obj);
7474
}
@@ -80,7 +80,7 @@ namespace {{packageName}}.Models
8080
/// <returns>Boolean</returns>
8181
public bool Equals({{classname}} other)
8282
{
83-
if (ReferenceEquals(null, other)) return false;
83+
if (other is null) return false;
8484
if (ReferenceEquals(this, other)) return true;
8585
8686
return {{#vars}}{{#isNotContainer}}

samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/ApiResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public string ToJson()
7373
/// <returns>Boolean</returns>
7474
public override bool Equals(object obj)
7575
{
76-
if (ReferenceEquals(null, obj)) return false;
76+
if (obj is null) return false;
7777
if (ReferenceEquals(this, obj)) return true;
7878
return obj.GetType() == GetType() && Equals((ApiResponse)obj);
7979
}
@@ -85,7 +85,7 @@ public override bool Equals(object obj)
8585
/// <returns>Boolean</returns>
8686
public bool Equals(ApiResponse other)
8787
{
88-
if (ReferenceEquals(null, other)) return false;
88+
if (other is null) return false;
8989
if (ReferenceEquals(this, other)) return true;
9090

9191
return

samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/Category.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public string ToJson()
6666
/// <returns>Boolean</returns>
6767
public override bool Equals(object obj)
6868
{
69-
if (ReferenceEquals(null, obj)) return false;
69+
if (obj is null) return false;
7070
if (ReferenceEquals(this, obj)) return true;
7171
return obj.GetType() == GetType() && Equals((Category)obj);
7272
}
@@ -78,7 +78,7 @@ public override bool Equals(object obj)
7878
/// <returns>Boolean</returns>
7979
public bool Equals(Category other)
8080
{
81-
if (ReferenceEquals(null, other)) return false;
81+
if (other is null) return false;
8282
if (ReferenceEquals(this, other)) return true;
8383

8484
return

samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/Order.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public string ToJson()
122122
/// <returns>Boolean</returns>
123123
public override bool Equals(object obj)
124124
{
125-
if (ReferenceEquals(null, obj)) return false;
125+
if (obj is null) return false;
126126
if (ReferenceEquals(this, obj)) return true;
127127
return obj.GetType() == GetType() && Equals((Order)obj);
128128
}
@@ -134,7 +134,7 @@ public override bool Equals(object obj)
134134
/// <returns>Boolean</returns>
135135
public bool Equals(Order other)
136136
{
137-
if (ReferenceEquals(null, other)) return false;
137+
if (other is null) return false;
138138
if (ReferenceEquals(this, other)) return true;
139139

140140
return

samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/Pet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public string ToJson()
124124
/// <returns>Boolean</returns>
125125
public override bool Equals(object obj)
126126
{
127-
if (ReferenceEquals(null, obj)) return false;
127+
if (obj is null) return false;
128128
if (ReferenceEquals(this, obj)) return true;
129129
return obj.GetType() == GetType() && Equals((Pet)obj);
130130
}
@@ -136,7 +136,7 @@ public override bool Equals(object obj)
136136
/// <returns>Boolean</returns>
137137
public bool Equals(Pet other)
138138
{
139-
if (ReferenceEquals(null, other)) return false;
139+
if (other is null) return false;
140140
if (ReferenceEquals(this, other)) return true;
141141

142142
return

samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/Tag.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public string ToJson()
6666
/// <returns>Boolean</returns>
6767
public override bool Equals(object obj)
6868
{
69-
if (ReferenceEquals(null, obj)) return false;
69+
if (obj is null) return false;
7070
if (ReferenceEquals(this, obj)) return true;
7171
return obj.GetType() == GetType() && Equals((Tag)obj);
7272
}
@@ -78,7 +78,7 @@ public override bool Equals(object obj)
7878
/// <returns>Boolean</returns>
7979
public bool Equals(Tag other)
8080
{
81-
if (ReferenceEquals(null, other)) return false;
81+
if (other is null) return false;
8282
if (ReferenceEquals(this, other)) return true;
8383

8484
return

samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/User.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public string ToJson()
109109
/// <returns>Boolean</returns>
110110
public override bool Equals(object obj)
111111
{
112-
if (ReferenceEquals(null, obj)) return false;
112+
if (obj is null) return false;
113113
if (ReferenceEquals(this, obj)) return true;
114114
return obj.GetType() == GetType() && Equals((User)obj);
115115
}
@@ -121,7 +121,7 @@ public override bool Equals(object obj)
121121
/// <returns>Boolean</returns>
122122
public bool Equals(User other)
123123
{
124-
if (ReferenceEquals(null, other)) return false;
124+
if (other is null) return false;
125125
if (ReferenceEquals(this, other)) return true;
126126

127127
return

0 commit comments

Comments
 (0)