Web API 2 プロジェクトがあります。これは、owin を使用して自己ホストされるように構成されています。global.asax ファイルはありません。Web API のヘルプ ページが必要で、swaschbuckle を使用しています。しかし、rooturl/swagger/docs には出力がありません。
こちらの「 https://github.com/domaindrivendev/Swashbuckle/issues/196 」の指示に従いましたが、まだ機能していません。以下は私の設定コードです
public void Configuration(IAppBuilder app)
{
// Configure DI
container = BuildDI();
// Create the configuration. OWIN Should create a new httpconfiguration.
// GlobalConfiguration can't be used.
HttpConfiguration = new HttpConfiguration();
HttpConfiguration.Formatters.XmlFormatter.UseXmlSerializer = true;
HttpConfiguration.MapHttpAttributeRoutes();
HttpConfiguration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
// Set ServicePointManager properties.
ServicePointManager.ServerCertificateValidationCallback = ((sender, cert, chain, sslPolicyErrors) => true);
// 10 concurrent connections can be made on the service point.
ServicePointManager.DefaultConnectionLimit = 10;
// After the idle time expires, the ServicePoint object is eligible for
// garbage collection and cannot be used by the ServicePointManager object.
ServicePointManager.MaxServicePointIdleTime = 30000; // 30 Seconds.
app.UseSerilogRequestContext("RequestId");
// Middleware is injected form DI.
app.UseAutofacMiddleware(container);
app.UseAutofacWebApi(HttpConfiguration);
//Enable swashbuckle
SwaggerConfig.Register(HttpConfiguration);
// Webapi middleware. Do it at the end.
app.UseWebApi(HttpConfiguration);
// Register callback to dispose container.
RegisterShutdownCallback(app, container);
}
public class SwaggerConfig
{
public static void Register(HttpConfiguration config)
{
config.EnableSwagger(c =>
{
c.RootUrl(rurl => ConfigurationManager.AppSettings["hostUrl"].ToString());
c.IncludeXmlComments(GetXmlCommentsFileLocation());
c.SingleApiVersion("v1", "Isone");
})
.EnableSwaggerUi(c =>
{
});
}
private static string GetXmlCommentsFileLocation()
{
var baseDirectory = AppDomain.CurrentDomain.BaseDirectory + "\\bin";
var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML";
var commentsFileLocation = Path.Combine(baseDirectory, commentsFileName);
return commentsFileLocation;
}
}
コードに間違いがあれば指摘してください。