swagger-api / swagger-api/swagger-codegen

[C#] Wierd names when generating clients

Open
#12,122 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I'm using Swagger to generate my definition, and then i consume this using c# code-gen.

The issue i have is that the parameter names of controller functions end up wierd: SelectGenericModelQuery_1OfOfArticleViewModelAndApplicationAnd_0AndCulture_neutralAndPublicKeyToken_null

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v11.0.0.0))")]
 public partial class **SelectGenericModelQuery_1OfOfArticleViewModelAndApplicationAnd_0AndCulture_neutralAndPublicKeyToken_null**
 {
     [Newtonsoft.Json.JsonProperty("filter", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
     public System.Collections.Generic.IDictionary<string, object> Filter { get; set; }

     [Newtonsoft.Json.JsonProperty("pageNumber", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
     public int PageNumber { get; set; }

     [Newtonsoft.Json.JsonProperty("pageSize", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
     public int PageSize { get; set; }

 }

My controller endpoint looks like this:
image

Swagger definition:
image

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 by reproducing the C# client generation from the Swagger definition shown in the issue and inspect how the controller parameter type becomes the generated class name. Compare the generated name with the intended name and identify the relevant code-generation entry point; done means the generated client uses stable, readable parameter names without regressing other C# models.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.