|
@@ -9,6 +9,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
import org.springframework.core.annotation.AnnotationUtils;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.ReflectionUtils;
|
|
|
import springfox.documentation.builders.ModelPropertyBuilder;
|
|
|
import springfox.documentation.schema.Annotations;
|
|
|
import springfox.documentation.spi.DocumentationType;
|
|
@@ -86,7 +87,26 @@ public class SwaggerDisplayConfig implements ModelPropertyBuilderPlugin {
|
|
|
|
|
|
|
|
|
final List<String> displayValues = Arrays.stream(subItemRecords).filter(Objects::nonNull).map(item -> {
|
|
|
- return item.toString() ;
|
|
|
+ String typeName = swaggerDisplayEnum.type();
|
|
|
+ String descName = swaggerDisplayEnum.desc();
|
|
|
+
|
|
|
+ Object type = null;
|
|
|
+ Object desc = null;
|
|
|
+
|
|
|
+ Field typeField = ReflectionUtils.findField(item.getClass(), typeName);
|
|
|
+ if (typeField != null) {
|
|
|
+ ReflectionUtils.makeAccessible(typeField);
|
|
|
+ type = ReflectionUtils.getField(typeField, item);
|
|
|
+ }
|
|
|
+
|
|
|
+ Field descField = ReflectionUtils.findField(item.getClass(), descName);
|
|
|
+ if (descField != null) {
|
|
|
+ ReflectionUtils.makeAccessible(descField);
|
|
|
+ desc = ReflectionUtils.getField(descField, item);
|
|
|
+ }
|
|
|
+ type = type == null ? "" : type;
|
|
|
+ desc = desc == null ? "" : desc;
|
|
|
+ return type + ":" + desc;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
|
String joinText = " (" + String.join("; ", displayValues) + ")";
|
|
@@ -103,7 +123,6 @@ public class SwaggerDisplayConfig implements ModelPropertyBuilderPlugin {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public boolean supports(DocumentationType documentationType) {
|
|
|
return true;
|