管理者と一般ユーザのための異なるドキュメントを生成します。しかし、私は管理者だけが利用できるいくつかのエンドポイントを持っています。あなたの下には例が見えます。闊歩は、私は現在、私の解決策は、各エンドポイントの闊歩ドキュメントを生成するために設定している
正規のユーザーがモデルを作成することができ、しかし、唯一の管理者は、データベース内のすべての単一のモデルを引くことができます。
課題は、闊歩ドキュメントの2セットを生成するのですか? 1つは通常のユーザーが見ることができ、もう1つはAdminユーザーが参照できるドキュメントです。私は、[ApiExplorerSettings(IgnoreApi = true)]をエンドポイントに追加すると生成されるドキュメントには表示されませんが、これは管理者ユーザーがドキュメントの重要な部分を見ることができなくなることを意味します。ユーザーに応じて2つのドキュメントセットを動的に生成する方法に関する推奨事項は役に立ちます。以下
[SwaggerResponse((int)System.Net.HttpStatusCode.OK, Type = typeof(RestOkResponse<PackageResponse>))]
[SwaggerResponse((int)System.Net.HttpStatusCode.InternalServerError, Type = typeof(RestErrorResponse))]
[SwaggerResponse((int)System.Net.HttpStatusCode.BadRequest, Type = typeof(RestErrorResponse))]
[SwaggerResponse((int)System.Net.HttpStatusCode.Forbidden, Type = typeof(RestErrorResponse))]
[SwaggerResponse((int)System.Net.HttpStatusCode.NotFound)]
[HttpPost("/v1/packages")]
[Authorize()]
public async Task<IActionResult> CreateModel([FromBody]Request request)
{
...
}
方法は、管理者のためのものである:
[SwaggerResponse((int)System.Net.HttpStatusCode.OK, Type = typeof(RestOkResponse<PackageResponse>))]
[SwaggerResponse((int)System.Net.HttpStatusCode.InternalServerError, Type = typeof(RestErrorResponse))]
[SwaggerResponse((int)System.Net.HttpStatusCode.BadRequest, Type = typeof(RestErrorResponse))]
[SwaggerResponse((int)System.Net.HttpStatusCode.Forbidden, Type = typeof(RestErrorResponse))]
[SwaggerResponse((int)System.Net.HttpStatusCode.NotFound)]
[ApiExplorerSettings(IgnoreApi = true)]
[HttpPost("/v1/packages")]
[Authorize()]
public async Task<IActionResult> GetAllModelsFromDatabase([FromBody]Request request)
{
...
}