Skip to content
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

Ignore query parameters if same name already exists as a path parameter #4

Open
jgraichen opened this issue Aug 22, 2018 · 0 comments

Comments

@jgraichen
Copy link
Owner

jgraichen commented Aug 22, 2018

When reusing controllers on different paths identically named placeholders might be added. See this example:

  get '/users/:user_id/permissions' => 'permissions#index'
  get '/permissions' => 'permissions#index'

The same controller is used for both actions as the user_id is just an optional filter for the permissions controller. Nevertheless the controller describes it as a param:

class PermissionsController < ApplicationController
  rfc6570_params index: %i[context user_id]
end

This will generate the following URI template for user_permissions:

/users/{user_id}/permissions{?context}{&user_id}

This will insert the User ID twice when expanding:

/users/fd32a10b-e900-4fdb-a4fd-6fe7002fb87c/permissions?user_id=fd32a10b-e900-4fdb-a4fd-6fe7002fb87c{&context}
Proposal

The query parameter user_id might just be skipped while kept for other routes:

user_permissions => /users/{user_id}/permissions{?context}
permissions => /permissions{?context}{&user_id}
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

1 participant