voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.54k stars 243 forks source link

No implicit conversion of integer to string with links #258

Closed wjdhamilton closed 9 years ago

wjdhamilton commented 9 years ago

I have encountered a bug when trying to use this gem to validate a json_hyperschema object. Here's the schema:

{ "id": "http://www.occasions.me/schemas/friends", "type": "object", "properties": { "friend": { "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "email": { "type": "string" }, "dob": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" }, "gender": { "type": "boolean" } }, "required": [ "name", "email" ] }, "links": [{ "rel": "full", "href": "{id}" }, { "rel": "relationships", "href": "/friends/{id}/relationships" }, { "rel": "occasions", "href": "/friends/{id}/occasions" }, { "rel": "address", "href": "/addresses/{address_id}" }] } }

..and here's the string to be validated:

"{\"friend\":{\"id\":1,\"name\":\"Miss Zita Bernhard\",\"email\":\"jaunita_padberg@collier.org\",\"dob\":\"1967-09-11\",\"gender\":true},\"links\":{\"id\":\"/friends/1\",\"relationships\":\"/friends/1/relationships\",\"occasions\":\"/friends/1/occasions\"}}"

The validator throws "No implicit conversion of integer to string" when trying to validate the links section, and I suspect it is due to the {id} notation in the lilnks.