1
1
package com .ztianzeng .apidoc ;
2
2
3
- import com .fasterxml .jackson .databind .BeanDescription ;
4
3
import com .thoughtworks .qdox .JavaProjectBuilder ;
5
4
import com .thoughtworks .qdox .model .JavaClass ;
6
5
import com .thoughtworks .qdox .model .JavaField ;
14
13
import com .ztianzeng .apidoc .models .media .PrimitiveType ;
15
14
import com .ztianzeng .apidoc .models .media .Schema ;
16
15
import com .ztianzeng .apidoc .utils .DocUtils ;
17
- import com .ztianzeng .apidoc .utils .Json ;
18
16
import lombok .extern .slf4j .Slf4j ;
19
17
import org .apache .commons .lang3 .StringUtils ;
20
18
@@ -167,9 +165,6 @@ public Schema resolve(AnnotatedType annotatedType,
167
165
}
168
166
169
167
170
- // com.fasterxml.jackson.databind.JavaType targetType = mapper.constructType(annotatedType.getType());
171
- // BeanDescription beanDesc = mapper.getSerializationConfig().introspect(targetType);
172
-
173
168
for (JavaField field : fields ) {
174
169
if (DocUtils .isPrimitive (field .getName ())) {
175
170
continue ;
@@ -192,18 +187,22 @@ public Schema resolve(AnnotatedType annotatedType,
192
187
String name = field .getName ();
193
188
Schema propSchema = new Schema ();
194
189
propSchema .setName (name );
195
-
196
- PrimitiveType primitiveType = PrimitiveType .fromType (field .getType ().getFullyQualifiedName ());
197
- if (primitiveType != null ) {
198
- propSchema = primitiveType .createProperty ();
190
+ // 处理泛型
191
+ if (genericityContentType != null && "T" .equals (field .getType ().getGenericFullyQualifiedName ())) {
192
+ propSchema .set$ref (constructRef (findName (genericityContentType )));
199
193
} else {
200
- propSchema = context .resolve (aType );
201
- if (propSchema != null ) {
202
- if (propSchema .get$ref () == null ) {
203
- if ("object" .equals (propSchema .getType ())) {
204
- // create a reference for the property
205
- if (context .getDefinedModels ().containsKey (typeName )) {
206
- propSchema .set$ref (constructRef (typeName ));
194
+ PrimitiveType primitiveType = PrimitiveType .fromType (field .getType ().getFullyQualifiedName ());
195
+ if (primitiveType != null ) {
196
+ propSchema = primitiveType .createProperty ();
197
+ } else {
198
+ propSchema = context .resolve (aType );
199
+ if (propSchema != null ) {
200
+ if (propSchema .get$ref () == null ) {
201
+ if ("object" .equals (propSchema .getType ())) {
202
+ // create a reference for the property
203
+ if (context .getDefinedModels ().containsKey (typeName )) {
204
+ propSchema .set$ref (constructRef (typeName ));
205
+ }
207
206
}
208
207
}
209
208
}
0 commit comments