3

I generated C# code from a Swagger definition and was wondering if there is a configuration parameter to automatically include using statements in the generated files. I found this link https://github.com/RicoSuter/NSwag/wiki/NSwag-Configuration-Document with config-parameters but none of these seems to make the trick. To be more clear, my file at the moment looks like this at the top:

enter image description here

I would like the autogenerated file to include using statements like this:

enter image description here

Any help or tips are very appretiated.

Helen
  • 58,317
  • 8
  • 161
  • 218
K.Oleksiak
  • 275
  • 2
  • 15

1 Answers1

2

In your NSwag configuration, you can set:

"openApiToCSharpClient": {
  ...
  "additionalNamespaceUsages": [
    "RDT.Api.DomainModels"
  ],
  ...
  "namespace": "RDT.Api.Repository",
  ...
}

Alternately, NSwagStudio includes an option 'Additional Namespace Usages'.

NSwagStudio Config

To keep the settings, you can save your .nswag file for future use

N Mead
  • 103
  • 4