{"action":"created","issue":{"url":"https://api.github.com/repos/intridea/grape/issues/905","labels_url":"https://api.github.com/repos/intridea/grape/issues/905/labels{/name}","comments_url":"https://api.github.com/repos/intridea/grape/issues/905/comments","events_url":"https://api.github.com/repos/intridea/grape/issues/905/events","html_url":"https://github.com/intridea/grape/issues/905","id":54975795,"number":905,"title":"Custmer json format add  {\"status\": \"202\", \"code\": \"2001\",\"data\": {grape object json}}, But i get a grape-swagger javascript error.","user":{"login":"tian-xiaobo","id":10395157,"avatar_url":"https://avatars.githubusercontent.com/u/10395157?v=3","gravatar_id":"","url":"https://api.github.com/users/tian-xiaobo","html_url":"https://github.com/tian-xiaobo","followers_url":"https://api.github.com/users/tian-xiaobo/followers","following_url":"https://api.github.com/users/tian-xiaobo/following{/other_user}","gists_url":"https://api.github.com/users/tian-xiaobo/gists{/gist_id}","starred_url":"https://api.github.com/users/tian-xiaobo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tian-xiaobo/subscriptions","organizations_url":"https://api.github.com/users/tian-xiaobo/orgs","repos_url":"https://api.github.com/users/tian-xiaobo/repos","events_url":"https://api.github.com/users/tian-xiaobo/events{/privacy}","received_events_url":"https://api.github.com/users/tian-xiaobo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-21T04:14:02Z","updated_at":"2015-01-21T13:25:02Z","closed_at":null,"body":"Custmer json format add  {\"status\": \"202\", \"code\": \"2001\",\"data\": {grape object json}}, But i get a grape-swagger javascript error.\r\n```\r\nmodule API\r\n  module APIHelpers\r\n\r\n    module JSendSuccessFormatter\r\n      def self.call(object, env)\r\n        { status: '200', code: '2001', data: object }.to_json\r\n      end\r\n    end\r\n\r\n    module JSendErrorFormatter\r\n      def self.call(message, backtrace, options, env)\r\n        if message.is_a?(Hash)\r\n          { :status => 'fail', :data => message }.to_json\r\n        else\r\n          { :status => 'error', :message => message }.to_json\r\n        end\r\n      end\r\n    end\r\n\r\n    module ExceptionHandlers\r\n      def self.included(base)\r\n        base.instance_eval do\r\n          rescue_from Grape::Exceptions::ValidationErrors do |e|\r\n            Rack::Response.new({\r\n              error: { code: 1001, message: e.message }\r\n            }.to_json, e.status)\r\n          end\r\n        end\r\n      end\r\n    end\r\n\r\n  end\r\nend\r\n\r\n```\r\n```\r\nmodule API\r\n  class API < Grape::API\r\n    version 'v1'\r\n    prefix 'api'\r\n    format :json\r\n\r\n    helpers APIHelpers\r\n\r\n   formatter :json, APIHelpers::JSendSuccessFormatter\r\n   error_formatter :json, APIHelpers::JSendErrorFormatter\r\n......\r\n.....\r\n\r\n```\r\noptput \r\n```\r\n{\r\n  \"status\": \"200\",\r\n  \"code\": \"2001\",\r\n  \"data\": {\r\n    \"id\": 1,\r\n    \"title\": \"title\",\r\n    \"summary\": \"summary\",\r\n    \"content\": \"content\",\r\n    \"title_link\": \"title_link\",\r\n    \"must_read\": true,\r\n    \"slug\": \"slug\",\r\n    \"state\": \"publish\",\r\n    \"draft_key\": \"draft_key\",\r\n    \"created_at\": \"2015-01-13T14:24:05.943+08:00\",\r\n    \"updated_at\": \"2015-01-13T14:24:05.943+08:00\",\r\n    \"cover\": {\r\n      \"url\": null\r\n    }\r\n  }\r\n}\r\n```\r\nGot a grape-swagger javascript error.\r\n\r\n```\r\n[Error] TypeError: undefined is not an object (evaluating 'response.apis.length')\r\n\tbuildFrom1_1Spec (swagger-ef0b13e38d9e65fe2645c7219034874d.js, line 217)\r\n\tresponse (swagger-ef0b13e38d9e65fe2645c7219034874d.js, line 143)\r\n\tresponse (swagger-ef0b13e38d9e65fe2645c7219034874d.js, line 1479)\r\n\temit (shred.bundle-945ecf92347d2bf3ab1b35dd24ed25cb.js, line 1391)\r\n\temit (shred.bundle-945ecf92347d2bf3ab1b35dd24ed25cb.js, line 1191)\r\n\t(anonymous function) (shred.bundle-945ecf92347d2bf3ab1b35dd24ed25cb.js, line 1211)\r\n\tsetBodyAndFinish (shred.bundle-945ecf92347d2bf3ab1b35dd24ed25cb.js, line 1815)\r\n\t(anonymous function) (shred.bundle-945ecf92347d2bf3ab1b35dd24ed25cb.js, line 1832)\r\n\temit (shred.bundle-945ecf92347d2bf3ab1b35dd24ed25cb.js, line 1388)\r\n\thandle (shred.bundle-945ecf92347d2bf3ab1b35dd24ed25cb.js, line 2715)\r\n\tonreadystatechange (shred.bundle-945ecf92347d2bf3ab1b35dd24ed25cb.js, line 2584)\r\n```"},"comment":{"url":"https://api.github.com/repos/intridea/grape/issues/comments/70835630","html_url":"https://github.com/intridea/grape/issues/905#issuecomment-70835630","issue_url":"https://api.github.com/repos/intridea/grape/issues/905","id":70835630,"user":{"login":"dblock","id":542335,"avatar_url":"https://avatars.githubusercontent.com/u/542335?v=3","gravatar_id":"","url":"https://api.github.com/users/dblock","html_url":"https://github.com/dblock","followers_url":"https://api.github.com/users/dblock/followers","following_url":"https://api.github.com/users/dblock/following{/other_user}","gists_url":"https://api.github.com/users/dblock/gists{/gist_id}","starred_url":"https://api.github.com/users/dblock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dblock/subscriptions","organizations_url":"https://api.github.com/users/dblock/orgs","repos_url":"https://api.github.com/users/dblock/repos","events_url":"https://api.github.com/users/dblock/events{/privacy}","received_events_url":"https://api.github.com/users/dblock/received_events","type":"User","site_admin":false},"created_at":"2015-01-21T13:25:02Z","updated_at":"2015-01-21T13:25:02Z","body":"This looks like an error in [swagger-ui](https://github.com/swagger-api/swagger-ui), I would run the development version and find out what causes this."}}