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

Can "Handy-URI-Templates" expand URIs partially? #24

Closed
martinicr opened this issue Feb 12, 2015 · 8 comments
Closed

Can "Handy-URI-Templates" expand URIs partially? #24

martinicr opened this issue Feb 12, 2015 · 8 comments
Assignees
Milestone

Comments

@martinicr
Copy link

Hi guys, first of all, I love "Handy-URI-Templates" library, works awesome. Now this not exactly an issue, is more a question about a feature.

I have this URI template:
http://localhost/my-app/employees{/employeeId}/reviews{?page,size}

I would like to provide the "employeeId" variable to the template BUT keep the {?page,size} section. Something like:
http://localhost/my-app/employees/999/reviews{?page,size}

I know the expand() method will hide unused variables in the template and also I know what I'm trying to do is probably not aligned with RFC 6570 but, is there a way to achieve this by using "Handy-URI-Templates"?

Thanks,

Martin.

@damnhandy
Copy link
Owner

It took me a while to grok what you're saying, but what you are looking for is that rather than the expansion return an expanded URI, you want it to return a new template with the partial values filled in?

@damnhandy
Copy link
Owner

It would be possible to add an expandPartial() method that would return another URITemplate instance. If that's what you're after, let me know. It'd be trivial to add.

@damnhandy damnhandy self-assigned this Mar 1, 2015
@martinicr
Copy link
Author

Hi thank your for taking for time on this (and sorry for the late response). I think you got the idea behind this kind of new "feature".

My idea behind the expandPartial() method could be something like:
Scenario #1
Given I have a URI template with format:
http://api.company.com/resources{/resourceId}{?page,size}
When I ask for a partial expansion with resourceId = 999
Then I should have a String like:
http://api.company.com/resources/999{?page,size}

Scenario #2
Given I have a URI template with format:
http://api.company.com/resources{/resourceId}{?page,size}
When I ask for a partial expansion with
page = 0 and
size = 10
Then I should have a String like:
http://api.company.com/resources{/resourceId}?page=0&size=10

Scenario #3
Given I have a URI template with format:
http://api.company.com/resources{/resourceId}{?page,size}
When I ask for a partial expansion with
resourceId = 999
page = 0 and
size = 10
Then I should have a String like:
http://api.company.com/resources/999?page=0&size=10

@drdamour
Copy link

+1

1 similar comment
@Vulcannis
Copy link

+1

@damnhandy damnhandy added this to the 2.0.3 milestone Sep 4, 2015
@damnhandy
Copy link
Owner

Thanks to Pull request #28 , we now have this feature. I have published a snapshot of 2.0.3 which contains this PR. If folks could test that and verify it's working as you've anticipated, I'll cut a release. At the moment, I'm planning in doing that tonight anyway.

@stefanseifert
Copy link
Contributor

i'm a colleague of cnagel (#28) - he is out of office this week.
we tested the latest 2.0.3-SNAPSHOT and it looks fine - thanks for the quick merge!

@damnhandy
Copy link
Owner

Thanks! I'm trying to push out the release, but it seems the github pages maven plugin I'm using is having some issues. Once I get that sorted out, I'll release 2.0.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants