@@ -118,6 +118,8 @@ public class ModelResolver extends AbstractModelConverter implements ModelConver
118
118
119
119
public static boolean composedModelPropertiesAsSibling = System .getProperty (SET_PROPERTY_OF_COMPOSED_MODEL_AS_SIBLING ) != null ;
120
120
121
+ private static final int SCHEMA_COMPONENT_PREFIX = "#/components/schemas/" .length ();
122
+
121
123
/**
122
124
* Allows all enums to be resolved as a reference to a scheme added to the components section.
123
125
*/
@@ -727,7 +729,11 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
727
729
.ctxAnnotations (null )
728
730
.jsonUnwrappedHandler (null )
729
731
.resolveAsRef (false );
730
- handleUnwrapped (props , context .resolve (t ), uw .prefix (), uw .suffix (), requiredProps );
732
+ Schema innerModel = context .resolve (t );
733
+ if (StringUtils .isNotBlank (innerModel .get$ref ())) {
734
+ innerModel = context .getDefinedModels ().get (innerModel .get$ref ().substring (SCHEMA_COMPONENT_PREFIX ));
735
+ }
736
+ handleUnwrapped (props , innerModel , uw .prefix (), uw .suffix (), requiredProps );
731
737
return null ;
732
738
} else {
733
739
return new Schema ();
@@ -2278,7 +2284,7 @@ protected void resolveDiscriminatorProperty(JavaType type, ModelConverterContext
2278
2284
if (StringUtils .isNotBlank (typeInfoProp )) {
2279
2285
Schema modelToUpdate = model ;
2280
2286
if (StringUtils .isNotBlank (model .get$ref ())) {
2281
- modelToUpdate = context .getDefinedModels ().get (model .get$ref ().substring (21 ));
2287
+ modelToUpdate = context .getDefinedModels ().get (model .get$ref ().substring (SCHEMA_COMPONENT_PREFIX ));
2282
2288
}
2283
2289
if (modelToUpdate .getProperties () == null || !modelToUpdate .getProperties ().keySet ().contains (typeInfoProp )) {
2284
2290
Schema discriminatorSchema = new StringSchema ().name (typeInfoProp );
0 commit comments