OpenAPITools / OpenAPITools/openapi-generator

[REQ] Not able to exclude headers as parameters

Open
#8,723 7 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Retrofit 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.

We use the Kotlin-Retrofit-Coroutines to generate the sources based on the OpenApi specs. But in our manually generated code-base, we use for the headers OkHttp Interceptors, that way we don't have to supply in each call all the required headers.

But it does not seem to be a way to avoid generating those headers. We tried to download the Retrofit template and remove the {{>headerParams}} block: this ends up not adding the headers but it keeps all the "," for parameters separation:

Screenshot 2021-02-16 at 11 45 30

Describe the solution you'd like

A way to avoid adding the header parameters to the generated endpoints

Describe alternatives you've considered

When manually removing {{>headerParams}} from the template it just works fine without keeping the "," leftovers

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/kotlin-client/libraries/jvm-retrofit2/api.mustache and inspect how headerParams and parameter separators are rendered. Check the generated endpoint output when header parameters are excluded. Done means a supported way to omit those headers without leftover commas or invalid parameter lists.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
api, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.