Skip to content

feat: [OpenAPI] Customize apache request object before invocation#1129

Open
newtork wants to merge 9 commits intomainfrom
intercept-request-openapi-apache
Open

feat: [OpenAPI] Customize apache request object before invocation#1129
newtork wants to merge 9 commits intomainfrom
intercept-request-openapi-apache

Conversation

@newtork
Copy link
Copy Markdown
Contributor

@newtork newtork commented Mar 27, 2026

Allows for runtime customization of request builder object before the ApiClient invocation.

Related:

Example:

  static RptClient forDestination(@Nonnull final Destination destination) {
    final var apiClient = ApiClient.create(destination)
        .withObjectMapper(getDefaultObjectMapper())
+       .withRequestCustomizer(request -> {
+         if(request.getPath().contains("/predict")) {
+           return request.addHeader("Accept-Encoding", "gzip");
+         }
+         return request;
+       });
    return new RptClient(new DefaultApi(apiClient));
  }

@newtork newtork added do not merge Pull request must not be merged please review Request to review a pull request labels Mar 27, 2026
Copy link
Copy Markdown
Member

@Jonas-Isr Jonas-Isr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this! It looks pretty cool and should give us a clean solution to the GZIP problem.

Only one minor comment. Also would be interested in what the others think.

Comment on lines +84 to +86
private static OpenApiResponseListener EMPTY_RESPONSE_LISTENER = r -> {
};
private static UnaryOperator<ClassicRequestBuilder> EMPTY_REQUEST_CUSTOMIZER = r -> r;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Minor)

These 2 could be final I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Pull request must not be merged please review Request to review a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants