swagger-api / swagger-api/swagger-codegen

Codegen is merging nested models

Open
#9,186 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

When multiple nested models have identical contents, codegen automatically merges them and generates only one model. This is not expected because these models are unrelated. Need an option to disable merging.

Swagger-codegen version

2.4.1

Swagger declaration file content or url
definitions:
  outer1:
    type: object
    properties:
      inner1:
        type: object
        properties:
          foo:
            type: string
  outer2:
    type: object
    properties:
      inner2:
        type: object
        properties:
          foo:
            type: string
Command line used for generation

java -jar swagger-codegen-cli-2.4.1.jar generate -i api.yaml -l jaxrs-spec

Steps to reproduce

Just generate code. Inner1 is generated as Outer1Inner1, but inner2 is not being generated. Outer2 now has a field Outer1Inner1 inner2, which is not expected.
It's not language-specific.

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

Reproduce the issue with the shown api.yaml definitions and the java -jar swagger-codegen-cli-2.4.1.jar generate -i api.yaml -l jaxrs-spec command. Trace the model-generation entry point responsible for deduplicating identical nested models, then verify that an option can preserve separate Outer1Inner1 and Outer2Inner2 types across generated languages.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
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.