swagger-api / swagger-api/swagger-core
Classes / enums with same name but different package replace each other
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
If your project has two or more classes (also enums) with the same name (but different packages) they replace each other during model definition.
public class MyClass {
private ClassWithSameName classOne;
private subpackge.ClassWithSameName classTwo;
// getters and setters
}
There will only be one generated Schema for ClassWithSameName and both properties point to the same definition. Same problem for enums when they are resolved as refs.
I'm aware of useFqn in TypeNameResolver but this setting affects all names. I'd prefer a solution where the name is only changed in case of a collision.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with TypeNameResolver and the model-definition path that resolves class and enum references. Reproduce the case with same simple names in different packages, then trace how schemas and refs are assigned. Done means colliding names receive distinct definitions while non-colliding names retain their existing naming behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100