swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.98k stars 6.03k forks source link

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

Open jamesbar2 opened 6 years ago

jamesbar2 commented 6 years ago
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.

jimschubert commented 6 years ago

@jamesbar2 Sorry I've just seen this issue. My mother passed in September, and I took a hiatus from open source contributions for a while.

I'll try and have a fix for this by tonight or tomorrow night. I agree that, regardless of property naming, constructor parameters should follow Microsoft's naming guidelines. The fix I have in mind will cause constructor parameters to always be generated in camelCase, so if you were to use PascalCase property names or snake_case… it should never affect named constructor args.

However, if your users are doing object initializers, any non-PascalCase change to property naming convention would be a client breaking change.

jimschubert commented 6 years ago

@jamesbar2 I've opened #7519 to fix this bug. I was wondering if you'd have a minute to evaluate the branch?

jamesbar2 commented 6 years ago

@jimschubert I'll check it out now! Sorry to hear about your mom, thanks so much for taking a look a this!