swagger-api / swagger-api/swagger-codegen

[C#] Method signatures use incorrect casing when generated since PR #6305

Open
#7,070 3 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

Since Issue #6281 and PR https://github.com/swagger-api/swagger-codegen/pull/6305, the parameters in model constructors are not using the recommended style rules from Microsoft. This creates breaking changes for our users who are using this formatting:

Old:

new Model(argument1: "foo", argument3: "bar")

New:

new Model(Argument1: "foo", Argument3: "bar")

This does not apply to the API method parameters, only model constructor parameters.

Swagger-codegen version

2.3.0

Swagger declaration file content or url
JSON Language Configuration File:
{
    "packageName": "MyApi.Client",
    "apiPackage": "Api"
}

Also, attempting adding "modelPropertyNaming": "camelCase", this provided the desired result for the parameters, but then the models were also named in camelCase.

Command line used for generation
docker run --rm -v /swagger_codegen:/local swaggerapi/swagger-codegen-cli generate -i /v1.json -l csharp -o /local/generated/csharp -c /local/csharp.json
Related issues/PRs

#6281
PR https://github.com/swagger-api/swagger-codegen/pull/6305

Suggest a fix/enhancement

Switch back to using camelCase on the model constructors, per the style guidelines from Microsoft.

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 supplied Docker command, C# configuration, and Swagger input, then inspect the generated model constructors rather than API methods. The change is complete when constructor parameters use camelCase while generated model names retain their existing casing, with coverage for the reported naming behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
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.