You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Grape should log a warning when the formatter returns a 406 for an unsupported content type. #322
@dblock
By creating a MyApi class with content_type :json, "application/json" in it, only json is allowed. Great.
Then, you can try accessing a resource with .xml extension for example and you'll get The requested format 'txt' is not supported.. This probably happens because Grape ignores input kind since it's not trying to parse it (because we didn't tell it to support other formats). When a user appends an extension, say .xml though, it's counter-intuitive to get that 'txt' message. I think that to fix this, we'd need to extract the extension from the URL. For a quick bugfix I'd just remove the format from the error message all together.
What do you think?
Activity
dblock commentedon Feb 9, 2013
Including the requested format and media type along in the body of the error. Let me know if this works.
leods92 commentedon Sep 11, 2014
This returns 'txt' even when format is 'xml' for example.
Is this expected behaviour?
dblock commentedon Sep 11, 2014
@leods92 It wouldn't be. Error formats can be controlled separately though. Build a repro case?
leods92 commentedon Sep 12, 2014
@dblock
By creating a MyApi class with
content_type :json, "application/json"in it, only json is allowed. Great.Then, you can try accessing a resource with .xml extension for example and you'll get The requested format 'txt' is not supported.. This probably happens because Grape ignores input kind since it's not trying to parse it (because we didn't tell it to support other formats). When a user appends an extension, say
.xmlthough, it's counter-intuitive to get that 'txt' message. I think that to fix this, we'd need to extract the extension from the URL. For a quick bugfix I'd just remove the format from the error message all together.What do you think?
dblock commentedon Sep 12, 2014
It does sound strange, some code that determines the format should settle on XML in this case, open another issue with maybe a spec?