OpenAPITools / OpenAPITools/openapi-generator

[BUG] Generator is merging nested models

Open
#2,178 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

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

openapi-generator version

4.0.0-beta2

OpenAPI 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 openapi-generator-cli-4.0.0-beta2.jar generate -i api.yaml -g jaxrs-spec

Steps to reproduce

Generate code. Inner1 is generated as Outer1Inner1, but inner2 is not being generated. Outer2 now has a field Outer1Inner1 inner2, which is not expected.
This issue 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

Start by reproducing the issue with the supplied api.yaml definitions and the openapi-generator-cli command using the jaxrs-spec generator. Trace where identical nested models are merged and identify the existing option-handling path; done means an option can disable merging so both unrelated nested models are generated separately.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.