RicoSuter/NSwag

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

Open

#2.019 geöffnet am 13. März 2019

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (1.189 Forks)batch import
help wantedproject: NJsonSchema.CodeGenerationproject: NJsonSchema.CodeGeneration.CSharptype: enhancement

Repository-Metriken

Stars
 (6.291 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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