Skip to content

Commit a1de9ad

Browse files
committed
Not working if a property of entity contains generic parameters. Fixes #2347
1 parent 3de26a7 commit a1de9ad

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocDataRestUtils.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import org.springframework.data.rest.core.mapping.ResourceMappings;
6060
import org.springframework.data.rest.core.mapping.ResourceMetadata;
6161
import org.springframework.data.rest.webmvc.RestMediaTypes;
62+
import org.springframework.data.util.TypeInformation;
6263
import org.springframework.hateoas.server.LinkRelationProvider;
6364
import org.springframework.util.CollectionUtils;
6465

@@ -118,22 +119,21 @@ public SpringDocDataRestUtils(LinkRelationProvider linkRelationProvider, Reposit
118119
*/
119120
public void customise(OpenAPI openAPI, ResourceMappings mappings, PersistentEntities persistentEntities) {
120121

121-
persistentEntities.getManagedTypes().stream().forEach(typeInformation ->
122-
{
123-
Class domainType = typeInformation.getType();
124-
ResourceMetadata resourceMetadata = mappings.getMetadataFor(domainType);
125-
final PersistentEntity<?, ?> entity = persistentEntities.getRequiredPersistentEntity(domainType);
126-
EntityInfo entityInfo = new EntityInfo();
127-
entityInfo.setDomainType(domainType);
128-
List<String> ignoredFields = getIgnoredFields(resourceMetadata, entity);
129-
if (!repositoryRestConfiguration.isIdExposedFor(entity.getType()))
130-
entityInfo.setIgnoredFields(ignoredFields);
131-
List<String> associationsFields = getAssociationsFields(resourceMetadata, entity);
132-
entityInfo.setAssociationsFields(associationsFields);
133-
entityInoMap.put(domainType.getSimpleName(), entityInfo);
134-
}
135-
);
136-
122+
for (PersistentEntity<?, ? extends PersistentProperty<?>> persistentEntity : persistentEntities) {
123+
TypeInformation<?> typeInformation = persistentEntity.getTypeInformation();
124+
Class domainType = typeInformation.getType();
125+
ResourceMetadata resourceMetadata = mappings.getMetadataFor(domainType);
126+
final PersistentEntity<?, ?> entity = persistentEntities.getRequiredPersistentEntity(domainType);
127+
EntityInfo entityInfo = new EntityInfo();
128+
entityInfo.setDomainType(domainType);
129+
List<String> ignoredFields = getIgnoredFields(resourceMetadata, entity);
130+
if (!repositoryRestConfiguration.isIdExposedFor(entity.getType()))
131+
entityInfo.setIgnoredFields(ignoredFields);
132+
List<String> associationsFields = getAssociationsFields(resourceMetadata, entity);
133+
entityInfo.setAssociationsFields(associationsFields);
134+
entityInoMap.put(domainType.getSimpleName(), entityInfo);
135+
}
136+
137137
openAPI.getPaths().entrySet().stream()
138138
.forEach(stringPathItemEntry -> {
139139
PathItem pathItem = stringPathItemEntry.getValue();

0 commit comments

Comments
 (0)