@@ -116,10 +116,13 @@ public Operation customize(Operation operation, HandlerMethod handlerMethod) {
116116 fieldsToAdd .addAll (aliases );
117117 fieldsToAdd .addAll (whiteList );
118118
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+ }
120123
121124 for (String fieldName : fieldsToAdd ) {
122- Type type = getFieldType (fieldName , pathSpecMap , predicate .root (), excludeUnlistedProperties );
125+ Type type = getFieldType (fieldName , pathSpecMap , predicate .root ());
123126 if (type != null ) {
124127 Parameter newParameter = buildParam (type , fieldName );
125128 parametersToAddToOperation .add (newParameter );
@@ -232,19 +235,18 @@ private Optional<Path<?>> getPathFromPathSpec(Object instance) {
232235 * Tries to figure out the Type of the field. It first checks the Qdsl pathSpecMap before checking the root class. Defaults to String.class
233236 * @param fieldName The name of the field used as reference to get the type
234237 * @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
237239 * @return The type of the field. Returns
238240 */
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 ) {
240242 Type genericType = null ;
241243 try {
242244 Object pathAndBinding = pathSpecMap .get (fieldName );
243245 Optional <Path <?>> path = getPathFromPathSpec (pathAndBinding );
244246 Field declaredField ;
245247 if (path .isPresent ()) {
246248 genericType = path .get ().getType ();
247- } else if (! excludeUnlistedProperties ) {
249+ } else {
248250 declaredField = root .getDeclaredField (fieldName );
249251 genericType = declaredField .getGenericType ();
250252 }
0 commit comments