Closed deepakkumpala closed 5 years ago
UseSwaggerWithApiExplorer is deprectated, you should use AddOpenApiDocument(), UseSwagger() and UseSwaggerUi3()
It works when I add below code
app.UseSwagger(); // registers the two documents in separate routes
app.UseSwaggerUi3(); // registers a single Swagger UI (v3) with the two documents
But it fails and hows error Fetch error undefined undefined as below when I add code as shown below
// Add Swagger 2.0 document serving middleware
app.UseSwagger(options =>
{
options.DocumentName = "swagger";
options.Path = "/swagger/v1/swagger.json";
});
// Add web UIs to interact with the document
app.UseSwaggerUi3(options =>
{
// Define web UI route
options.Path = "/swagger";
// Define OpenAPI/Swagger document route (defined with UseSwaggerWithApiExplorer)
options.DocumentPath = "/swagger/v1/swagger.json";
});
app.UseReDoc(options =>
{
options.Path = "/redoc";
options.DocumentPath = "/swagger/v1/swagger.json";
});
// app.UseSwaggerUi3(); // registers a single Swagger UI (v3) with the two documents
app.UseSwaggerUi3(options =>
{
// Add multiple OpenAPI/Swagger documents to the Swagger UI 3 web frontend
options.SwaggerRoutes.Add(new SwaggerUi3Route("Swagger", "/swagger/v1/swagger.json"));
// Define web UI route
options.Path = "/swagger_all";
});
What exactly is these lines? do I have to create file entitled swagger.json some where in project folder?
I think in your case the DocumentName in UseSwagger is wrong:
options.DocumentName = "swagger";
it must match the document name registered in AddSwaggerDocument (default: "v1")
Please, update this article. Few days later a method is now obsolete. It is very difficult to first use this toolchain with this gap between package and examples.
Article is updated, thanks @daveabrock :-)
I am using .NET Core2.1 to developer Web API
I have added Nuget - NSwag.AspNetCore