I have an ASP.NET Core MVC application, targeting the .NET Core 2.1 framework. This application serves a RESTful API and returns JSON data.
Using the interactive, web-based SwaggerGen in SwaggerHub, I've created an API definition document and saved it in JSON format as 'swagger.json' in a folder in my ASP.NET Core MVC application project.
Since I've already defined the API, I don't need to run SwaggerGen in my application. I'd just like SwaggerUI to display the static 'swagger.json' file I've created.
I've read the Swashbuckle documentation as well as several "How to get started with Swashbuckle" tutorials, but they all assume that SwaggerGen will be used to dynamically create the Swagger API documentation from my API.
I've added the 'Swashbuckle.AspNetCore' NuGet package to my application's dependencies.
In the Configure() method in my application's Startup.cs class, I've added the UseSwaggerUI directive:
app.UseSwaggerUI(c => {
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
When I run my application in Visual Studio, I get a normal blank page.
Per the Swashbuckle documentation, the SwaggerUI-formatted API documentation should be available at the relative '/swagger' path, assuming that SwaggerGen had been added and had dynamically generated the API definition (file?).
GETting the relative '/swagger' path produces a '400 Bad Request' error.
Q: Would SwaggerGen produce its own 'swagger.json' file, and if so, where would it create this file?
Q: Is there a way to tell SwaggerUI where to find and display my manually created 'swagger.json' API definition file?
Thanks!




Why would you want to do this?Swashbuckle is a sledgehammer to fix a swiss watch. Why use that? was that the "easy" NuGet package option? - Helder Sepulveda