Open bhaidar opened 5 years ago
There's a problem with running the generator from the "openapi" context (in CLI)... you need to somehow change the settings/exclude this EF registration when running NSwag from cli
@RicoSuter I am using NSwagStudio and not the command line.
This also uses the cli
@RicoSuter OK thanks.
Can you illustrate more on this pls?
you need to somehow change the settings/exclude this EF registration
When generating via CLI it might not find the appsettings.json and some services might not register correctly. An option is to check whether it's running in the nswag context and not register unnecessary services or use an nswag only startup.cs (a second one), just catch the exception and use that to find out in which context it's running, etc.
I had this same issue when trying to use the LazyCache library - see https://github.com/alastairtree/LazyCache/issues/186. In that case, it turned out to be because LazyCache expects to be the first library to register an IMemoryCache
singleton in its recommended services.AddLazyCache()
call in Startup.cs, whereas the NSwag generation process injects its own IMemoryCache
into the DI container before my Startup.cs is ever called. The workaround in my case was to ensure that LazyCache
gets its own IMemoryCache
instance rather than using the default DI-based setup process: https://github.com/CareTogether/CareTogetherCMS/commit/076200d81c4c8ca868fd9f83c2d8122fd6339ff4
Hi, I have an ASP.NET Core 2.2 Web API app running fine in the browser. When I try to generate Typescript files in NSwagStudio, I get the following errors:
Here's the DbContext I have: