-
-
Notifications
You must be signed in to change notification settings - Fork 549
C# generator: create anoymous types with camel casing (reworked) #1788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for the PR. |
|
@RicoSuter I know, a test would be appropriate But I ran into this issue when consuming a closed source api description, and I don't have enough OpenApi knowledge to build a sample file myself. |
|
doesnt seem to work correctly... Seems that i need to revert. |
|
@RicoSuter According to your diff screenshot, the right side of the code is the expected behaviour, as it eliminates the lower case class names. Or did I have a misunderstanding? |

This is the second attempt to fix RicoSuter/NSwag#4849 and RicoSuter/NSwag#4837 and a followup for #1716: since NSwag 14, the resulting C# file generated from a yaml file might contain lower case class names.
This seems to happen if an array item has as lower case type name hint (e.g. "data"), and a class "Data" was already generated.
In this situation,
DefaultTypeNameGenerator.GenerateAnonymousTypeNamedoes not callConversionUtilities.ConvertToUpperCamelCaseand thus picks the lower case class name "data" as "not used".With my fix, it would generate a class "Data2" again.
The first fix worked locally for me because I had one additional line that I forget to add to my pull request. This request adds this line and removes an unneccesary
ConvertToUpperCamelCasefrom the previous pull request (variabletypeNameHintis already camel cased now).Sorry for the confusion, I had some problems building/running NSwag/NJsonSchema and first added workaround code to my local NSwag copy, then applied it to NJsonSchema, where I lost one important line. But this time I really tested a fixed "NJsonSchema.dll" with NSwag console and can confirm that the generated cs file is valid ;-).