NSwag & Extension Code - How to ensure it's placed at the start of the file?
Okay, I figured it out. For me, there were two issues:
- I had a configurationClass that was actually an interface.
- There were comments above my base class, which is apparently a no-no.
I was running into the same issue and found Matt Grande's solution didn't work for me. So here are a list of things to check which caused my problem.
- Any comment with the word class in it above the base class seem to cause a problem.
- There cannot be any indentation before the start of your class declaration - This either leads to the generator adding your code at the bottom or doing
export export class BaseClass
. (Copying from the docs adds indentation to the file) - Having an interface as your
configrationClass
seems to work but generates the configuration interface at the bottom of the file - This is still valid Typescript.