Skip to content

parameter of type com.querydsl.core.types.Predicate ignored when unique #1522

Closed
@metcox

Description

@metcox

When an operation has a single parameter of type com.querydsl.core.types.Predicate annotated with @QuerydslPredicate, the generated schema does not expose the expected input query param.

Let's say we have the following operation:

@RequestMapping(method = RequestMethod.GET, value = "/operation")
@ResponseBody
public String operation(@QuerydslPredicate(root = MyUser.class) Predicate predicate) {
    return "hi";
}

we get something like

"/auth/operation":
    {"get":{
        "operationId":"operation",
        "responses":{"200":{"content":{"*/*":{"schema":{"type":"string"}}}}}
    }}

With a additional parameter:

@RequestMapping(method = RequestMethod.GET, value = "/operation")
@ResponseBody
public String operation(@QuerydslPredicate(root = MyUser.class) Predicate predicate, String param) {
    return "hi";
}

we get something like

"/auth/operation":
    {"get":{
        "operationId":"operation",
        "parameters":[
            {"name":"param","in":"query","required":true,"schema":{"type":"string"}},
            {"name":"firstName","in":"query","schema":{"type":"string"}}
        ],
        "responses":{"200":{"content":{"*/*":{"schema":{"type":"string"}}}}}
    }}

where firstName is a field of MyUser POJO.

The QuerydslPredicateOperationCustomizer class only customize the operation if parameters are found.

public Operation customize(Operation operation, HandlerMethod handlerMethod) {
if (operation.getParameters() == null) {
return operation;
}

However parameters of type Predicate are ignored

QuerydslPredicateOperationCustomizer queryDslQuerydslPredicateOperationCustomizer(Optional<QuerydslBindingsFactory> querydslBindingsFactory) {
if (querydslBindingsFactory.isPresent()) {
getConfig().addRequestWrapperToIgnore(Predicate.class);
return new QuerydslPredicateOperationCustomizer(querydslBindingsFactory.get());
}
return null;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions