atc-net / atc-rest-api-generator

A REST API code generator from OpenAPI Specification in YAML or Json file format
https://atc-net.github.io/repository/atc-rest-api-generator
MIT License
19 stars 4 forks source link

The ToString on models now print the count of collections #98

Closed egil closed 3 years ago

egil commented 3 years ago

Closes #49.

The ToString on models now print the count of collections instead of just the type name, e.g. List.

This is a simple example of the change:

public override string ToString()
{
-  return $"{nameof(MyItems)}: {MyItems}";
+  return $"{nameof(MyItems)}: {MyItems?.Count ?? 0}";
}

Note that the code ensures it works with both nullable and non-nullable collections, and this makes it safe even if null is assigned to a non-nullable property.