Closed tlivings closed 10 years ago
Hello @tlivings.
I'm considering swagger spec and this implementation for my company data aggregation layer. While reading the code I wondered (read master branch) about the decision to use enjoi instead of tv4. I prefer tv4 mainly because it's seems more performant (http://cosmicrealms.com/blog/2014/02/07/benchmark-of-node-dot-js-json-validation-modules-part-2/).
Could you share the rationale behind this issue?
Hi, sure.
The link you reference has questionable benchmarks. When I ran my own benchmarks, which you can run by calling npm run bench
in swagaerize-builder
, joi
validation is actually much faster. I suspect the benchmark run in that link was done without pre-building the joi
schema, which I do.
In addition, I found I had better validation results with enjoi
, since I resolved $ref
up front.
Finally, since I also wrote a swaggerize-hapi
module, hapi handles the input validation automatically if you provide it a joi
schema, which was a really nice fit.
Hope this helps answer your question.
Closing this since it's already done in 2.0.0.
Rather than
tv4
, useenjoi
for input validation.Likely API schema validation will need to remain the same due to the broken Swagger 2.0 schema.