Skip to content

Commit e50758c

Browse files
author
Simon Cardaire
committed
bug fix : filter associationsFields and ignoredFields when exported annotation is set to false
1 parent a714f41 commit e50758c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.springframework.data.mapping.SimpleAssociationHandler;
5757
import org.springframework.data.mapping.context.PersistentEntities;
5858
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
59+
import org.springframework.data.rest.core.mapping.ResourceMapping;
5960
import org.springframework.data.rest.core.mapping.ResourceMappings;
6061
import org.springframework.data.rest.core.mapping.ResourceMetadata;
6162
import org.springframework.data.rest.webmvc.RestMediaTypes;
@@ -417,8 +418,11 @@ private List<String> getAssociationsFields(ResourceMetadata
417418
List<String> associationsFields = new ArrayList<>();
418419
entity.doWithAssociations((SimpleAssociationHandler) association -> {
419420
PersistentProperty<?> property = association.getInverse();
420-
String filedName = resourceMetadata.getMappingFor(property).getRel().value();
421-
associationsFields.add(filedName);
421+
ResourceMapping mapping = resourceMetadata.getMappingFor(property);
422+
if (mapping.isExported()) {
423+
String filedName = mapping.getRel().value();
424+
associationsFields.add(filedName);
425+
}
422426
});
423427
return associationsFields;
424428
}
@@ -438,8 +442,11 @@ private List<String> getIgnoredFields(ResourceMetadata
438442
ignoredFields.add(idField);
439443
entity.doWithAssociations((SimpleAssociationHandler) association -> {
440444
PersistentProperty<?> property = association.getInverse();
441-
String filedName = resourceMetadata.getMappingFor(property).getRel().value();
442-
ignoredFields.add(filedName);
445+
ResourceMapping mapping = resourceMetadata.getMappingFor(property);
446+
if (mapping.isExported()) {
447+
String filedName = mapping.getRel().value();
448+
ignoredFields.add(filedName);
449+
}
443450
});
444451
}
445452
return ignoredFields;

0 commit comments

Comments
 (0)