OpenAPITools / OpenAPITools/openapi-generator

[REQ][ASPNETCORE]Allow multiple naming conventions

Open
#2,912 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Server: C-Sharp
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

The swagger spec (OAS 3.0) that I use to generate my .NET Core server stubs contains many instances of variable names or attributes with hyphens and/or underscores, e.g., "X-Correlation-Id", "access_token", etc... C# does not allow hyphens in variable names, of course, and so the generator resolves these names to camelCase. This is a problem for me when I use NSwag to generate my client code and the names are, more accurately, resolved to snake_case. As a workaround, I have made a script to be run post-generation which replaces the names to be formatted how I want them.

openapi-generator version

3.3.4

OpenAPI declaration file content or url
Command line used for generation

java -jar .\modules\openapi-generator-cli\target\openapi-generator-cli.jar generate -i " + $jsonFile + " -g aspnetcore -o " + $OutputDir + " -c " + $configFile + " `-t " + $templates

Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

I think allowing for multiple naming conventions in the c# generators could be a great improvement for the sake of flexibility in code generation.

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 the aspnetcore C# generator invoked by the provided openapi-generator CLI command and trace how names such as X-Correlation-Id and access_token are resolved. Reproduce the behavior with an OpenAPI 3.0 declaration, then define and verify how multiple naming conventions should be selected for generated server stubs.

Written by the indexing model from the issue text.

Assessment

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