私はOWIN、自己ホストWeb APIプロジェクトを持っており、SwaggerドキュメントとSwagger UIを追加したいと思います。Swashbuckle - BaseControllerを継承するWeb APIコントローラは表示されません
私はSwashbuckle.Coreパッケージを含んでおり、手動で設定しました。Startup.cs
です。
configuration.EnableSwagger(s =>
{
s.SingleApiVersion(Assembly.GetExecutingAssembly().GetName().Version.ToString().Replace('.', ' '), "MyApi").;
s.IncludeXmlComments([email protected]"{System.AppDomain.CurrentDomain.BaseDirectory}\MyApi.XML");
s.DescribeAllEnumsAsStrings();
})
.EnableSwaggerUi(s =>
{
// By default, swagger-ui will validate specs against swagger.io's online validator and display the result
// in a badge at the bottom of the page. Use these options to set a different validator URL or to disable the
// feature entirely.
//c.SetValidatorUrl("http://localhost/validator");
s.DisableValidator();
});
ここでは、ベースコントローラと、ベースから継承する2つの追加コントローラがあります。残念ながら、私はコントローラの名前とアクションがぼんやりしたページに表示されません。ここで
は私のベースコントローラである:
public class BaseController : ApiController
{
public BaseController()
{
// Initialization...
}
public async Task<IHttpActionResult> MyAction()
{
// Code here...
}
}
Controler1:
public class My1Controller : BaseController
{
public MyController1(...): base(...)
{
// Initialization...
}
public async Task<IHttpActionResult> Post(Model1 model)
{
// Code here...
}
public async Task<IHttpActionResult> Post(Model2 model)
{
// Code here...
}
}
コントローラ2:
public class My2Controller : BaseController
{
public My2Controller(...): base(...)
{
// Initialization...
}
public async Task<IHttpActionResult> Post(Model1 model)
{
// Code here...
}
public async Task<IHttpActionResult> Post(Model2 model)
{
// Code here...
}
}
私が闊歩インデックスページでMy1Controller
もMy2Controller
を見ることはできません。私はMy1Controller
とMy2Controller
にApiExplorerSettings(IgnoreApi = true)]
属性を試しましたが、何も起こりませんでした。
コントローラのアクションが共通の名前を共有していますか(複数のパラメータタイプを持つPost
のアクション)?上記の例のようにRPCスタイルのURLを使用しているわけではなく、5レベルのメディアタイプ(5LMT)プロポーザルの次のRESTful URLを使用しています。
提案がありますか?
あなたはベースコントローラからか、ベース&子コントローラからのメソッドが表示されないような方法が表示されていない、あなたの問題の帽子です? – bsoulier
@bsoulier正しい、私はぼんやりとしたドキュメントのページ – gdyrrahitis