Reputation: 7843
I have been following a number of tutorials including this one on adding Swagger via Swashbuckle.
From various posts, I have changed the following in my startup..
//GlobalConfiguration.Configuration
// .EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API"))
// .EnableSwaggerUi();
HttpConfiguration httpConfig = new HttpConfiguration();
SwaggerConfig.Register(httpConfig);
WebApiConfig.Register(httpConfig, unityContainer);
app.UseWebApi(httpConfig);
And in my SwaggerConfig.cs I have...
//[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
namespace Micromine.MyApp
{
public class SwaggerConfig
{
public static void Register(HttpConfiguration httpConfig)
{
httpConfig
.EnableSwagger(c =>
{
c.RootUrl(req => SwaggerDocsConfig.DefaultRootUrlResolver(req));
c.SingleApiVersion("v1", "MyCompany.MyApp");
c.IncludeXmlComments(string.Format(@"{0}\bin\myapp.xml", System.AppDomain.CurrentDomain.BaseDirectory));
})
.EnableSwaggerUi(c =>
{
});
}
Problem 1.
When I run my app, I have the following root route...
http://localhost/myapp/
Now if I try to browse to the swagger, ie enter
http://localhost/myapp/swagger
it redirects to http://localhost/swagger/ui/index
, ie it does not have myapp
in the path.
Problem 2
If I now manually browse to http://localhost/myapp/swagger/ui/index
, I now get..
Finally, if I manually enter the following...
my routes show up.
Any ideas how I configure this?
Upvotes: 2
Views: 660