-
Notifications
You must be signed in to change notification settings - Fork 81
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
Why enjoi? #102
Comments
Because Swagger is based on json-schema and enjoi converts it to a Joi schema for validation. Hapi supports Joi directly whereas we need to provide middleware that calls the Joi validation in express. |
Follow up question. Why is Joi being used at all if the swagger schema is based on json-schema and not Joi schema? Why not use a json schema validator to validate against a json schema? |
@shattar that's the approach we've taken with express-openapi and it's worked out incredibly well. |
@jsdevel but this approach is design driven, meaning all you have to do is to design the spec of your api and let this module generate a nice express server for you, judging from the readme docs, express-openapi is not, correct me if I'm wrong |
|
from what I've seen you have to create everything yourself, paths, files, from the example in the readme |
right, so there isn't a generator for |
@shattar at the time there were wasn't a json-schema validator faster than Joi. The other reason is hapi's native support for Joi. We are, however, in the process of updating to The difficulty in doing validation at all is that Swagger (OpenAPI) is not true json-schema and has various oddities (such as introducing a new primitive that can't be validated by value). @Kashio |
@tlivings |
@mihir83in enjoi? Yes - but mostly for hapi-openapi. Swaggerize-express is in limbo but has a branch that is much updated and no longer depending on enjoi. If you are not bound to hapi I would recommend ajv or is-my-json-valid for json schema and https://github.com/APIDevTools/swagger-parser for parsing swagger. |
Probably missing something obvious, but was curious as to why you dont use joi directly in the express version but do in the hapi version!
The text was updated successfully, but these errors were encountered: