-
Notifications
You must be signed in to change notification settings - Fork 34
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
Generate schema location urls in controller #71
Conversation
@@ -13,7 +13,7 @@ def initialize(options = {}) | |||
|
|||
# Converts the schema to its json representation that will be returned by /SCHEMAS end-point of a SCIM service provider. | |||
def as_json(options = {}) | |||
@meta.location = Scimitar::Engine.routes.url_helpers.scim_schemas_path(name: id) | |||
@meta.location ||= Scimitar::Engine.routes.url_helpers.scim_schemas_path(name: id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if generating a url here still has any value. I left it in here for backwards compatibility.
Took a while to get my head around it and I do worry about that there's now no test coverage for any prior initialisers where the likes of The only thing holding this back from merging is an addition to Is that OK? |
No problem. See last commit. Thanks for taking the time to consider and review my changes, and for maintaining this gem in general. Saved my life! |
Great stuff. Merged! Many thanks for the contribution 👍 |
This is now available via RubyGems in v2.6.0 / v1.7.0. |
Makes schema location URLs be generated in the controller. This way required keyword arguments for the URL helper are automatically revolved from the current path parameters. This solves an issues when Scimitar's routes are mounted inside a namespace with variable parameters. E.g. in our multitenant environment we have:
In this case
#scim_schemas_url
requires the:organization_id
key, which is omitted when the URL is generated inSchema::Base#as_json
. This causes an error. Using the controller's URL helper fixes this.Additionally, the controller's URL helpers can be overridden in a simple(r) manner, making Scimitar a bit more extensible. I have utilized this to test this change (see the application controller mixin for the tests).
The resource types controller already does a similar thing for resource type urls.