Also do not attempt to get the schema for null/undefined docs
Summary
After updating the package to the latest version (1.1.0) it started failing when an empty array contained discriminated documents. It would get the child schema using the array as the document instead of an element of the array so it would end up with an undefined schema.
With this change it now gets the schema for each document in the array (unless it is null/undefined) and will also not break if a schema has a discriminator mapping key but no discriminators object (which happens when the schema is configured the way it is in the test).
Examples
I have included a new test, should work on schemas with discriminators in arrays, that failed before but passes now.
Also do not attempt to get the schema for null/undefined docs
Summary
After updating the package to the latest version (1.1.0) it started failing when an empty array contained discriminated documents. It would get the child schema using the array as the document instead of an element of the array so it would end up with an undefined schema.
With this change it now gets the schema for each document in the array (unless it is null/undefined) and will also not break if a schema has a discriminator mapping key but no discriminators object (which happens when the schema is configured the way it is in the test).
Examples I have included a new test,
should work on schemas with discriminators in arrays
, that failed before but passes now.