Repository: johnnoone/json-spec

Issue:
Add details to Missing Property error
Please consider the patch below.  In reporting a missing property during validation, this include the name of the property in the ValidationError's reason.

(Sorry for the inline code. I haven't figured out how to properly submit a patch. The github's issues editor won't let me attach a *.patch file to this post, and other options I tried get rejected because I don't have permission to contribute.)

```
From 42c4a75835ccb98907c75b7611f550774e3e245f Mon Sep 17 00:00:00 2001
From: Greg Bullock <greg@nwra.com>
Date: Wed, 20 Apr 2016 15:30:37 -0700
Subject: [PATCH] Add details to Missing Property error

In reporting a missing property during validation, include the name of
the property in the ValidationError's reason.

---
 src/jsonspec/validators/draft04.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/jsonspec/validators/draft04.py b/src/jsonspec/validators/draft04.py
index adb6ee9..f6d67bb 100644
--- a/src/jsonspec/validators/draft04.py
+++ b/src/jsonspec/validators/draft04.py
@@ -380,7 +380,7 @@ class Draft04Validator(Validator):
             if key in obj:
                 if isinstance(dependencies, sequence_types):
                     for dep in set(dependencies) - set(obj.keys()):
-                        self.fail('Missing property', obj, pointer)
+                        self.fail('Missing property "{}"'.format(dep), obj, pointer)
                 else:
                     dependencies(obj)
         return obj
@@ -609,7 +609,7 @@ class Draft04Validator(Validator):
         if 'required' in self.attrs:
             for name in self.attrs['required']:
                 if name not in obj:
-                    self.fail('Missing property', obj, pointer)
+                    self.fail('Missing property "{}"'.format(name), obj, pointer)
         return obj

     def validate_type(self, obj, pointer=None):
-- 
2.7.1.windows.2


```


Comments:

Patch:
diff --git a/src/jsonspec/validators/draft04.py b/src/jsonspec/validators/draft04.py
index adb6ee9..6d2fc9c 100644
--- a/src/jsonspec/validators/draft04.py
+++ b/src/jsonspec/validators/draft04.py
@@ -379,8 +379,8 @@ class Draft04Validator(Validator):
         for key, dependencies in self.attrs.get('dependencies', {}).items():
             if key in obj:
                 if isinstance(dependencies, sequence_types):
-                    for dep in set(dependencies) - set(obj.keys()):
-                        self.fail('Missing property', obj, pointer)
+                    for name in set(dependencies) - set(obj.keys()):
+                        self.fail('Missing property', obj, pointer_join(pointer, name))  # noqa
                 else:
                     dependencies(obj)
         return obj
@@ -596,7 +596,8 @@ class Draft04Validator(Validator):
             return obj
 
         if additionals is False:
-            self.fail('Forbidden additional properties', obj, pointer)
+            for name in pending:
+                self.fail('Forbidden property', obj, pointer_join(pointer, name))  # noqa
             return obj
 
         validator = additionals
@@ -609,7 +610,7 @@ class Draft04Validator(Validator):
         if 'required' in self.attrs:
             for name in self.attrs['required']:
                 if name not in obj:
-                    self.fail('Missing property', obj, pointer)
+                    self.fail('Missing property', obj, pointer_join(pointer, name))  # noqa
         return obj
 
     def validate_type(self, obj, pointer=None):


Test patch:
diff --git a/tests/test_errors2.py b/tests/test_errors2.py
index bf5b4f4..0c121e5 100644
--- a/tests/test_errors2.py
+++ b/tests/test_errors2.py
@@ -41,21 +41,23 @@ scenarii = [
      {'#/foo': {'Wrong type'}},
      'integer required'),
     ({'bar': 'foo'},
-     {'#/': {"Missing property"}},
-     'string required'),
+     {'#/foo': {"Missing property"}},
+     'missing required'),
     ({'foo': 12, 'baz': None},
-     {'#/': {"Missing property"}},
-     'miss a dependencies'),
+     {'#/bar': {"Missing property"}},
+     'missing dependencies'),
     ({'foo': 42},
      {'#/foo': {"Exceeded maximum"}},
      'too big'),
     ({'foo': 12, 'baz': None, 'quux': True},
-     {'#/': {'Forbidden additional properties', 'Missing property'}},
-     'too big'),
+     {'#/quux': {'Forbidden property'},
+      '#/bar': {'Missing property'}},
+     'missing dependencies, forbidden additional'),
     ({'foo': 42, 'baz': None, 'quux': True},
-     {'#/': {'Forbidden additional properties', 'Missing property'},
+     {'#/quux': {'Forbidden property'},
+      '#/bar': {'Missing property'},
       '#/foo': {'Exceeded maximum'}},
-     'too big'),
+     'missing dependencies, forbidden additional, too big'),
 ]