question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No differentiation between inner class names

See original GitHub issue

We 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:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
PavelJcommented, Mar 8, 2017

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.

1reaction
frantumacommented, May 4, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found