swagger-api / swagger-api/swagger-codegen

[JavaJaxRS (repros in Java too)] Inherited properties missing from generated model.

Open
#4,114 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

When a swagger definition uses allOf to both include normal properties and inherit the properties of another model using $ref the generated model is missing the properties of the inherited model.

My use case is for the JavaJaxRS language target, but the below repro case is for the Java language target.

Swagger-codegen version

2.2.2-SNAPSHOT

Tried changing swagger-parser-version to be 1.0.23 in the pom, but the problem still persists.

Swagger declaration file content or url
Command line used for generation
Steps to reproduce

See Repro case gist

Related issues

Might be related to https://github.com/swagger-api/swagger-codegen/issues/3544

Suggest a Fix

Although I've done some digging in the source, I'm not yet familiar enough with the codebase to know what portions of it are responsible for propagating the inherited properties through to the composed model.

The expected behavior is that the composed model includes inherited properties.

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 with the linked repro case and the Java language target, then trace how an allOf composition with a $ref is represented during model generation. Done means the generated composed model includes the inherited properties as well as its normal properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
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.