@@ -206,26 +206,13 @@ protected void _addEnumProps(Class<?> propClass, Property property) {
206206        }
207207    }
208208
209-     private  BeanDescription  fecthAppropriateBeanDescForType (JavaType  type ) {
210-         BeanDescription  beanDesc  = _mapper .getSerializationConfig ().introspect (type );
211-         JsonSerialize  jasonSerialize  = beanDesc .getClassAnnotations ().get (JsonSerialize .class );
212-         if  (jasonSerialize  != null ) {
213-             if  (jasonSerialize .as () != null ) {
214-                 JavaType  asType  = _mapper .constructType (jasonSerialize .as ());
215-                 beanDesc  = _mapper .getSerializationConfig ().introspect (asType );
216-             }
217-         }
218- 
219-         return  beanDesc ;
220-     }
221- 
222209    public  Model  resolve (JavaType  type , ModelConverterContext  context , Iterator <ModelConverter > next ) {
223210        if  (type .isEnumType () || PrimitiveType .fromType (type ) != null ) {
224211            // We don't build models for primitive types 
225212            return  null ;
226213        }
227214
228-         final   BeanDescription  beanDesc  = fecthAppropriateBeanDescForType (type );
215+         BeanDescription  beanDesc  = _mapper . getSerializationConfig (). introspect (type );
229216        // Couple of possibilities for defining 
230217        String  name  = _typeName (type , beanDesc );
231218
@@ -272,6 +259,12 @@ public Model resolve(JavaType type, ModelConverterContext context, Iterator<Mode
272259            context .resolve (type .getContentType ());
273260            return  null ;
274261        }
262+ 
263+         final  ApiModel  apiModel  = beanDesc .getClassAnnotations ().get (ApiModel .class );
264+         if  (apiModel  != null  && StringUtils .isNotEmpty (apiModel .reference ())) {
265+             model .setReference (apiModel .reference ());
266+         }
267+ 
275268        // if XmlRootElement annotation, construct an Xml object and attach it to the model 
276269        XmlRootElement  rootAnnotation  = beanDesc .getClassAnnotations ().get (XmlRootElement .class );
277270        if  (rootAnnotation  != null  && !"" .equals (rootAnnotation .name ()) && !"##default" .equals (rootAnnotation .name ())) {
@@ -284,20 +277,23 @@ public Model resolve(JavaType type, ModelConverterContext context, Iterator<Mode
284277        }
285278        final  XmlAccessorType  xmlAccessorTypeAnnotation  = beanDesc .getClassAnnotations ().get (XmlAccessorType .class );
286279
280+         //If JsonSerialize(as=...) is specified then use that bean to figure out all the json-like bits 
281+         JsonSerialize  jasonSerialize  = beanDesc .getClassAnnotations ().get (JsonSerialize .class );
282+         if  (jasonSerialize  != null ) {
283+             if  (jasonSerialize .as () != null ) {
284+                 JavaType  asType  = _mapper .constructType (jasonSerialize .as ());
285+                 beanDesc  = _mapper .getSerializationConfig ().introspect (asType );
286+             }
287+         }
288+ 
287289        // see if @JsonIgnoreProperties exist 
288290        Set <String > propertiesToIgnore  = new  HashSet <String >();
289291        JsonIgnoreProperties  ignoreProperties  = beanDesc .getClassAnnotations ().get (JsonIgnoreProperties .class );
290292        if  (ignoreProperties  != null ) {
291293            propertiesToIgnore .addAll (Arrays .asList (ignoreProperties .value ()));
292294        }
293295
294-         final  ApiModel  apiModel  = beanDesc .getClassAnnotations ().get (ApiModel .class );
295296        String  disc  = (apiModel  == null ) ? ""  : apiModel .discriminator ();
296- 
297-         if  (apiModel  != null  && StringUtils .isNotEmpty (apiModel .reference ())) {
298-             model .setReference (apiModel .reference ());
299-         }
300- 
301297        if  (disc .isEmpty ()) {
302298            // longer method would involve AnnotationIntrospector.findTypeResolver(...) but: 
303299            JsonTypeInfo  typeInfo  = beanDesc .getClassAnnotations ().get (JsonTypeInfo .class );
0 commit comments