'NSwag: Export enums/static lists to typescript generated client
I have a .NET Core project that uses NSwag to generate the typescript HTTP clients to be consumed in a ReactJS project.
Everything works fine when the exposed classes are within the .NET controllers, but in my actual case, I need to export a static list or an enum failing that, which is not in used as any request/response on the controllers, so it's not generated by default.
My list looks like this:
public static readonly List<ProductFormats> WebinarFormats = new List<ProductFormats>() {
ProductFormats.BDCSW,
ProductFormats.WEBNR,
ProductFormats.LIVE,
ProductFormats.BDCST,
ProductFormats.MDCPE,
ProductFormats.BB,
ProductFormats.CH,
ProductFormats.IGT,
ProductFormats.MM,
ProductFormats.TV,
ProductFormats.WC
};
The reason why I need to do this is because I need to consume these values within the ReactJS client and I need them to be regenerated by the NSwag client if those are being changed on the .NET side.
I searched multiple posts, but I couldn't find anything, so I don't know if that's possible.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|