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

Comments

Projects
None yet
5 participants
@martinicr
Copy link

martinicr commented Feb 12, 2015

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

This comment has been minimized.

Copy link
Owner

damnhandy commented Feb 28, 2015

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

This comment has been minimized.

Copy link
Owner

damnhandy commented Mar 1, 2015

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

This comment has been minimized.

Copy link

martinicr commented Mar 1, 2015

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

This comment has been minimized.

Copy link

drdamour commented Apr 24, 2015

+1

1 similar comment
@Vulcannis

This comment has been minimized.

Copy link

Vulcannis commented May 22, 2015

+1

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

@damnhandy

This comment has been minimized.

Copy link
Owner

damnhandy commented Sep 4, 2015

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.

@damnhandy damnhandy closed this Sep 5, 2015

@stefanseifert

This comment has been minimized.

Copy link
Contributor

stefanseifert commented Sep 8, 2015

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

This comment has been minimized.

Copy link
Owner

damnhandy commented Sep 8, 2015

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