微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

C#.NET MVC-使用自定义动词时Swagger引发异常

如何解决C#.NET MVC-使用自定义动词时Swagger引发异常

简单的死问题:

我的控制器代码

       [AcceptVerbs("VALIDATE","PUT")]
        public ObjectResult Validate(BookingState input)
        {
            return OK(ImmutableList.Create<object>());
        }

而且,当我混合JSON(https://localhost:44327/swagger/v1/swagger.json)端点时,我得到:

System.Collections.Generic.KeyNotFoundException: The given key 'VALIDATE' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable`1 apiDescriptions,SchemaRepository schemaRepository)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions,SchemaRepository schemaRepository)
   at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName,String host,String basePath)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext,ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

如果我删除“ VALIDATE”动词,它会正常工作。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。