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
  • #1606
Closed
Open
Issue created Dec 04, 2018 by Administrator@rootContributor

[Java client] add a way to duplicate an model class

Created by: jmini

There are scenario where being able to create a new instance of a model class with the same values as an other one is necessary.

Example:

Pet pet = api.getPetById().petIdPath(id).executeAs(r -> r.thenReturn());

Pet body = pet; // this should be a new instance of Pet, a copy with the same values.
pet.setName("New name");
api.updatePet().body(body).execute(r -> r.prettyPeek());

Pet pet2 = api.getPetById().petIdPath(id).executeAs(r -> r.thenReturn());

// here you need the pet instance as it was (without any modification) 
// and pet2 to perform some assertions

I suggest to add two constructors to the models classes:

  • An empty one (current behaviour)
  • A constructor accepting an other instance of the same class

In the second case, the values will be copied.

Assignee
Assign to
Time tracking