jarrodek / ChromeRestClient

ARC Chrome is deprecated. Please move to https://github.com/advanced-rest-client/arc-electron/
Apache License 2.0
370 stars 98 forks source link

Support for RFC 6570 UriTemplates #987

Open dschulten opened 7 years ago

dschulten commented 7 years ago

Who will benefit from this feature?

Developers using media types with uri templates, such as HAL, siren, Hydra which allow to browse an API.

Overview

RFC6570 is a standard to describe URI templates where clients can fill in placeholders. There is ample toollng for this kind of template available, also in Javascript. I use https://github.com/geraintluff/uri-templates.

Example templates are: http://example.com/~{username}/ http://example.com/dictionary/{term:1}/{term} http://example.com/search{?q,lang}

Use cases

Working with URI Template

  1. User clicks templated link (UriTemplate)
  2. System puts clicked UriTemplate into the ARC address bar
  3. System recognizes placeholders by parsing UriTemplate (see below) and offers a panel to enter values for the placeholders. Note that values may not only be strings, but also lists and dictionaries. For the latter two a JSON notation could be used ([] for lists, {} for dictionaries)
  4. User enters values
  5. User clicks Send
  6. System expands UriTemplate in address bar with entered values and processes request
  7. System stores entered values for UriTemplate in session storage

Reusing URI Template

Precondition: User has entered values for a UriTemplate in a previous request

  1. User clicks templated link (UriTemplate)
  2. System puts clicked UriTemplate into the ARC address bar
  3. System finds stored values for URL and offers a panel with prefilled values
  4. User clicks Send

Do you know anyone else, internal or external, that is also interested in this feature?

No

Do you expect this feature to be fairly stable? How might it be extended or changed in the future?

Stable. RFC 6570 is well-established and supporting tools are mature.

List every UI surface belonging to or potentially affected by this feature:

Request

How could this feature be abused?

The system must ensure that stored placeholders will only be applied to the URL for which they were entered originally. Otherwise values not intended for a URL might be entered unintentionally.

Imagine you’re Dr. Evil app user, list the three worst evil deeds you could commit with your feature (if you’ve got good ones, feel free to add more): I have limited evil imagination, but I do not see any.

Open questions

None

Example usage

Sample usage of https://github.com/geraintluff/uri-templates in node

mkdir uri-templates
cd uri-templates
npm install uri-templates
node
> var uriTemplates = require('uri-templates')             
> var template1 = uriTemplates("/date/{colour}/{shape}/");
> template1.varNames                                      
[ 'colour', 'shape' ]                                     
jarrodek commented 7 years ago

Hi,

Thank you for the feature request. Recently I've build a similar tool for the Mulesoft's API Console. RAML spec defines URI templates and I had to build an editor to provide the values for this templates. So the user is able to change the value in the URL editor and in so called parameters editor where you have a form with input fields to place the values.

However, how this refers to the app variables? You can do the same thing already in arc by defining a variable and use the variable in the URL. Isn't it the same thing?

Thanks