From e2ab9b813736eeae3a53ae8a459616585e61071d Mon Sep 17 00:00:00 2001 From: Miron Balcerzak Date: Fri, 15 Nov 2024 21:01:39 +0100 Subject: [PATCH] #4781 Jackson/@JsonUnwrapped - when innerModel.$ref not null - unwrapping does not happen --- .../java/io/swagger/v3/core/jackson/ModelResolver.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java b/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java index 7b6b7cefa9..d7bb2202c5 100644 --- a/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java +++ b/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java @@ -727,7 +727,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context .ctxAnnotations(null) .jsonUnwrappedHandler(null) .resolveAsRef(false); - handleUnwrapped(props, context.resolve(t), uw.prefix(), uw.suffix(), requiredProps); + handleUnwrapped(context, props, context.resolve(t), uw.prefix(), uw.suffix(), requiredProps); return null; } else { return new Schema(); @@ -1307,7 +1307,13 @@ protected boolean ignore(final Annotated member, final XmlAccessorType xmlAccess return false; } - private void handleUnwrapped(List props, Schema innerModel, String prefix, String suffix, List requiredProps) { + private void handleUnwrapped(ModelConverterContext context, List props, Schema innerModel, String prefix, String suffix, List requiredProps) { + if (innerModel.get$ref() != null && innerModel.getProperties() == null) { + Schema resolvedByRef = context.getDefinedModels().get(innerModel.get$ref().substring(21)); + if (resolvedByRef != null) { + innerModel = resolvedByRef; + } + } if (StringUtils.isBlank(suffix) && StringUtils.isBlank(prefix)) { if (innerModel.getProperties() != null) { props.addAll(innerModel.getProperties().values());