Skip to content

Commit

Permalink
feat: Skip all not jax rs method params if configuration is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
poldinik committed Apr 20, 2024
1 parent 6b171d0 commit 06081cc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ public Supplier<Boolean> apply(ClassInfo classInfo) {
}
});

serverConfig.skipAllNotMethodParameter().ifPresent(skip -> serverEndpointIndexerBuilder.skipAllNotMethodParameter(skip));

if (!serverDefaultProducesHandlers.isEmpty()) {
List<DefaultProducesHandler> handlers = new ArrayList<>(serverDefaultProducesHandlers.size());
for (ServerDefaultProducesHandlerBuildItem bi : serverDefaultProducesHandlers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ public interface ResteasyReactiveServerConfig {
* This value is always resolved relative to {@code quarkus.http.root-path}.
*/
Optional<String> path();
Optional<Boolean> skipAllNotMethodParameter();
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public abstract class EndpointIndexer<T extends EndpointIndexer<T, PARAM, METHOD
private final Function<ClassInfo, Supplier<Boolean>> isDisabledCreator;

private final Predicate<Map<DotName, AnnotationInstance>> skipMethodParameter;
private final boolean skipAllNotMethodParameter;
private SerializerScanningResult serializerScanningResult;

protected EndpointIndexer(Builder<T, ?, METHOD> builder) {
Expand All @@ -262,6 +263,7 @@ protected EndpointIndexer(Builder<T, ?, METHOD> builder) {
this.targetJavaVersion = builder.targetJavaVersion;
this.isDisabledCreator = builder.isDisabledCreator;
this.skipMethodParameter = builder.skipMethodParameter;
this.skipAllNotMethodParameter = builder.skipAllNotMethodParameter;
}

public Optional<ResourceClass> createEndpoints(ClassInfo classInfo, boolean considerApplication) {
Expand Down Expand Up @@ -782,6 +784,19 @@ protected void warnAboutMissUsedBodyParameter(DotName httpMethod, MethodInfo met
+ methodInfo.declaringClass().name() + "#" + methodInfo + "'");
}

private Function<Map<DotName, AnnotationInstance>, Boolean> skipServerParameter(boolean skipAllNotMethodParameter) {
return new Function<Map<DotName, AnnotationInstance>, Boolean>() {
@Override
public Boolean apply(Map<DotName, AnnotationInstance> anns) {
if (skipAllNotMethodParameter) {
return JAX_RS_ANNOTATIONS_FOR_FIELDS.stream()
.noneMatch(dotName -> anns.containsKey(dotName));
}
return false;
}
};
}

protected boolean skipParameter(Map<DotName, AnnotationInstance> anns) {
return skipMethodParameter != null && skipMethodParameter.test(anns);
}
Expand Down Expand Up @@ -1678,6 +1693,7 @@ public boolean handleMultipartForReturnType(AdditionalWriters additionalWriters,
private Function<ClassInfo, Supplier<Boolean>> isDisabledCreator = null;

private Predicate<Map<DotName, AnnotationInstance>> skipMethodParameter = null;
private boolean skipAllNotMethodParameter = false;

public B setMultipartReturnTypeIndexerExtension(MultipartReturnTypeIndexerExtension multipartReturnTypeHandler) {
this.multipartReturnTypeIndexerExtension = multipartReturnTypeHandler;
Expand Down Expand Up @@ -1801,6 +1817,11 @@ public B setSkipMethodParameter(
return (B) this;
}

public B skipAllNotMethodParameter(boolean skipAllNotMethodParameter){
this.skipAllNotMethodParameter = skipAllNotMethodParameter;
return (B) this;
}

public abstract T build();
}

Expand Down

0 comments on commit 06081cc

Please sign in to comment.