ruby-grape / ruby-grape/grape-swagger

`hidden` setting won't work for grape's default 404 handler

Open
#755 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.1k
Forks
479
Avg merge
2d 14h
Merged PRs (30d)
6

Description

Hi.

I'm running an application which uses grape v1.1.0 and grape-swagger v0.27.3.
In my application I'm using grape's functionality for handling all 404's.

When I'm trying to access /swagger_doc I'm getting an undefined method '[]' for nil:NilClass error on GrapeSwagger::DocMethods::StatusCodes.get[route.request_method.downcase.to_sym].

The reason is obviously the missing request method as it is converted to * when using route(:any).
Since I don't even need the default 404 handler in my swagger documentation, I tried adding a hidden: true setting to the route (both in the description and using the route_setting method) but it doesn't seem to work.

Is there any way to get this working?
Thanks in advance.

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 with GrapeSwagger::DocMethods::StatusCodes.get and the route(:any) handling described in the report, then trace how route settings are read while generating /swagger_doc. Reproduce the nil request-method failure with the stated Grape and grape-swagger versions. Done means the default 404 route no longer causes documentation generation to fail when hidden: true is configured.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.