Skip to content

Commit e2ab9b8

Browse files
#4781 Jackson/@JsonUnwrapped - when innerModel.$ref not null - unwrapping does not happen
1 parent e8bb595 commit e2ab9b8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
727727
.ctxAnnotations(null)
728728
.jsonUnwrappedHandler(null)
729729
.resolveAsRef(false);
730-
handleUnwrapped(props, context.resolve(t), uw.prefix(), uw.suffix(), requiredProps);
730+
handleUnwrapped(context, props, context.resolve(t), uw.prefix(), uw.suffix(), requiredProps);
731731
return null;
732732
} else {
733733
return new Schema();
@@ -1307,7 +1307,13 @@ protected boolean ignore(final Annotated member, final XmlAccessorType xmlAccess
13071307
return false;
13081308
}
13091309

1310-
private void handleUnwrapped(List<Schema> props, Schema innerModel, String prefix, String suffix, List<String> requiredProps) {
1310+
private void handleUnwrapped(ModelConverterContext context, List<Schema> props, Schema innerModel, String prefix, String suffix, List<String> requiredProps) {
1311+
if (innerModel.get$ref() != null && innerModel.getProperties() == null) {
1312+
Schema resolvedByRef = context.getDefinedModels().get(innerModel.get$ref().substring(21));
1313+
if (resolvedByRef != null) {
1314+
innerModel = resolvedByRef;
1315+
}
1316+
}
13111317
if (StringUtils.isBlank(suffix) && StringUtils.isBlank(prefix)) {
13121318
if (innerModel.getProperties() != null) {
13131319
props.addAll(innerModel.getProperties().values());

0 commit comments

Comments
 (0)