Closed kibertoad closed 6 years ago
@idanto Any opinion on this?
@idanto ping?..
Thanks @kibertoad. Sorry for the late response, busy weeks... You can add this functionality but please make it configurable and false by default for two reasons:
feel free to submit a pull request and I promise to review it as fast as possible.
@idanto Thanks for the response! Will try to do it in the next few days.
@idanto Done! See https://github.com/idanto/express-ajv-swagger-validation/pull/22 BTW, what are the requirements for getting co-maintainer permissions on this project? Or you prefer to keep it a solo project?
@idanto Any chance you could publish 0.5.0 version at some point? Also see question above :)
already there :).
RE: co-maintainer permissions - I will add you soon.
Thanks!
Since Swagger 2.0 doesn't support specifying multiple types for a field (as JSON Schema does), it is not possible to correctly coerce numeric types as Ajv converts null integers into 0 if null is not one of possible types, and typically this is a very bad idea.
My suggestion is to provide slightly adjusted JSON schema to the Ajv for validation, using following rule: if property is not listed as required, it has one additional type - 'null'. Probably this behaviour should be regulated via a middleware option.
I can work on this functionality if approved :).