Skip to content
GitLab
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
  • Issues
  • #4961
Closed
Open
Issue created Jan 10, 2020 by Administrator@rootContributor

[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;
  }
Assignee
Assign to
Time tracking