OpenAPITools / OpenAPITools/openapi-generator

[REQ][GO] Allow customization of debug output in generated client

Open
#16,081 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.

When creating a client with the debug flag enabled, the callApi calls httputil.DumpRequestOut. However, there is currently no mechanism to override or customize the way the debug output is handled. This limitation can be problematic if there is a need to hide sensitive information, such as tokens from HTTP headers.

Describe the solution you'd like

  • In the configuration file, introduce a new field called "RequestDebug" (or any other appropriate name).
  • If the "RequestDebug" field is not set, the NewAPIClient function can initialize a default value, which calls httputil.DumpRequestOut for debug output.

Describe alternatives you've considered

Alternatively, instead of relying on the debug flag in the client generated by openapi-generator, it is possible to override the HTTP client in the client code. By hooking into the RoundTrip function, similar to what is done in terraform-plugin-sdk, custom logging can be performed. This approach provides more flexibility and control over the debug output handling.

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 modules/openapi-generator/src/main/resources/go/client.mustache, especially callApi and NewAPIClient, then read configuration.mustache around the proposed configuration field. Trace how generated Go clients handle the debug flag and verify that the completed change preserves the default httputil.DumpRequestOut behavior while allowing callers to customize or redact debug output.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.