Skip to content

Grape - Improve readability when multiple versions are defined #1431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
katpadi opened this issue Feb 26, 2025 · 2 comments
Open

Grape - Improve readability when multiple versions are defined #1431

katpadi opened this issue Feb 26, 2025 · 2 comments

Comments

@katpadi
Copy link

katpadi commented Feb 26, 2025

In Grape, it's possible to define multiple versions e.g.:

class V1 < Grape::API
  version 'v1', 'v2'

  get '/foos' do
    # your code for GET /foo
  end
end

This produces a value for path and http.route that looks like this:

/["v1", "v2"]/foos/

Reference:

Perhaps this is to promote low cardinality URL as per specs but would it hurt if we add an ability or configuration to maybe produce something like:

/{v1|v2}/foos/
/(v1|v2)/foos/
/v1|v2/foos/
/{v1|v2}/foos/
/:version/foos/ # Static value?

I'm not sure if a pipe or any of my recommended symbols violate any spec but it's mainly for readability as ["v1", "v2"] looks like a typo or a misconfiguration.

Thoughts?

@arielvalentin
Copy link
Collaborator

Cc: @muripic

Copy link
Contributor

👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot.

@github-actions github-actions bot added the stale Marks an issue/PR stale label Mar 29, 2025
@kaylareopelle kaylareopelle removed the stale Marks an issue/PR stale label Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants