OpenAPITools / OpenAPITools/openapi-generator

C# Client Library when generated through openapi-generator-cli adds two authorization headers

Open
#9,872 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

We have created a microservice using nest js. we are using openapi-generator-cli to generate client sdks. We are using swagger to consume open api definition. We have configured OAuth2 for 'Try it out' on Swagger UI to work with protected routes and also configured bearer Auth using documentbuilder.addOAuth2().addBearerAuth().
While generating client SDK for angular apps, it works perfectly fine -
image
But while generating client SDK in C# dotnet core using "openapi-generator-cli generate -g csharp-netcore -o XYZ/ -i openApi.json --additional-properties packageName=XYZ", we are unable to use it since two authorization headers were added in the generated code. It returns 401 on every API call through client SDK.
image

Open API Generator Version - 2.3.5

https://github.com/OpenAPITools/openapi-generator-cli/issues/394

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

Reproduce the issue with the openApi.json definition and the openapi-generator-cli command using the csharp-netcore generator. Inspect the generated C# SDK's authorization handling with the OAuth2 and bearer authentication configuration, then verify that generated API calls send only the intended authorization header and no longer return 401.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.