You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class ViewStructureShared {
private long id;
private long viewId;
private List<ViewStructureShared> children;
private String title;
private Long categoryId;
private Long tagId;
private short order;
private boolean global;
}
Swagger generates right response for this endpoint:
public Schema resolve(AnnotatedType type) {
if (processedTypes.contains(type)) {
return modelByType.get(type);
} else {
processedTypes.add(type);
}
In first case we have two different annotated types (by AnnotatedType.getType() method): sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl for returned object in controller and com.fasterxml.jackson.databind.type.CollectionType for List<ViewStructureShared> in ViewStructureShared.
But in second we have both identical (by equals method) com.fasterxml.jackson.databind.type.CollectionType,
therefore, this code omits this processing and no children anymore, as I understand it, this is done to protect against recursion. But specifically, this example should work.
There is one hack that will help children - specify a different type of collection, for example Collection instead of List:
I used latest swagger 2.1.2, spring doc 1.3.1 and spring boot mvc 2.2.6.
I have a method that returns data in a hierarchical structure:
ViewStructureShared
model:Swagger generates right response for this endpoint:
But, if response wrapper appears, then everything changes.
ActionResult response wrapper structure:
then swagger generates this schema model:
no more
children
field in schema.Why is everything fine in the first case, but everything breaks in the second? I tried to figure it out.
The problem is here.
In first case we have two different annotated types (by AnnotatedType.getType() method):
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
for returned object in controller andcom.fasterxml.jackson.databind.type.CollectionType
forList<ViewStructureShared>
inViewStructureShared
.But in second we have both identical (by equals method)
com.fasterxml.jackson.databind.type.CollectionType
,therefore, this code omits this processing and no children anymore, as I understand it, this is done to protect against recursion. But specifically, this example should work.
There is one hack that will help
children
- specify a different type of collection, for exampleCollection
instead ofList
:but this is not the right decision
The text was updated successfully, but these errors were encountered: