[英]Does Swashbuckle.AspNetCore support FluentValidation instead of DataAnnotations?
I've been reading the docs for Swashbuckle.AspNetCore
and it suggest that you can use DataAnnotation
's to decorate various things to get a richer Swagger API generated. 我一直在阅读
Swashbuckle.AspNetCore
的文档,它建议您可以使用DataAnnotation
来装饰各种东西,以生成更丰富的Swagger API。 Nice! 太好了!
But ... we're not using DataAnnotations
. 但是...我们没有使用
DataAnnotations
。 We're using FluentValidation
instead. 我们改用
FluentValidation
。
So, does the Swashbuckle.AspNetCore
library provide a way to leverage FluentValidation
instead DataAnnotations
? 那么,
Swashbuckle.AspNetCore
库是否提供一种利用FluentValidation
代替DataAnnotations
?
We would prefer not to repeat any validation logic, twice. 我们不希望重复任何验证逻辑两次。
Let me expand a bit on my comment: 让我扩大一下我的评论:
It would not be too difficult to enhance Swashbuckle to incorporate FluentValidation
增强Swashbuckle以并入FluentValidation并不是很困难
I would like to start by saying that FluentValidation
has some complicated validation cases, stuff that is probably not even supported by the latest OAS (3.0.1) or the Swagger-UI, so my comment is about the most common stuff... 首先,我要说
FluentValidation
有一些复杂的验证案例,这些东西甚至可能不受最新的OAS(3.0.1)或Swagger-UI的支持,所以我的评论是关于最常见的东西...
Your best leverage here is that both projects are OpenSource, you could: 最好的利用是,这两个项目都是OpenSource,您可以:
Let's be clear none of those are a 5 hour quick code fix... 让我们清楚一点,这些都不是5小时的快速代码修复...
But if I was going to do the job, I think that the second is a better option. 但是,如果我打算做这份工作,我认为第二个是更好的选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.