ASP.NET Core 2.1 Swagger(swashbuckle)网址模板可选参数[duplicate]

问题描述 投票:1回答:1
[HttpGet("commercial/{fromCcy}/{toCcy?}")]
public ActionResult Commercial(string fromCcy, string toCcy)

我有带有可选参数“ toCcy”的动作“ commercial”,并且使用必填字段生成了详细规格。有什么办法可以解决这个问题?

enter image description here

c# asp.net-core swagger asp.net-core-2.1 swashbuckle
1个回答
2
投票

[使用可选参数时,最好的方法是使用[Fromquery]。例如:

© www.soinside.com 2019 - 2024. All rights reserved.