Skip to content

When using @Fields and @Page together, the pagination and sorting fields are not returned #490

@matteociasco

Description

@matteociasco

Basically the title of the issue, but i will give a brief explaination.

I have a controller with an end-point:

@Fields
@GetMapping
@PreAuthorize("hasAuthority('employees:view')")
public Page<UserDto> findAll(@Filter(parameter = "q") FilterSpecification<User> filter, @com.turkraft.springfilter.boot.Page Pageable pageable) {
    return entityService.findAll(filter, pageable).map(userMapper::toDto);
}

There are two major problems:

  1. Since i'm using the jpa Page, the result i in the content node of the response, so i need to pass content.name if i only want the name of the users
  2. The pagination and sorting params are not returned in the response

Here a screenshot of Postman without the fields paramether and as tou can see all the sorgint and paging parameters are returned:

Image

Here a screenshot of Postman with the same request and the fields parameter passed to the request:

Image

As you can see, i need to pass content.* and also the sorting and pating parameters are not present in the response.

Also as a side note, if i try to filter with a "in" -> name in ('Matteo','Tommaso') as shown in the swagger auto implementation of this library:

Image

The filter does not get recognized and i receive an error:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: com.turkraft.springfilter.parser.InvalidSyntaxException: mismatched input ',' expecting {<EOF>, INFIX_OPERATOR, POSTFIX_OPERATOR}] with root cause
com.turkraft.springfilter.parser.InvalidSyntaxException: mismatched input ',' expecting {<EOF>, INFIX_OPERATOR, POSTFIX_OPERATOR}
	at com.turkraft.springfilter.parser.ThrowingErrorListener.syntaxError(ThrowingErrorListener.java:16)
	at com.turkraft.springfilter.shaded.org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
	at com.turkraft.springfilter.shaded.org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)
	at com.turkraft.springfilter.shaded.org.antlr.v4.runtime.DefaultErrorStrategy.reportInputMismatch(DefaultErrorStrategy.java:327)
	at com.turkraft.springfilter.shaded.org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:139)
	at com.turkraft.springfilter.parser.AntlrFilterParser.filter(AntlrFilterParser.java:154)
	at com.turkraft.springfilter.parser.FilterParserImpl.parse(FilterParserImpl.java:38)
	at com.turkraft.springfilter.converter.FilterStringConverterImpl.convert(FilterStringConverterImpl.java:44)
	at com.turkraft.springfilter.converter.FilterStringConverter.convert(FilterStringConverter.java:13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions