1. 程式人生 > >Ambiguous HTTP method Actions require an explicit HttpMethod binding for Swagger 2.0

Ambiguous HTTP method Actions require an explicit HttpMethod binding for Swagger 2.0

test void swa uri mbo ogl 自己 找到 code

異常內容

NotSupportedException: Ambiguous HTTP method for action . 
Actions require an explicit HttpMethod binding for Swagger 2.0

解決方案

思考:瘋狂Google,找到 https://stackoverflow.com/questions/47822177/swagger-net-core-api-ambiguous-http-action-debugging, 但是底下沒有有價值的回答。自己琢磨一下,比起一個標準的接口,少了Http請求定義和參數定義。
猜測是因為定義不標準,對Swagger來說,不標準就報錯,這沒問題。

驗證:寫一個標準的method。

[HttpPost,Route(test)]
pulic void Test([FromBody] InputDto dto)
{
}

異常解決。

Ambiguous HTTP method Actions require an explicit HttpMethod binding for Swagger 2.0