gpt4 book ai didi

asp.net-core - Swashbuckle.AspNetCore 所需的查询字符串参数

转载 作者:行者123 更新时间:2023-12-04 16:46:39 25 4
gpt4 key购买 nike

我有一个 ASP.NET Core v2.1 项目 Swashbuckle.AspNetCore包裹。
我的代码是:

    /// <summary>
/// Set new android token for the current driver
/// </summary>
/// <remarks>
/// Sample request:
///
/// PUT /SetToken?token=new_token
///
/// </remarks>
/// <param name="token">can't be null or empty</param>
/// <returns></returns>
/// <response code="204">If executed successfully</response>
/// <response code="400">if token is null or empty</response>
/// <response code="404">if user is not a driver; if driver is not found (removed etc); if user does not have a profile</response>
[ProducesResponseType(204)]
[ProducesResponseType(400)]
[ProducesResponseType(404)]
[HttpPut]
[Route("SetToken")]
[UserIsNotDriverException]
[NullReferenceException]
[DriverWithoutProfileException]
public async Task<IActionResult> SetToken([FromQuery]string token)
{

我想根据需要标记查询参数。我该怎么做?注意,我在查询字符串中传递参数,而不是在正文中等

最佳答案

您可以添加 BindRequired属性到您的参数。

public async Task<IActionResult> SetToken([FromQuery, BindRequired]string token)

关于asp.net-core - Swashbuckle.AspNetCore 所需的查询字符串参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56186603/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com