OpenAPITools / OpenAPITools/openapi-generator

[REQ] okhttp-json: provide access to original function name

Open
#17,936 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

Right now, if I call a function like getAPIGroup, there is no easy way to associate this with the HTTP request, unless I walk the stack or similar. For example, when tracing I would like to know the http request originated from this, vs guess based on the resulting path.

Describe the solution you'd like

I typically use okhttp's request tag for this, but it currently used to stash a custom callback.

https://github.com/OpenAPITools/openapi-generator/blob/9f5ec178cba28f445efb5bd5ed6af68e7cae69e4/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java#L1371

one way out could be to have a wrapper whose toString is the calling function, and this wraps the callback to execute.

Then, a simple okhttp filter can tag the value of that.. tag, and know where it came from.

Describe alternatives you've considered

Another way is a synthetic header, and another way is to try to reverse engineer it or walk up the stack (expensive).

Another expensive way is to make a dynamic proxy then trace before going into it openapi.

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated okhttp-gson ApiClient.java reference around line 1371 and examine how the request tag currently stores the custom callback. Determine a concrete way for an HTTP interceptor to access the originating function name without stack walking, then define tests showing that the name is available on the request and remains usable during callback execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.