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

MultiJSON receives filepath instead of its content #318

Closed
triplepointfive opened this issue Mar 28, 2016 · 3 comments
Closed

MultiJSON receives filepath instead of its content #318

triplepointfive opened this issue Mar 28, 2016 · 3 comments

Comments

@triplepointfive
Copy link

Calling
JSON::Validator.fully_validate_schema( {"$schema"=>"http://json-schema.org/draft-03/schema#", "type"=>"object", "properties"=>{}} )
Leads to JSON::ParserError: invalid comment format at line 1, column 1 [parse.c:96]

But the same result even with JSON::Validator.fully_validate_schema( {} )

This is happening because the first arg of MultiJSON.load is
"/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/json-schema-2.5.2/resources/draft-04.json", not the content of file itself

Backtrace:

/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/multi_json-1.11.2/lib/multi_json/adapters/json_common.rb:19:in `parse'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/multi_json-1.11.2/lib/multi_json/adapters/json_common.rb:19:in `load'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/multi_json-1.11.2/lib/multi_json/adapter.rb:21:in `load'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/multi_json-1.11.2/lib/multi_json.rb:119:in `load'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/json-schema-2.6.1/lib/json-schema/validator.rb:417:in `parse'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/json-schema-2.6.1/lib/json-schema/validator.rb:537:in `initialize_schema'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/json-schema-2.6.1/lib/json-schema/validator.rb:53:in `block in initialize'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/json-schema-2.6.1/lib/json-schema/validator.rb:53:in `synchronize'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/json-schema-2.6.1/lib/json-schema/validator.rb:53:in `initialize'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/json-schema-2.6.1/lib/json-schema/validator.rb:276:in `new'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/json-schema-2.6.1/lib/json-schema/validator.rb:276:in `fully_validate'
/Users/Smelkov/.rvm/gems/ruby-2.2.3@ege-fcc-ash/gems/json-schema-2.6.1/lib/json-schema/validator.rb:283:in `fully_validate_schema'
@iainbeeston
Copy link
Contributor

I can reproduce this by doing the following:

require 'json-schema'
MultiJson.use :json_common
JSON::Validator.fully_validate_schema( {} ) # => raises a NameError

Unfortunately this is a bug with the :json_common adapter in MultiJson, rather than a problem with json-schema itself. I've raised an issue on the MultiJson repository for it.

A workaround for now would be to not use the :json_common MultiJson adapter (for example, use :json_gem) or not to use MultiJson with json-schema

@iainbeeston
Copy link
Contributor

@rwz has informed me that :json_common isn't an adapter you should be using - perhaps changing the MultiJson adapter for your app will resolve the issue

@triplepointfive
Copy link
Author

I actually just downgraded to v2.5.2 and that's fixed the issue. That's why I suspected json-schema. Anyway, thank you for your investigation.

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

2 participants