Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# .NET Core中的Swashbuckle-设置需要的字符串参数_C#_Json_Asp.net Web Api_Swagger_Swashbuckle - Fatal编程技术网

C# .NET Core中的Swashbuckle-设置需要的字符串参数

C# .NET Core中的Swashbuckle-设置需要的字符串参数,c#,json,asp.net-web-api,swagger,swashbuckle,C#,Json,Asp.net Web Api,Swagger,Swashbuckle,我正试图找到一种方法来设置ASP.NET核心Api项目所需的字符串参数,但一直没有找到答案。我的假设是只需添加[Required]的DataAnnotation就可以了,但事实并非如此 如何让Swagger实现string类型的查询字符串参数是必需的 [HttpGet] [Produces("application/json", Type = typeof(IEnumerable<string>))] [SwaggerOperation(operationId: "ListStuff

我正试图找到一种方法来设置ASP.NET核心Api项目所需的字符串参数,但一直没有找到答案。我的假设是只需添加[Required]的DataAnnotation就可以了,但事实并非如此

如何让Swagger实现string类型的查询字符串参数是必需的

[HttpGet]
[Produces("application/json", Type = typeof(IEnumerable<string>))]
[SwaggerOperation(operationId: "ListStuff")]
[ProducesResponseType(typeof(string), (int)HttpStatusCode.BadRequest)]
public IActionResult ListStuff(int id, [Required]string auditId)
{
    ...
}

奇怪的是,如果没有所需的。。。你有什么版本的Swashback?这也是我在阅读一些github线程时所想的。所有内容都应默认为required,除非特别设置为nullable?不幸的是,我看到了完全相反的情况。Swashback.AspNetCore v1.0.0Aaa您正在使用Swashback.AspNetCore很可能是一个bug,您应该报告它:谢谢。臭虫档案。您不应该添加属性
[FromRoute]
以使其成为必需的吗?
{
  "name":"auditId",
  "in":"query",
  "required":false,
  "type":"string"
}