You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[tony@starship test (reference_schema *)]$ ruby test-oneOf.rb
Run options: --seed 25046
# Running:
{:schema=>#<URI::Generic:0x007f7a6cbc71e8 URL:840ddff5-9a23-5e12-b904-1790f2467ce3#>, :fragment=>"#/", :message=>"The property '#/' of type Hash did not match any of the required schemas in schema 840ddff5-9a23-5e12-b904-1790f2467ce3#", :failed_attribute=>"OneOf"}.
Finished in 0.004075s, 245.3878 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 0 errors, 0 skips
If I remove the oneOf attribute then my output becomes:
[tony@starship test (reference_schema *)]$ ruby test-single.rb
Run options: --seed 21753
# Running:
{:schema=>#<URI::Generic:0x007fecb81564c0 URL:01545b94-1588-55b9-8a56-97f328178a87#>, :fragment=>"#/", :message=>"The property '#/' did not contain a required property of 'b' in schema 01545b94-1588-55b9-8a56-97f328178a87#", :failed_attribute=>"Required"}
{:schema=>#<URI::Generic:0x007fecb81564c0 URL:01545b94-1588-55b9-8a56-97f328178a87#>, :fragment=>"#/a", :message=>"The property '#/a' of type String did not match the following type: integer in schema 01545b94-1588-55b9-8a56-97f328178a87#", :failed_attribute=>"TypeV4"}
Is it me misinterpreting the json-schema specification?
The text was updated successfully, but these errors were encountered:
This is as designed and follows the JSON Schema draft-04 specification. When oneOf is utilized, a JSON object only validates if it validates against one of the schemas defined in the oneOf schema array. Since the object in your example does not validate against any of the schemas in the oneOf schema array (you only have one schema), it fails validation for the oneOf directive. It would not follow JSON Schema conventions to list validation failures in all of the optional schemas listed in the oneOf directive, as if one of the schemas were to validate the data, there would be no validation failure.
If oneOf is absent, the object simply fails to validate against the schema (for the provided reasons).
Your description makes sense to me, but the implementation isn't very useful. This prevents me from getting the cause of the oneOf schema validation error.
Are there other methods of retrieving the most-specific validation errors? For example the jsonschema package for Python provides a best_match API that reveals specific errors in the case of oneOf or allOf.
JSON::Validator.fully_validate
only reports a schema error with theoneOf
attribute.Here is an example test:
Running the test outputs:
If I remove the
oneOf
attribute then my output becomes:Is it me misinterpreting the json-schema specification?
The text was updated successfully, but these errors were encountered: