Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot self-validate the schema #2

Open
TelegramSam opened this issue Feb 14, 2011 · 7 comments
Open

Cannot self-validate the schema #2

TelegramSam opened this issue Feb 14, 2011 · 7 comments

Comments

@TelegramSam
Copy link

The spec says that the schema is self validating, but when I try using your library, I get this error:

    JSON::Schema::ValueError: dependencies is missing and it is not optional

    /Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:40:in `check_property'
    /Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:209:in `check_object'
    /Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:207:in `each'
    /Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:207:in `check_object'
    /Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:99:in `check_property'
    /Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:287:in `validate'
    /Library/Ruby/Gems/1.8/gems/jsonschema-2.0.0/lib/jsonschema.rb:298:in `validate'
    ./sqapp.rb:96:in `POST /d/schemas/add'
@Constellation
Copy link
Owner

This library is in accordance with JSON Schema 2nd Draft ( http://groups.google.com/group/json-schema/web/json-schema-proposal---second-draft ), excepting Extending and Referencing / unique property.

Thanks for your report.

@jfirebaugh
Copy link

Are you planning to update to draft 3, which replaces the "optional" attribute with "required" attribute (and makes optional the default)?

@Constellation
Copy link
Owner

I would like to implement draft 3 JSON Schema in the future.
but, JSON Schema draft 3 is very complexed (such as format, URI based $schema, etc.), so this takes a little long time...

thx.

@hoxworth
Copy link

If interested, I have a fairly stable draft-3 compliant Ruby json schema validator at https://github.com/hoxworth/json-schema. The validator also supports draft-1 and draft-2, and will be tracking any future updates to the JSON Schema spec.

@Constellation
Copy link
Owner

Oh! Thanks!!! Your implementation is great!

Do you think about the 3rd draft complicated attributes like "regexp" in "format", "$ref" with the external URL(http://...)?

@hoxworth
Copy link

The $ref attribute is definitely handled and resolves against absolute and relative URIs. The library will load external 'http' and 'file' URI schemes if the URI is not explicitly defined in the schema, and will treat all other URIs as internal references.

As for format, the library does not explicitly enforce that the instance value matches the constraints of a format. The draft spec explicitly states that validators are not required to enforce these rules and that the 'format' attribute is to be used mostly as an inference tool by consumers of data that adhere to a JSON schema.

There are probably a few more things that need to be ironed out in this library; however it is pretty simple to add / remove features and declare new schemas. I will be moving the library into its first major release once the JSON schema is finalized past the draft stage and proper testing has been performed.

@Constellation
Copy link
Owner

Oh thanks!

The draft spec explicitly states that validators are not required to enforce these rules and that the 'format' attribute is to be used mostly as an inference tool by consumers of data that adhere to a JSON schema.

Oh! I overlooked. I misunderstood that JSON Schema spec requires completely implementation of "format".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants