@@ -116,10 +116,13 @@ public Operation customize(Operation operation, HandlerMethod handlerMethod) {
116
116
fieldsToAdd .addAll (aliases );
117
117
fieldsToAdd .addAll (whiteList );
118
118
119
- boolean excludeUnlistedProperties = getFieldValueOfBoolean (bindings , "excludeUnlistedProperties" );
119
+ // if only listed properties should be included, remove all other fields from fieldsToAdd
120
+ if (getFieldValueOfBoolean (bindings , "excludeUnlistedProperties" )) {
121
+ fieldsToAdd .removeIf (s -> !whiteList .contains (s ));
122
+ }
120
123
121
124
for (String fieldName : fieldsToAdd ) {
122
- Type type = getFieldType (fieldName , pathSpecMap , predicate .root (), excludeUnlistedProperties );
125
+ Type type = getFieldType (fieldName , pathSpecMap , predicate .root ());
123
126
if (type != null ) {
124
127
Parameter newParameter = buildParam (type , fieldName );
125
128
parametersToAddToOperation .add (newParameter );
@@ -232,19 +235,18 @@ private Optional<Path<?>> getPathFromPathSpec(Object instance) {
232
235
* Tries to figure out the Type of the field. It first checks the Qdsl pathSpecMap before checking the root class. Defaults to String.class
233
236
* @param fieldName The name of the field used as reference to get the type
234
237
* @param pathSpecMap The Qdsl path specifications as defined in the resolved bindings
235
- * @param root The root type where the paths are gotten
236
- * @param excludeUnlistedProperties the exclude unlisted properties
238
+ * @param root The root type where the paths are gotten
237
239
* @return The type of the field. Returns
238
240
*/
239
- private Type getFieldType (String fieldName , Map <String , Object > pathSpecMap , Class <?> root , boolean excludeUnlistedProperties ) {
241
+ private Type getFieldType (String fieldName , Map <String , Object > pathSpecMap , Class <?> root ) {
240
242
Type genericType = null ;
241
243
try {
242
244
Object pathAndBinding = pathSpecMap .get (fieldName );
243
245
Optional <Path <?>> path = getPathFromPathSpec (pathAndBinding );
244
246
Field declaredField ;
245
247
if (path .isPresent ()) {
246
248
genericType = path .get ().getType ();
247
- } else if (! excludeUnlistedProperties ) {
249
+ } else {
248
250
declaredField = root .getDeclaredField (fieldName );
249
251
genericType = declaredField .getGenericType ();
250
252
}
0 commit comments