title: jsonschema: Abstract Data Type and correct error message
body: <p>I'm using the <code>jsonschema</code> Python library like this:</p>
  <pre class="lang-py prettyprint-override"><code>import jsonschema
  
  schema = {
      &quot;type&quot;: &quot;object&quot;,
      &quot;oneOf&quot;: [
          {
              &quot;type&quot;: &quot;object&quot;,
              &quot;additionalProperties&quot;: False,
              &quot;required&quot;: [&quot;key&quot;],
              &quot;properties&quot;: {&quot;key&quot;: {&quot;enum&quot;: [&quot;foo&quot;], &quot;type&quot;: &quot;string&quot;}},
          },
          {
              &quot;type&quot;: &quot;object&quot;,
              &quot;additionalProperties&quot;: False,
              &quot;required&quot;: [&quot;key&quot;, &quot;baritem&quot;],
              &quot;properties&quot;: {
                  &quot;key&quot;: {&quot;enum&quot;: [&quot;bar&quot;], &quot;type&quot;: &quot;string&quot;},
                  &quot;baritem&quot;: {&quot;type&quot;: &quot;string&quot;},
              },
          },
      ],
  }
  </code></pre>
  <p>I can validate correct data:</p>
  <pre class="lang-py prettyprint-override"><code>jsonschema.validate({&quot;key&quot;: &quot;bar&quot;, &quot;baritem&quot;: &quot;ok&quot;}, schema)
  </code></pre>
  <p>But if a property is missing, if fails (as expected), but with a strange error message:</p>
  <pre class="lang-py prettyprint-override"><code>jsonschema.validate({&quot;key&quot;: &quot;bar&quot;}, schema)
  </code></pre>
  <pre><code>Traceback (most recent call last):
    File &quot;valid.py&quot;, line 29, in &lt;module&gt;
      jsonschema.validate({&quot;key&quot;: &quot;bar&quot;}, schema)
    File &quot;/home/david/.pyenv/versions/3.7.11/lib/python3.7/site-packages/jsonschema/validators.py&quot;, line 934, in validate
      raise error
  jsonschema.exceptions.ValidationError: 'bar' is not one of ['foo']
  
  Failed validating 'enum' in schema[0]['properties']['key']:
      {'enum': ['foo'], 'type': 'string'}
  
  On instance['key']:
      'bar'
  </code></pre>
  <p>My first question is: Is it the right way to defined the <code>JSON</code> schema, especially the part defined the <code>key</code> with an <code>enum</code>?</p>
  <p>My second question is: Is there a way to define properly Abstract Data Type like this with <code>jsonschema</code>, ie to tell <code>jsonschema</code> to choose the <code>object</code> listed in <code>oneOf</code> based on the <code>key</code> property, and to validate the rest of the properties based on this object?</p>