voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.53k stars 242 forks source link

How to validate data with only part of my schema #288

Closed panSarin closed 8 years ago

panSarin commented 8 years ago

Hello.

I have complex json-schema files. With definitions and links. In link i use targetSchema like

    "targetSchema": {
        "type": "object",
        "$ref": "/schemata/my_resource#/definitions/my_resource_create_response"
      }

So in my tests i want to use

    schema = JSON.parse(File.read(my_json_path))['definitions'][schema_def_name] # schema_def_name => my_resource_create_response
    JSON::Validator.validate!(schema, response.body, parse_data: false)

But whatever i try to do it it always expects me to give him url as a schema. Can i pass some JSON schema definition as a schema to compare with my response body ?

panSarin commented 8 years ago

Ok nvm, it wasn't about path to file. It was confusing error about $ref path :< srry!