0

I am working on a project written in French. The classes are named in French. I want to use code generation for a C# client.

[Route("[controller]s")]
public class EtablissementControleur : ControllerBase
{
  ...
}

My api route is good and my swagger documentation is good, because I took care of the translation.

/api/v1/etablissements/{id}/adresse

Here is the partial configuration of the generator

nswag.json

  "codeGenerators": {
    "openApiToCSharpClient": {
      "className": "{controller}HttpService",
...

The name of the generated service is EtablissementControleurHttpService, whereas I was expecting EtablissementHttpService.

    [System.CodeDom.Compiler.GeneratedCode("NSwag", "13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))")]
    public partial class EtablissementControleurHttpService : IEtablissementControleurHttpService
    {

Should I tell the generator to remove the word Controller? Or should I modify the swagger documentation to support it? Thanks for your help

  • If the class name is `EtablissementControleur` then why would you not expect `EtablissementControleurHttpService`?. Your `nswag.json` says `"className": "{controller}HttpService"` and the `{controller}` is `EtablissementControleur`, right? – Chuck Dec 01 '22 at 18:09
  • Does it really make sense to translate the word Controller into French? I would just name the class EtablissementController - the first part I can understand the reason for translating, but `Controller` is almost like a keyword in the context of web api... – DaggeJ Dec 06 '22 at 08:47

0 Answers0