NSwag: a clear steps and clean sample on how to use class extensions in NSwag studio

828 Views Asked by At

There are not clear documentation on how to extend the auto-generated TS file using NSwag. I mean the extension methods with a protector access modifier

here a discussion with the NSwag's owner:

https://github.com/RicoSuter/NSwag/issues/1012

but there is some uncertainty among the steps followed. especially in the case when adding a static suffix and/or prefix to the controller's name.

Can someone provide a clear explanation of how can we extend the auto-generated methods?

1

There are 1 best solutions below

0
On

Finally, the correct convention to extend the auto-generated classes with prefixes and/or suffixes is to follow the rule as below

  { prefixIfExists} + {classname} + {suffixIfExists} extends generated.{classnameOnly} {

}

Example:

enter image description here

class FilesApplicationsManagerService extends generated.FilesApplicationsManager {
}