grape-jsonapi-resources
grape-jsonapi-resources copied to clipboard
Creating formatter resource cache fails due to 'Uninitialized constant... ::ThreadSafe'
I'm attempting to utilise this library with Rails (7.0.7), Grape (1.7.1), and Ruby (3.2.2). but I'm running into issues when the formatter is attempting to resolve the resource class for the first time. Below is the stack trace. Is there something missing in my setup or is this library no longer supported in these versions of Rails/Ruby?
NameError:
uninitialized constant #<Class:Grape::Formatter::JSONAPIResources>::ThreadSafe
Backtrace:
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:85:in `resources_cache'
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:89:in `get_resource_for'
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:80:in `resource_class_for'
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:78:in `resource_class_for'
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:19:in `serialize_resource'
/usr/local/rvm/gems/default/gems/grape-jsonapi-resources-0.0.7/lib/grape-jsonapi-resources/formatter.rb:6:in `call'
The basic code setup is as follows:
# app/api/public/v1/topics.rb
module Public
module V1
class Topics < ::Grape::API
include Public::V1::Defaults
resource :topics do
desc 'List of available topics which a helpline may support.'
get do
render Topics.All
end
end
add_swagger_documentation
end
end
end
# app/resources/topic_resource.rb
class TopicResource < JSONAPI::Resource
attributes :name
end
# config/routes.rb
Rails.application.routes.draw do
...
mount Public::API => '/'
mount GrapeSwaggerRails::Engine => '/swagger'
jsonapi_resources :topics
end