Use endpoint.endpoints instead of endpoint.options[:app]#981
Merged
Conversation
dec3926 to
8f356e4
Compare
Danger ReportNo issues found. |
There was a problem hiding this comment.
Pull request overview
This pull request updates how mounted API endpoints are discovered in combine_namespaces, switching from reaching into an endpoint’s options hash (endpoint.options[:app]) to using the first-class endpoint.endpoints reader to improve forward-compatibility with Grape and avoid errors on bare Rack mounts.
Changes:
- Replace
endpoint.options[:app].endpointswithendpoint.endpointswhen collecting nested endpoints. - Update the relevant spec double to stub
endpointsinstead ofoptions[:app]. - Add a changelog entry describing the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/grape-swagger/swagger_documentation_adder.rb | Use endpoint.endpoints to safely and directly collect nested endpoints during namespace combination. |
| spec/lib/swagger_routing_spec.rb | Adjust test setup to match the new endpoint.endpoints access pattern. |
| CHANGELOG.md | Document the change under upcoming fixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
numbata
reviewed
Jul 5, 2026
numbata
approved these changes
Jul 6, 2026
numbata
left a comment
Contributor
There was a problem hiding this comment.
@ericproulx thx for the fix. Let's rebase the branch and merge it!
`combine_namespaces` reached into the endpoint's options bag with `endpoint.options[:app].endpoints` to collect a mounted API's endpoints. Use the `endpoint.endpoints` reader instead, which returns exactly those endpoints for a mounted Grape API (and `nil` otherwise). This is equivalent for Grape mounts, works across all supported Grape versions, and is safer for bare Rack (Proc) mounts — `options[:app]` is truthy for a Proc but has no `#endpoints`, whereas `endpoint.endpoints` is `nil`. It also drops grape-swagger's dependency on `options[:app]`, which Grape plans to remove from the endpoint options Hash. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Memoize endpoint.endpoints in a local so it is called once, and add a positive-recursion spec covering an endpoint that exposes nested endpoints. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
719fb41 to
38d6171
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
combine_namespacescollected a mounted API's endpoints by reaching into the endpoint's options bag withendpoint.options[:app].endpoints. This switches to the first-classendpoint.endpointsreader.Why
endpoint.endpointsreturnsconfig.app.endpoints, exactly whatoptions[:app].endpointscomputed.Proc) mounts:options[:app]is truthy for aProcbut has no#endpoints(would raise), whereasendpoint.endpointsisnil.endpoint.endpointshas existed for a long time (verified on the 1.8 → 2.4 range and HEAD).options[:app]dependency. Grape is moving endpoint attributes out of the catch-all options Hash toward named accessors (http_methods,path,mounted_app, …) and plans to remove:appfrom it; this keeps grape-swagger forward-compatible.🤖 Generated with Claude Code