Skip to content

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

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

feat: [OpenAPI] Customize apache request object before invocation#1129
newtork wants to merge 21 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));
  }

New methods:

+ ApiClient#withRequestCustomizer( UnaryOperator<ClassicRequestBuilder> )

@newtork newtork added do not merge Pull request must not be merged please review Request to review a pull request labels Mar 27, 2026
Jonas-Isr
Jonas-Isr previously approved these changes 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.

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

@rpanackal rpanackal left a comment

Choose a reason for hiding this comment

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

I tried different approaches that is more focused at modifying BaseApi class to achieve the same. But its either breaking, requires modifications to generated code or a lot of new public.

So, I think this is a great way to do this.

@newtork
Copy link
Copy Markdown
Contributor Author

newtork commented Mar 31, 2026

An alternative approach (with a less generic approach) is being discussed here:
#1130

@newtork newtork added do not merge Pull request must not be merged and removed please merge Request to merge a pull request labels Apr 9, 2026
@newtork
Copy link
Copy Markdown
Contributor Author

newtork commented Apr 9, 2026

Looks like we're preferring #1130 over this

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.

3 participants