fix: more descriptive message for wrong discriminator use

fixes #505
This commit is contained in:
Roman Hotsiy 2018-05-29 17:58:56 +03:00
parent 4b41bb103f
commit 3c6de2cafc
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -40,6 +40,13 @@ export class Schema extends React.Component<Partial<SchemaProps>> {
}
if (discriminatorProp !== undefined) {
if (!oneOf || !oneOf.length) {
throw new Error(
`Looks like you are using discriminator wrong: you don't have any definition inherited from the ${
schema.title
}`,
);
}
return (
<ObjectSchema
{...{ ...this.props, schema: oneOf![schema.activeOneOf] }}