openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] [CSharp] Use lowercase string.Join() instead of String.Join()

Open LazaroOnline opened this issue 1 year ago • 1 comments

Bug Report Checklist

  • [v] Have you provided a full/minimal spec to reproduce the issue?
  • [v] Have you validated the input using an OpenAPI validator (example)?
  • [ ] Have you tested with the latest master to confirm the issue still exists?

Not with master, but with the latest released version in npm.

  • [v] Have you searched for related issues/PRs?
  • [v] What's the actual output vs expected output?
Description

In CSharp code generation, there is a build error in generated code due to String.Join function being used with the UpperCase String which is conflicting with a custom String class defined in the generated code (bad practice, but it is out of my control, I didn't define the json schema, just generating code for it), this would not happen if string lowercase was used, since the class names start with UpperCase.

openapi-generator version

openapi-generator-cli version Did set selected version to 7.8.0

Steps to reproduce
openapi-generator-cli generate -g csharp --skip-validate-spec  -i https://raw.githubusercontent.com/PagerDuty/api-schema/5d679f79622d30b767c777be5f2e9787ef21e092/reference/REST/openapiv3.json

In the code generated, if you search the project by "String.Join" with case sensitive search, it will show the invalid code references.

Suggest a fix

When generating code, use always string.Join( with the lowercase s instead of String.Join( with the uppercase S.

LazaroOnline avatar Aug 22 '24 00:08 LazaroOnline

can you please file a PR with the suggested fix?

one workaround is to use the name mapping option to map the model name String to something else:

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#name-mapping

see modelNameMappings

wing328 avatar Aug 22 '24 06:08 wing328