38
38
import io .swagger .v3 .oas .models .media .StringSchema ;
39
39
import org .apache .commons .lang3 .ArrayUtils ;
40
40
import org .apache .commons .lang3 .StringUtils ;
41
+ import org .slf4j .Logger ;
42
+ import org .slf4j .LoggerFactory ;
41
43
42
44
@ SuppressWarnings ({ "rawtypes" })
43
45
public class SpringDocAnnotationsUtils extends AnnotationsUtils {
44
46
47
+ private static final Logger LOGGER = LoggerFactory .getLogger (SpringDocAnnotationsUtils .class );
48
+
49
+ private static final String GRACEFUL_EXCEPTION_OCCURRED = "Graceful exception occurred" ;
50
+
45
51
public static Schema resolveSchemaFromType (Class <?> schemaImplementation , Components components ,
46
52
JsonView jsonView , Annotation [] annotations ) {
47
53
Schema schemaObject = extractSchema (components , schemaImplementation , jsonView , annotations );
@@ -55,9 +61,16 @@ public static Schema resolveSchemaFromType(Class<?> schemaImplementation, Compon
55
61
56
62
public static Schema extractSchema (Components components , Type returnType , JsonView jsonView , Annotation [] annotations ) {
57
63
Schema schemaN = null ;
58
- ResolvedSchema resolvedSchema = ModelConverters .getInstance ()
59
- .resolveAsResolvedSchema (
60
- new AnnotatedType (returnType ).resolveAsRef (true ).jsonViewAnnotation (jsonView ).ctxAnnotations (annotations ));
64
+ ResolvedSchema resolvedSchema = null ;
65
+ try {
66
+ resolvedSchema = ModelConverters .getInstance ()
67
+ .resolveAsResolvedSchema (
68
+ new AnnotatedType (returnType ).resolveAsRef (true ).jsonViewAnnotation (jsonView ).ctxAnnotations (annotations ));
69
+ }
70
+ catch (Exception e ) {
71
+ LOGGER .error (GRACEFUL_EXCEPTION_OCCURRED , e );
72
+ return new StringSchema ();
73
+ }
61
74
if (resolvedSchema .schema != null ) {
62
75
schemaN = resolvedSchema .schema ;
63
76
Map <String , Schema > schemaMap = resolvedSchema .referencedSchemas ;
@@ -167,7 +180,7 @@ private static MediaType getMediaType(Schema schema, Components components, Json
167
180
return mediaType ;
168
181
}
169
182
170
- private static boolean isArray (io .swagger .v3 .oas .annotations .media .Content annotationContent ){
183
+ private static boolean isArray (io .swagger .v3 .oas .annotations .media .Content annotationContent ) {
171
184
Class <?> schemaImplementation = annotationContent .schema ().implementation ();
172
185
boolean isArray = false ;
173
186
if (schemaImplementation == Void .class ) {
0 commit comments