-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
No implicit conversion of integer #259
Comments
I think that in your schemes friends and links are also objects - you need
|
Hi Iain, Thanks for the help. I've rewritten the schema as follows:
...but now I get the following error: |
My bad, your links property is an array of objects, not an object. If it helps, I recommend this guide to Jason schema: http://spacetelescope.github.io/understanding-json-schema/index.html
|
Thanks, I did look at that but in my enthusiasm I decided to just crack on an write something. Won't be the first time! |
I'm more than willing to suppose that I am doing something wrong, but whenever I try and validate the following string:
{ "friend": { "id": 1, "name": "Roman Graham", "email": "ro.willms@carroll.org", "dob": "1995-05-05", "gender": true }, "links": { "id": "/friends/1", "relationships": "/friends/1/relationships", "occasions": "/friends/1/occasions" } }
with this 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}" }] } }
I get the following error:
Failure/Error: expect(response).to match_response_schema :friend_schema TypeError: no implicit conversion of String into Integer
...and it's doing my head in. The runtime error only occurs when id is specified as an integer. If I specify it as a string it predictably fails validation. Can anyone tell me where I'm going wrong or have I found a bug?
The text was updated successfully, but these errors were encountered: