Skip to content

Commit

Permalink
@QuerydslPredicate(root = X.class) annotation at Controller Method le…
Browse files Browse the repository at this point in the history
…vel not getting documented in Spring Boot 3. Fixes #2326
  • Loading branch information
bnasslahsen committed Aug 6, 2023
1 parent cdde2ac commit f1ac0b4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.Optional;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.querydsl.core.types.Predicate;
import io.swagger.v3.core.converter.ModelConverter;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.models.Components;
Expand Down Expand Up @@ -63,6 +64,7 @@
import org.springdoc.core.customizers.OpenApiCustomizer;
import org.springdoc.core.customizers.OperationCustomizer;
import org.springdoc.core.customizers.PropertyCustomizer;
import org.springdoc.core.customizers.QuerydslPredicateOperationCustomizer;
import org.springdoc.core.customizers.RouterOperationCustomizer;
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
import org.springdoc.core.customizers.SpringDocCustomizers;
Expand Down Expand Up @@ -110,6 +112,7 @@
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.querydsl.binding.QuerydslBindingsFactory;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -617,4 +620,29 @@ public SpringDocCustomizers springDocCustomizers(Optional<List<OpenApiCustomizer
dataRestRouterOperationCustomizers,
methodFilters, globalOpenApiCustomizers, globalOperationCustomizers, globalOpenApiMethodFilters);
}

/**
* The type Querydsl provider.
* @author bnasslashen
*/
@ConditionalOnClass(value = QuerydslBindingsFactory.class)
static class QuerydslProvider {

/**
* Query dsl querydsl predicate operation customizer querydsl predicate operation customizer.
*
* @param querydslBindingsFactory the querydsl bindings factory
* @return the querydsl predicate operation customizer
*/
@Bean
@ConditionalOnMissingBean
@Lazy(false)
QuerydslPredicateOperationCustomizer queryDslQuerydslPredicateOperationCustomizer(Optional<QuerydslBindingsFactory> querydslBindingsFactory) {
if (querydslBindingsFactory.isPresent()) {
getConfig().addRequestWrapperToIgnore(Predicate.class);
return new QuerydslPredicateOperationCustomizer(querydslBindingsFactory.get());
}
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,29 +240,4 @@ SpringDocDataRestUtils springDocDataRestUtils(LinkRelationProvider linkRelationP
}
}

/**
* The type Querydsl provider.
* @author bnasslashen
*/
@ConditionalOnClass(value = { QuerydslBindingsFactory.class })
class QuerydslProvider {

/**
* Query dsl querydsl predicate operation customizer querydsl predicate operation customizer.
*
* @param querydslBindingsFactory the querydsl bindings factory
* @return the querydsl predicate operation customizer
*/
@Bean
@ConditionalOnMissingBean
@Lazy(false)
QuerydslPredicateOperationCustomizer queryDslQuerydslPredicateOperationCustomizer(Optional<QuerydslBindingsFactory> querydslBindingsFactory) {
if (querydslBindingsFactory.isPresent()) {
getConfig().addRequestWrapperToIgnore(Predicate.class);
return new QuerydslPredicateOperationCustomizer(querydslBindingsFactory.get());
}
return null;
}
}

}

0 comments on commit f1ac0b4

Please sign in to comment.