Open markyme21 opened 4 years ago
@markyme21 what happens if nullable: false
is set on a schema item, but globally in AJV we allow nullable?
@jsdevel Same as happens now, an error.
Ajv -> validate.js
if ($typeSchema && it.opts.nullable && it.schema.nullable === true) { if ($typeIsArray) { if ($typeSchema.indexOf('null') == -1) $typeSchema = $typeSchema.concat('null'); } else if ($typeSchema != 'null') { typeSchema = [$typeSchema, 'null']; $typeIsArray = true; } }
$typeSchema which then used to compile the validation code will stay the same. Right? 👨💻
not sure. feel free to open a PR. ensure that whatever you do adheres to the spec as much as possible.
Looks like Ajv is initialized in Request/Response validators (Needed them both, may be relevant to others) without "nulllable" set to TRUE, causing validation errors.
var v = new Ajv({ ..., nullable: true });
This fixed the issue I was having.
I'm using express-openapi@6.0.0 which uses openapi-framework@0.26.0 -> "openapi-request-validator": "4.2.0" and "openapi-response-validator": "4.0.0".
Was trying to use OPENAPI3 JSON definition which looks like: