{"action":"created","issue":{"url":"https://api.github.com/repos/jhthorsen/swagger2/issues/24","labels_url":"https://api.github.com/repos/jhthorsen/swagger2/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/jhthorsen/swagger2/issues/24/comments","events_url":"https://api.github.com/repos/jhthorsen/swagger2/issues/24/events","html_url":"https://github.com/jhthorsen/swagger2/issues/24","id":102024439,"number":24,"title":"I need to always set SWAGGER_COERCE_VALUES=1","user":{"login":"kberov","id":111614,"avatar_url":"https://avatars.githubusercontent.com/u/111614?v=3","gravatar_id":"","url":"https://api.github.com/users/kberov","html_url":"https://github.com/kberov","followers_url":"https://api.github.com/users/kberov/followers","following_url":"https://api.github.com/users/kberov/following{/other_user}","gists_url":"https://api.github.com/users/kberov/gists{/gist_id}","starred_url":"https://api.github.com/users/kberov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kberov/subscriptions","organizations_url":"https://api.github.com/users/kberov/orgs","repos_url":"https://api.github.com/users/kberov/repos","events_url":"https://api.github.com/users/kberov/events{/privacy}","received_events_url":"https://api.github.com/users/kberov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jhthorsen/swagger2/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":{"login":"jhthorsen","id":45729,"avatar_url":"https://avatars.githubusercontent.com/u/45729?v=3","gravatar_id":"","url":"https://api.github.com/users/jhthorsen","html_url":"https://github.com/jhthorsen","followers_url":"https://api.github.com/users/jhthorsen/followers","following_url":"https://api.github.com/users/jhthorsen/following{/other_user}","gists_url":"https://api.github.com/users/jhthorsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jhthorsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhthorsen/subscriptions","organizations_url":"https://api.github.com/users/jhthorsen/orgs","repos_url":"https://api.github.com/users/jhthorsen/repos","events_url":"https://api.github.com/users/jhthorsen/events{/privacy}","received_events_url":"https://api.github.com/users/jhthorsen/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2015-08-19T23:42:34Z","updated_at":"2015-08-20T12:09:17Z","closed_at":null,"body":"I have the following data:\r\n```\r\n[\r\n  {\r\n    \"disabled\" => 1,\r\n    \"email\" => \"null\\@localhost\",\r\n    \"first_name\" => \"Null\",\r\n    \"group_id\" => 1,\r\n    \"id\" => 1,\r\n    \"last_name\" => \"Null\",\r\n    \"login_name\" => \"null\"\r\n  },\r\n  {\r\n    \"disabled\" => 1,\r\n    \"email\" => \"foo\\@localhost\",\r\n    \"first_name\" => \"Foo\",\r\n    \"group_id\" => 2,\r\n    \"id\" => 2,\r\n    \"last_name\" => \"Bar\",\r\n    \"login_name\" => \"foo\"\r\n  },\r\n]\r\n```\r\nI have the following response description:\r\n```\r\n      responses:\r\n        200:\r\n          description: A paged array of users\r\n          headers:\r\n            #This we have to create it before sending the response I think?\r\n            x-next:\r\n              type: string\r\n              description: A link to the next page of responses\r\n          schema: {$ref: \"lib/AppName/etc/APIs/definitions.yaml#/definitions/Users\"}\r\n\r\n```\r\nlib/AppName/etc/APIs/definitions.yaml#/definitions/Users:\r\n```\r\n---\r\n#definitions.yaml: All object definitions go here\r\ndefinitions:\r\n  User:\r\n    #describe all the required fields\r\n    required:\r\n      - id\r\n      - group_id\r\n      - login_name\r\n      - first_name\r\n      - last_name\r\n      - email\r\n      - disabled\r\n    properties:\r\n      id:\r\n        type: integer\r\n      group_id:\r\n        type: integer\r\n      login_name:\r\n        type: string\r\n      first_name:\r\n        type: string\r\n      last_name:\r\n        type: string\r\n      email:\r\n        type: string\r\n      disabled:\r\n        type: boolean\r\n  Users:\r\n    type: array\r\n    items:\r\n      $ref: User\r\n```\r\nHowever if I do not set  SWAGGER_COERCE_VALUES, I get the following error:\r\n```\r\n{\r\n  \"errors\":[\r\n    {\"message\":\"Expected integer - got string.\",\"path\":\"\\/0\\/group_id\"},\r\n    {\"path\":\"\\/0\\/id\",\"message\":\"Expected integer - got string.\"},\r\n    {\"message\":\"Expected integer - got string.\",\"path\":\"\\/1\\/group_id\"},\r\n    {\"path\":\"\\/1\\/id\",\"message\":\"Expected integer - got string.\"},\r\n  ],\r\n\"valid\":false\r\n}\r\n```\r\nIs this expected behavior? I think it is not. My data is \"integer\".\r\nLooks like the chek here (https://github.com/jhthorsen/swagger2/blob/master/lib/Swagger2/SchemaValidator.pm#L543) is somehow wrong.\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/jhthorsen/swagger2/issues/comments/132987587","html_url":"https://github.com/jhthorsen/swagger2/issues/24#issuecomment-132987587","issue_url":"https://api.github.com/repos/jhthorsen/swagger2/issues/24","id":132987587,"user":{"login":"jhthorsen","id":45729,"avatar_url":"https://avatars.githubusercontent.com/u/45729?v=3","gravatar_id":"","url":"https://api.github.com/users/jhthorsen","html_url":"https://github.com/jhthorsen","followers_url":"https://api.github.com/users/jhthorsen/followers","following_url":"https://api.github.com/users/jhthorsen/following{/other_user}","gists_url":"https://api.github.com/users/jhthorsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jhthorsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhthorsen/subscriptions","organizations_url":"https://api.github.com/users/jhthorsen/orgs","repos_url":"https://api.github.com/users/jhthorsen/repos","events_url":"https://api.github.com/users/jhthorsen/events{/privacy}","received_events_url":"https://api.github.com/users/jhthorsen/received_events","type":"User","site_admin":false},"created_at":"2015-08-20T12:09:17Z","updated_at":"2015-08-20T12:09:17Z","body":"@timbunce: Could you give more input (example?) on how Cpanel::JSON::XS solves this issue? Do you use it on the client side? If so, does it use something like Scalar::Util::looks_like_number() to figure out if it's a number or not? If so, how do you enable sending a number as a string?"}}