私はSwashbucklまたはSwaggerの新機能ですが、クライアントからSwaggerを使用してドキュメントを作成する必要があるWeb APIを作成しました。私は既に作成しましたが、APIバージョンの詳細をSwageer UIに表示する必要がありますが、これはどのように達成するかわかりません。SwashbuckleにAPIの説明を追加するにはどうすればよいですか?
public class SwaggerConfig
{
public static void Register()
{
var thisAssembly = typeof(SwaggerConfig).Assembly;
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "Demo Api");
c.IncludeXmlComments(string.Format(@"{0}\bin\WebApi.XML",
System.AppDomain.CurrentDomain.BaseDirectory));
})
.EnableSwaggerUi();
}
}
コントローラ例:
は、ここに私のコードです
/// <summary>
/// Get the Next IdKey
/// </summary>
/// <remarks>Get the Next IdKey from Dettagli Table</remarks>
/// <response code="404">Not found</response>
/// <response code="500">Internal Server Error</response>
[HttpGet]
public int GetNextIdDettagli()
{
try
{
DettagliRepo repo = new DettagliRepo();
return repo.GetNextIdDettagli();
}
catch (Exception ex)
{
throw (ex);
}
}
これは、コントローラのすべてのアクションが行われている方法です。ここで
は私の闊歩UIの出力です:
これは、1,2および3でマークされた私のクライアントからの期待出力されます:
私は理解することができますスクリーンショットから、APIの説明、タイトル、その他の情報が表示されることを望んでいますが、それらを表示する方法はわかりません。私を助けてください、私はその部分をどのように達成するのですか?前もって感謝します。
私は次のコードでFollowing link
から1と2を達成した
更新:
.EnableSwagger(c =>
{
c.RootUrl(req => GetRootUrlFromAppConfig());
c.Schemes(new[] { "http", "https" });
c.SingleApiVersion("v1", "Swashbuckle.Dummy")
.Description("A sample API for testing and prototyping Swashbuckle features")
.TermsOfService("Some terms")
.Contact(cc => cc
.Name("Some contact")
.Url("http://tempuri.org/contact")
.Email("[email protected]"))
.License(lc => lc
.Name("Some License")
.Url("http://tempuri.org/license"));
});
しかし、それでもまだ、私はポイント3感謝のために助けが必要。
が、これは私をたくさん助けたありがとうございました。 – barsan