From 3c29a9ccfc7fc2845952103d4e16b47a465100e6 Mon Sep 17 00:00:00 2001 From: Iaroslav Ciupin Date: Thu, 15 Jul 2021 15:17:14 +0300 Subject: [PATCH] fix allOf wrong type error message --- schema.go | 2 +- schema_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/schema.go b/schema.go index 9e93cd79..82faba7b 100644 --- a/schema.go +++ b/schema.go @@ -891,7 +891,7 @@ func (d *Schema) parseSchema(documentNode interface{}, currentSchema *subSchema) } else { return errors.New(formatErrorDescription( Locale.MustBeOfAn(), - ErrorDetails{"x": KEY_ANY_OF, "y": TYPE_ARRAY}, + ErrorDetails{"x": KEY_ALL_OF, "y": TYPE_ARRAY}, )) } } diff --git a/schema_test.go b/schema_test.go index c05ddf08..6d35dd73 100644 --- a/schema_test.go +++ b/schema_test.go @@ -380,3 +380,12 @@ func TestIncorrectRef(t *testing.T) { assert.Nil(t, s) assert.Equal(t, "Object has no key 'fail'", err.Error()) } + +func TestAllOfIncorrectTypeErrorMessage(t *testing.T) { + schemaLoader := NewStringLoader(`{"allOf": {}}`) + + s, err := NewSchema(schemaLoader) + + assert.Nil(t, s) + assert.EqualError(t, err, "allOf must be of an array") +}