ruby-grape / ruby-grape/grape-entity

`route.entity` can not get entity class in Rails 7.1

Open
#380 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
729
Forks
154
PR merge metrics
No merged PRs in 30d

Description

I use grape gem version is that:

grape (~> 1.8)
grape-entity (~> 1.0)
grape-middleware-logger (~> 1.12)
grape-swagger (~> 1.6)
grape-swagger-entity (~> 0.5)

When I use rails 7.1.0, the output of route.entity in grape is #<Class:0x000000010bb66910>.
Xnip2023-10-10_21-01-25

However, when using rails 7.0.8, the output of route.entity becomes the normal V1::Entities::Dev::Haha.
Xnip2023-10-10_21-00-14

All other code is the same except for the change in Rails version.

This leads to an incorrect entity name in the definitions when generating swagger json.
I'm not sure if this is an issue with grape or grape-entity, so I've posted the issue here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the route.entity result with Rails 7.0.8 and 7.1.0 using the listed grape, grape-entity, grape-swagger, and grape-swagger-entity versions. Trace how the entity class is resolved and verify the generated Swagger JSON; done means route.entity returns the expected entity class and its correct name appears in the definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.