-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to convert joi-schema to json-schema? #2253
Comments
Unfortunately, no community resources were available to help resolve this issue after two weeks, and it is being closed. We close unresolved community issues to keep the issue tracker organized and effective. Please check https://hapi.dev/support for other support options. |
Would love to see this is as well... Especially since json-schema validation is much faster than joi validation this would be a great way to allow for speed up where appropriate. |
json-schema is also less powerful, some things can't be converted to json-schema. Honestly this likely will never happen. Performance especially in the latest versions is not bad at all, if you're trying to squeeze microseconds, maybe it's not the right tool for you. |
@Marsup Makes sense that it's less powerful. Most things can however be converted. It's not about microseconds, it's about percentage. If a single check takes only 10ms but you are doing 1k of them, shaving 9ms is a lot :) Anyways, there is now a project https://www.npmjs.com/package/joi-to-json which seems to not rely on internals of joi. So that's really the way to do this going forward. |
What's important is the percentage per request, not how many you can do in a loop. If you lose 5ms on a request that takes 50ms, optimizing it to 2ms won't even be noticeable. I see your point but I don't think it matters, people care too much about joi performance when most of the time is wasted in your own code. |
@Marsup Well, I just replaced joi with custom validation to change overall time for a client request from ~1050ms to ~650ms. And yes, we want and need the validation. So call me biased :) |
Then that's a good bench case and we're open to that, can you somehow anonymize that and submit it to see if there's something specific going on? |
@Marsup Sure. Do you want me to open a new ticket? |
This would be very useful, since:
|
i would find it useful too. export to JSON. this would allow to build some automation tools around joi. in my case - UI element to copy part of schema and drop it on another validator. just good joi-json-joi conversion is needed |
This is useful feature since json-schema has many tools that depend on |
No description provided.
The text was updated successfully, but these errors were encountered: