我知道如何在Swagger中添加一个头值,代码如下:
[HttpGet] [Route("api/{bookID}")] public async Task<IActionResult> GetBooksByID([FromHeader(Name = "Correlation-ID")]string bookID) { //... }
字符串但是如果我想添加额外的头值,如“TenantID”,“UserID”等,该怎么办?语法是什么样子的?
w8f9ii691#
只需添加更多参数,并在每个要匹配的参数上包含FromHeader属性:
FromHeader
[HttpGet] [Route("api/{bookID}")] public async Task<IActionResult> GetBooksByID( string bookID, [FromHeader(Name = "Correlation-ID")] string correlationID, [FromHeader(Name = "Tenant-ID")] string tenantID, [FromHeader(Name = "User-ID")] string userID) { //... }
字符串
1条答案
按热度按时间w8f9ii691#
只需添加更多参数,并在每个要匹配的参数上包含
FromHeader
属性:字符串