RicoSuter/NSwag

Generation of c# client from .net core api does not have correct casing for some names

Open

#2,019 opened on Mar 13, 2019

View on GitHub
 (3 comments) (0 reactions) (0 assignees)C# (1,189 forks)batch import
help wantedproject: NJsonSchema.CodeGenerationproject: NJsonSchema.CodeGeneration.CSharptype: enhancement

Repository metrics

Stars
 (6,291 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

We have a .net core api and are generating a c# client with nswag run nswag.json. In a specific case where a property name or parameter name is IPAddress, the resulting c# name will sometimes be iPaddress or IpAddress, I also saw class names were IPAddress which i guess would be correct. In general, 2 letter acronyms (i.e. System.IO) would be capitalized (or both lowercase if using camel casing for property name?). The swagger ui and document in the api are correctly doing this, but the c# client seems to have some weirdness, so I wanted to find if there is a way to address this in the client? maybe an override looking for this specific name?

startup code:

var assembly = typeof(Startup).GetTypeInfo().Assembly; app.UseSwaggerUi3WithApiExplorer( settings => { settings.GeneratorSettings.DefaultEnumHandling = EnumHandling.String; settings.GeneratorSettings.DefaultPropertyNameHandling = PropertyNameHandling.CamelCase; settings.GeneratorSettings.Title = "Zywave.Shared.Mail"; settings.GeneratorSettings.Version = StringFormatter.ModelFormatInvariant("v{Major}.{Minor}", assembly.GetName().Version); settings.DocExpansion = "none"; settings.PostProcess = swaggerDocument => swaggerDocument.Schemes.Add(SwaggerSchema.Https); settings.SwaggerRoute = "/swagger.json"; });

and our nswag.json is attached.

NSwagContracts.CSharp_content_nswag.json.txt

Contributor guide