No differentiation between inner class names
See original GitHub issueWe use a lot of static inner classes as a way of grouping together similar, but not identical dtos. For example:
public class CustomerDto {
public static class In {
// fields for saving a new customer
}
public static class Out {
// fields returned when querying a customer.
}
}
public class Address {
public static class In {
//...
}
public static class Out {
//...
}
}
In this case, it looks like the swagger.json is including only one of the In classes (with the reference “#/definitions/In”) and one of the Out classes.
This makes it fairly unusable since the apis using the other In/Out classes have the wrong model.
At the least, could the generation fail if it gets naming conflicts? Right now it’s just silently referencing the wrong model.
I’m using Jersey to generate the swagger.json if that helps/makes a difference.
Thanks.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:11
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Java inner class with the same name as other top level class
I have question related to Java inner classes. Is there a way to access top level class A from top level class Main...
Read more >Difference Between Static and Non Static Nested Class in Java
Nested classes are divided into two categories namely static and non-static. Nested classes that are declared static are called static ...
Read more >Nested Classes - Learning the Java Language
Terminology: Nested classes are divided into two categories: non-static and static. Non-static nested classes are called inner classes. Nested classes that are ...
Read more >Finer points of Java: the difference between nested, inner and ...
A nested inner class is a class that has special access to the members of the enclosing class. A static nested class has...
Read more >Inner class and nested Static Class in Java with Example
Any class which is not a top level or declared inside another class is known as nested class and out of those nested...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have just encountered this behaviour and was really suprised because I would assume that this would be a serious issue. For example I have one User model and have multiple request and response classes for multiple operations with User - each containing only a subset of User’s attributes.
For example I have class CreateUserRequest (in one package) annotated with @JsonRootName(value = “user”) and another class UpdateUsersStateRequest (may be even in the same package) again with annotation @JsonRootName(value = “user”). Swagger definition has only one of those definitions and ignoring others so basically most of the generated examples which I see in swagger UI are wrong.
I would assume that swagger would have different definition for each REST method, am I missing something? It is extremely important to be able to define same object with different attributes in different API methods.
A solution for this issue has been implemented in #2797, check out this comment and related test case, to be able to customize name resolving