diff --git a/CHANGELOG.md b/CHANGELOG.md index 773aa4dde..ce18d325b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * [#2538](https://github.com/ruby-grape/grape/pull/2538): Fix validating nested json array params - [@mohammednasser-32](https://github.com/mohammednasser-32). * [#2543](https://github.com/ruby-grape/grape/pull/2543): Fix array allocation on mount - [@ericproulx](https://github.com/ericproulx). * [#2546](https://github.com/ruby-grape/grape/pull/2546): Fix middleware with keywords - [@ericproulx](https://github.com/ericproulx). +* [#2547](https://github.com/ruby-grape/grape/pull/2547): Remove jsonapi related code - [@ericproulx](https://github.com/ericproulx). * Your contribution here. ### 2.3.0 (2025-02-08) diff --git a/lib/grape/error_formatter/jsonapi.rb b/lib/grape/error_formatter/jsonapi.rb deleted file mode 100644 index ed1d2d30f..000000000 --- a/lib/grape/error_formatter/jsonapi.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -module Grape - module ErrorFormatter - class Jsonapi < Json; end - end -end diff --git a/lib/grape/parser/jsonapi.rb b/lib/grape/parser/jsonapi.rb deleted file mode 100644 index 58e16571b..000000000 --- a/lib/grape/parser/jsonapi.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -module Grape - module Parser - class Jsonapi < Json; end - end -end diff --git a/spec/grape/middleware/exception_spec.rb b/spec/grape/middleware/exception_spec.rb index b209b726f..ccd48b7b7 100644 --- a/spec/grape/middleware/exception_spec.rb +++ b/spec/grape/middleware/exception_spec.rb @@ -162,27 +162,6 @@ def call(_env) end end - context do - let(:running_app) { exception_app } - let(:options) { { rescue_all: true, format: :jsonapi } } - - it 'is possible to return errors in jsonapi format' do - get '/' - expect(last_response.body).to eq('{"error":"rain!"}') - end - end - - context do - let(:running_app) { error_hash_app } - let(:options) { { rescue_all: true, format: :jsonapi } } - - it 'is possible to return hash errors in jsonapi format' do - get '/' - expect(['{"error":"rain!","detail":"missing widget"}', - '{"detail":"missing widget","error":"rain!"}']).to include(last_response.body) - end - end - context do let(:running_app) { exception_app } let(:options) { { rescue_all: true, format: :xml } } diff --git a/spec/grape/middleware/formatter_spec.rb b/spec/grape/middleware/formatter_spec.rb index 28ec6c9aa..037e0915c 100644 --- a/spec/grape/middleware/formatter_spec.rb +++ b/spec/grape/middleware/formatter_spec.rb @@ -36,23 +36,6 @@ def to_json(*_args) end end - context 'jsonapi' do - let(:body) { { 'foos' => [{ 'bar' => 'baz' }] } } - let(:env) do - { Rack::PATH_INFO => '/somewhere', Grape::Http::Headers::HTTP_ACCEPT => 'application/vnd.api+json' } - end - - it 'calls #to_json if the content type is jsonapi' do - body.instance_eval do - def to_json(*_args) - '{"foos":[{"bar":"baz"}] }' - end - end - r = Rack::MockResponse[*subject.call(env)] - expect(r.body).to eq(Grape::Json.dump(body)) - end - end - context 'xml' do let(:body) { +'string' } let(:env) do