I am using Swagger to document my .NET C#
API and when my models are on another project Swagger just crashes and doesn't load anything.
When I load the sample WebAPI
Project from Visual Studio it uses the models that are on the same project and it works:
But when I use Models from other project it just crashes before loading anything.
I have an API project and a Business Project. My models are View Models stored(and shared among other projects, therfore needed there) on my Buisiness Project.
Is there any way I can indicate to Swagger where my model definitions are?
I faced same issue with Swashbuckle 5.6.0 and managed to fixed as follows. Enable XML documentation file on model objects containing project by changing project properties as follows.
Then go to SwaggerConfig.cs file of the api project and add xml comments file of model object project as follows.
c.IncludeXmlComments(string.Format(@"{0}\bin\WebApplication1.XML", System.AppDomain.CurrentDomain.BaseDirectory));
// New code line
c.IncludeXmlComments(string.Format(@"{0}\bin\core.XML", System.AppDomain.CurrentDomain.BaseDirectory));
Now you will have xml comments for model properties on swagger doc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With