Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !385

[aspnetcore] Fix new keyword collection

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/etherealjoy/fix_new_keyword_collection into master 7 years ago
  • Overview 0
  • Commits 3
  • Pipelines 0
  • Changes 9

Created by: etherealjoy

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.1.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Add isMapModel to CodegenModel to allow distinguishing if a Model is inherited from ICollection. Small refactor in model.mustache to allow removal of some VS hints.

Solves #275 (closed)

@mandrean @jimschubert cc core team for DefaultCodegen and CodegenModel Changes @wing328 @jimschubert @cbornet @jaz-ah @ackintosh @JFCote @jmini

Compare
  • master (base)

and
  • latest version
    f45ec312
    3 commits, 2 years ago

9 files
+ 18
- 17

    Preferences

    File browser
    Compare changes
modules/openapi-g‎enerator/src/main‎
java/org/opena‎pitools/codegen‎
CodegenM‎odel.java‎ +1 -1
DefaultCo‎degen.java‎ +2 -1
resources/‎aspnetcore‎
model.m‎ustache‎ +3 -3
samples/server‎/…/…/…/…/Models‎
ApiResp‎onse.cs‎ +2 -2
Categ‎ory.cs‎ +2 -2
Orde‎r.cs‎ +2 -2
Pet‎.cs‎ +2 -2
Tag‎.cs‎ +2 -2
Use‎r.cs‎ +2 -2
modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
+ 1
- 1
  • View file @ f45ec312

  • Edit in single-file editor

  • Open in Web IDE


@@ -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, isMapModel;
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
public ExternalDocumentation externalDocumentation;
modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java
+ 1
- 1
  • View file @ f45ec312

  • Edit in single-file editor

  • Open in Web IDE


@@ -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, isMapModel;
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
public ExternalDocumentation externalDocumentation;
modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+ 2
- 1
  • View file @ f45ec312

  • Edit in single-file editor

  • Open in Web IDE


@@ -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;
}
@@ -1521,6 +1521,7 @@ public class DefaultCodegen implements CodegenConfig {
}
if (ModelUtils.isMapSchema(schema)) {
addAdditionPropertiesToCodeGenModel(m, schema);
m.isMapModel = true;
}
addVars(m, schema.getProperties(), schema.getRequired());
}
modules/openapi-generator/src/main/resources/aspnetcore/model.mustache
+ 3
- 3
  • View file @ f45ec312

  • Edit in single-file editor

  • Open in Web IDE


@@ -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}}{{^isMapModel}}{{^isArrayModel}}new {{/isArrayModel}}{{/isMapModel}}{{/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}}
samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/ApiResponse.cs
+ 2
- 2
  • View file @ f45ec312

  • Edit in single-file editor

  • Open in Web IDE


@@ -73,7 +73,7 @@ namespace Org.OpenAPITools.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((ApiResponse)obj);
}
@@ -85,7 +85,7 @@ namespace Org.OpenAPITools.Models
/// <returns>Boolean</returns>
public bool Equals(ApiResponse other)
{
if (ReferenceEquals(null, other)) return false;
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/Category.cs
+ 2
- 2
  • View file @ f45ec312

  • Edit in single-file editor

  • Open in Web IDE


@@ -66,7 +66,7 @@ namespace Org.OpenAPITools.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((Category)obj);
}
@@ -78,7 +78,7 @@ namespace Org.OpenAPITools.Models
/// <returns>Boolean</returns>
public bool Equals(Category other)
{
if (ReferenceEquals(null, other)) return false;
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/Order.cs
+ 2
- 2
  • View file @ f45ec312

  • Edit in single-file editor

  • Open in Web IDE


@@ -122,7 +122,7 @@ namespace Org.OpenAPITools.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((Order)obj);
}
@@ -134,7 +134,7 @@ namespace Org.OpenAPITools.Models
/// <returns>Boolean</returns>
public bool Equals(Order other)
{
if (ReferenceEquals(null, other)) return false;
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/Pet.cs
+ 2
- 2
  • View file @ f45ec312

  • Edit in single-file editor

  • Open in Web IDE


@@ -124,7 +124,7 @@ namespace Org.OpenAPITools.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((Pet)obj);
}
@@ -136,7 +136,7 @@ namespace Org.OpenAPITools.Models
/// <returns>Boolean</returns>
public bool Equals(Pet other)
{
if (ReferenceEquals(null, other)) return false;
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/Tag.cs
+ 2
- 2
  • View file @ f45ec312

  • Edit in single-file editor

  • Open in Web IDE


@@ -66,7 +66,7 @@ namespace Org.OpenAPITools.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((Tag)obj);
}
@@ -78,7 +78,7 @@ namespace Org.OpenAPITools.Models
/// <returns>Boolean</returns>
public bool Equals(Tag other)
{
if (ReferenceEquals(null, other)) return false;
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Models/User.cs
+ 2
- 2
  • View file @ f45ec312

  • Edit in single-file editor

  • Open in Web IDE


@@ -109,7 +109,7 @@ namespace Org.OpenAPITools.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((User)obj);
}
@@ -121,7 +121,7 @@ namespace Org.OpenAPITools.Models
/// <returns>Boolean</returns>
public bool Equals(User other)
{
if (ReferenceEquals(null, other)) return false;
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
2
Enhancement: General Server: C-Sharp
2
Enhancement: General Server: C-Sharp
    Assign labels
  • Manage project labels

Milestone
3.0.3
3.0.3 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
3
3 participants
Administrator
Jim Schubert
William Cheng
Reference: OpenAPITools/openapi-generator!385
Source branch: github/fork/etherealjoy/fix_new_keyword_collection

Menu

Explore Projects Groups Snippets