swagger-api / swagger-api/swagger-codegen

Duplicate entries when using inheritance or composition

Open
#4,258 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature: Composition / Inheritance Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

A PR(#3935) has been opened by @j4velin regarding this problem, but I cannot find any related issue.

Using the simple definition below, we get duplicate vars for seaplane:

image

Also, I am unsure if the PR fully fixes the issue. Since the second call to addVars(...) will add new properties to m.allVars instead of m.vars, these properties will not be taken into account by postProcessModelProperty as it is run only on m.vars.

Swagger-codegen version

Master branch

Swagger declaration file content or url
definitions:
  plane:
    type: object
    properties:
      name:
        type: string
      length: 
        type: string

  seaplane:
    type: object
    allOf:
      - $ref: '#/definitions/plane'
      - type: object
        properties:
          other: 
            type: string

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at addVars(...) and follow how inheritance or composition populates m.vars and m.allVars. Check postProcessModelProperty and reproduce the seaplane definition from the issue; done means generated properties are not duplicated and all properties receive the expected post-processing.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.