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
  • #1216
Closed
Open
Issue created Oct 10, 2018 by Administrator@rootContributor

[JavaScript] Duplicate superclass constructor calls

Created by: delenius

Description

The JavaScript client generator generates two calls to the superclass constructor. For example, in samples/client/petstore/javascript/src/model/Dog.js, we have

  /**
   * Constructs a new <code>Dog</code>.
   * @alias module:model/Dog
   * @class
   * @extends module:model/Animal
   * @implements module:model/Animal
   * @param className {} 
   */
  var exports = function(className) {
    var _this = this;
    Animal.call(_this, className);
    Animal.call(_this, className);

  };

and also

  /**
   * Constructs a <code>Dog</code> from a plain JavaScript object, optionally creating a new instance.
   * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
   * @param {Object} data The plain JavaScript object bearing properties of interest.
   * @param {module:model/Dog} obj Optional instance to populate.
   * @return {module:model/Dog} The populated <code>Dog</code> instance.
   */
  exports.constructFromObject = function(data, obj) {
    if (data) {
      obj = obj || new exports();
      Animal.constructFromObject(data, obj);
      Animal.constructFromObject(data, obj);
      if (data.hasOwnProperty('breed')) {
        obj['breed'] = ApiClient.convertToType(data['breed'], 'String');
      }
    }
    return obj;
  }

Looking at the code, one of the calls comes from the parent property, and one from interfaceModels.

I'm not sure where those values ultimately come from. "interfaceModels" is not an openapi concept AFAIK.

openapi-generator version

3.3.1-SNAPSHOT (latest from git at the time of writing).

Suggest a fix/enhancement

I am guessing a reasonable solution would be to remove the parent from the interfaceModels in DefaultCodegen.postProcessAllModels, but I am not sure how this would affect e.g. the Java client generator.

Assignee
Assign to
Time tracking