Skip to content

Grape - Improve readability when multiple versions are defined #1431

@katpadi

Description

@katpadi

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions