rest icon indicating copy to clipboard operation
rest copied to clipboard

Support for RFC 6570 "URI Template"

Open mkarg opened this issue 1 year ago • 5 comments

As proposed by @jansupol in a recent Jersey discussion the adoption of RFC 6570 "URI Template" could clarify some ambiguities in Jakarta REST's current definition of when to / when not to percent-encode template parameter values. Due to that, I hereby propose the mandatory support of RFC 6570 for Jakarta REST 4.0.

mkarg avatar Jun 11 '23 14:06 mkarg

@chkal @jansupol @jamezp @arjantijms @spericas WDYT?

mkarg avatar Jun 11 '23 14:06 mkarg

I'd be a +1 as I think this makes sense.

jamezp avatar Jun 12 '23 14:06 jamezp

The RFC fits perfectly with the UriBuilder functionality and putting it to the Spec requirement seems natural to me.

jansupol avatar Jun 13 '23 12:06 jansupol

UriBuilder mandates throwing IllegalArgumentException for a missing template argument which is in contradiction to the RFC which skips missing arguments: Section 3.2.1:

A variable that is undefined (Section 2.3) has no value and is ignored by the expansion process. If all of the variables in an expression are undefined, then the expression's expansion is the empty string.

jansupol avatar Jul 18 '23 21:07 jansupol

Depending on which part of Uri the template is used for, the template behavior changes

For Uri, the path does not percent-encode reserved characters such as the exclamation mark "!" The RFC default template {var} should percent-encode the exclamation mark, whereas other types of a template, such as (path) {/var} or reserved expansion template {+var} do not percent-encode reserved characters (exclamation mark).

The query part, on the other hand, percent-encode the reserved characters.

Hence, the template's default behavior behaves or does not behave as the default template as described in Section 3.2.2 of the RFC and it should be clearly described by the UriBuilder javadoc in the case of the RFC adoption.

jansupol avatar Jul 24 '23 20:07 jansupol