format :json is not scoped to one API, it affects other APIs
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
We have two endpoints, one accepts application/json content-type, the other accepts text/plain. They live together. However, when format :json is included in one of our API's the other one is effected as well.
Consider the example below:
class API < Grape::API
format :json
get '/v1/users' do
{'api': 'api'}
end
end
class BAPI < Grape::API
post '/v1/users' do
{'bapi': 'bapi'}
end
end
application = Rack::Builder.new do
map '/' do
run Rack::Cascade.new [API, BAPI]
end
end
In this case, POST /v1/users returns {"error":"The requested content-type 'text/plain' is not supported."}. When format :json is removed, it returns {"bapi": "bapi"} as expected.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Rack::Builder example with API and BAPI to confirm that format :json affects the other endpoint's content-type handling. Trace how format configuration is shared between the two APIs; the work is done when each API keeps its own content-type behavior and the example no longer rejects text/plain for BAPI.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100