swagger-api / swagger-api/swagger-codegen-generators
Problem with dashes in header params for c# code generation
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
The current version of swagger code generation is swagger-codegen-cli-3.0.16.jar
I'm using the header param "X-Auth-Token":
parameters:
-name: X-Auth-Token
in: header
description: The authorisation token
required: true
type: string
However, when generating C# .Net Core , it generates this code:
Seems like by mistake in Controller get method, the variable name (which correctly was turned into "xAuthToken") and the original name "X-Auth-Token" should be used there, otherwise the system get a validation exception.
To my ming it should be generated like
public Task Get([Required][FromHeader(Name="X-Auth-Token")] string xAuthToken)
We found the same issue needs to solve for [FromQuery] params
Thank you
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no file or test. Reproduce C# .NET Core generation with the shown X-Auth-Token header parameter and inspect the generated controller output, then repeat for a dashed query parameter. Done means generated [FromHeader(Name="X-Auth-Token")] and [FromQuery] parameters use the sanitized xAuthToken variable while preserving the original wire names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100