Use the URI template fields to pre-populate the Input (JSON) field
timbunce opened this issue · 3 comments
It's surprising to click on a /resource{/id}
link and find the box that pops up contains
{ "foo": "bar" }
It would be helpful if the "foo" could at least be "id" from parsing the template. Even more helpful to present the user with something like this:
{
"id": ""
}
ideally with text box already given the focus and the cursor placed between the value quotes - but I don't know how tricky that would be.
uritemplate-js is the (Level 4) implementation for JS recommended here. See also this note comparing implementations.
The pull request I just made creates a default JSON input based on the query string but I just realized that null is probably a better default value than an empty string.
Consider the following URI template: '/some/path{?q}' Which would be expanded to: '/some/path?q=' for an empty string and '/some/path' for null.
Do we perhaps want different default values for different kinds of expressions? An empty string for simple expressions such as {someVar} but null for expressions such as {?someVar}?
Given that an input could potentially be an array or an object, maybe the best route is to default to null.
I had a quick look, it doesn't look like the uri template library we're using at the moment will make it easy to reflect on a given variable to figure out what kind of input is needed. I could be wrong though, I didn't look super hard! :)
thoughts?
I'm ok with this for now, feel free to re-open though