ruby-grape / ruby-grape/grape-swagger

Does Not Handle Rails Optional Path Segments

Open
#878 0 comments 0 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

Ruby on Rails supports optional path segments, such as:

get 'photos(/:id)'

would match both photos/:id and photos paths.

However, grape-swagger does not recognise these optional path segments. For example:

get 'photos(/:id)' 

would generate:

"paths": {
  "/api/v2/photos(/{id})": {
    "get": {
    ...
      "parameters": [
         {
           "in": "path", "name": "id"
           ...
  }
}

instead of the expected:

"paths": {
  "/api/v2/photos": {
    "get": {
    ...
  }
  ...
  "/api/v2/photos/{id}": {
    "get": {
    ...
      "parameters": [
         {
           "in": "path", "name": "id"
           ...
  }
}

grape-swagger should also handle Rails optional path segments in a predictable manner.

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 the Rails optional path-segment example in the issue and trace how grape-swagger turns that route into OpenAPI paths. Verify that the generated output represents both /api/v2/photos and /api/v2/photos/{id}, with the id parameter retained only on the parameterized path.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, rails, ruby
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.