|
24 | 24 |
|
25 | 25 | package org.springdoc.core.converters;
|
26 | 26 |
|
| 27 | +import java.lang.reflect.Field; |
27 | 28 | import java.lang.reflect.Modifier;
|
28 | 29 | import java.util.ArrayList;
|
29 | 30 | import java.util.Collection;
|
30 | 31 | import java.util.Collections;
|
31 | 32 | import java.util.Iterator;
|
32 | 33 | import java.util.List;
|
33 | 34 |
|
| 35 | +import com.fasterxml.jackson.annotation.JsonUnwrapped; |
34 | 36 | import com.fasterxml.jackson.databind.JavaType;
|
35 | 37 | import io.swagger.v3.core.converter.AnnotatedType;
|
36 | 38 | import io.swagger.v3.core.converter.ModelConverter;
|
|
39 | 41 | import io.swagger.v3.oas.models.media.ComposedSchema;
|
40 | 42 | import io.swagger.v3.oas.models.media.ObjectSchema;
|
41 | 43 | import io.swagger.v3.oas.models.media.Schema;
|
| 44 | +import org.apache.commons.lang3.reflect.FieldUtils; |
42 | 45 | import org.springdoc.core.providers.ObjectMapperProvider;
|
43 | 46 |
|
44 | 47 | /**
|
@@ -98,6 +101,11 @@ else if (resolvedSchema.getProperties().containsKey(javaType.getRawClass().getSi
|
98 | 101 | public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) {
|
99 | 102 | JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType());
|
100 | 103 | if (javaType != null) {
|
| 104 | + for (Field field : FieldUtils.getAllFields(javaType.getRawClass())) { |
| 105 | + if (field.isAnnotationPresent(JsonUnwrapped.class)) { |
| 106 | + PARENT_TYPES_TO_IGNORE.add(javaType.getRawClass().getSimpleName()); |
| 107 | + } |
| 108 | + } |
101 | 109 | if (chain.hasNext()) {
|
102 | 110 | if (!type.isResolveAsRef() && type.getParent() != null
|
103 | 111 | && PARENT_TYPES_TO_IGNORE.stream().noneMatch(ignore -> type.getParent().getName().startsWith(ignore)))
|
|
0 commit comments