[REQ] expose parentContainer to templates, add itemsDepth property to container items
Created by: mitchnull
I'm extending the models generated from swaggers with a deepCopy() method for java. For this I need to generate code based on the property types, but in case the baseType is List or Map, the detailed type information is lost to the templates (see: generateAliasAsModel).
I propose exposing the "parentContainer" type in these cases similar to how "items" are exposed for container properties.
The other issue is creating temporary variables for nested elements, as we can run into shadowing errors. To solve this issue I propose adding an "itemsDepth" property to nested properties ("items"), that reflects that depth in a container-hierarchy.
With these changes, one can generate code like this:
protected ArrArr deepCopyImpl(ArrArr source) {
this.strArrArr = (source.strArrArr == null
? null
: source.strArrArr.stream().map(v$1 -> (v$1 == null
? null
: v$1.stream().map(v$2 -> (v$2 == null
? null
: v$2.deepCopy())
).collect(Collectors.toList()))
).collect(Collectors.toList()));
return this;
}