swagger-api / swagger-api/swagger-core

Property with same name, jsonProperty and className but different packages Swagger3 (Springboot3 webflux rest) not use inheritance

Open
#4,757 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog
Dominant language
Java
Stars
7.5k
Forks
2.3k
Avg merge
18h 1m
Merged PRs (30d)
10

Description

I have 2 APIs that are implemented as response 200 with 2 different objects (with a property with same name and propertyName with implementation with 2 fullpath package different and same classe name).
I don't know why Swagger generate documents where that property is like it only searches for it the first time it finds it in an API and doesn't search for inheritance from the starting object by scanning the properties with the related subobjects.
As if it build a hashmap without adding the full package path and do not go to look for that object that has a different full package path
The java annotation Schema - implementation (strated from only classNAme.class now I added fullpackage.className.class but it doesn't work):

@ApiResponse( responseCode = "200",
description = "Response successful",
content = @Content(schema = @Schema(implementation = [fullpackageClassName].class)
)),

it isn't using inheritance for that property in the specified class [fullllpackageClassName].class from implementation but is taking that property from a class with the same object name but are in different packages path and the objects even with the same name and same jsonProperty name are different as package.classe.class property.

Is there a way to specify for a property of type object with the java swagger3 annotations that that object is implemented in the correct class specifying the full package?
Or does anyone have a solution for swagger to correctly take the correct object with the [full package].[classe].class

Thanks a lot for your support.

Kind regards.

Correct Object property to print for this API:
image
Swagger print object with same className but different fullPathPackage:
image

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 two response models described in the issue, using the @ApiResponse, @Content, and @Schema(implementation=...) annotations shown. Inspect how nested properties with identical class and JSON property names are resolved across different packages, and verify that the generated Swagger document uses the implementation's correct package-specific type and inheritance.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring-boot
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.