Skip to content

Instantly share code, notes, and snippets.

@mamund
Last active March 12, 2021 03:39
Show Gist options
  • Save mamund/f87f8177ac8cb6a52f361acd4a95ea30 to your computer and use it in GitHub Desktop.
Save mamund/f87f8177ac8cb6a52f361acd4a95ea30 to your computer and use it in GitHub Desktop.
Working Skeleton for HAL-FORMS SUGGEST control

Below is an updated workinging model for HAL-FORMS options control. See notes below for details. Comments welcome.

{
  "_templates" : {
    "default" : {
      ...
      "properties" : [
        {
          "name" : "...", 
          "value" : "...", 
          "prompt" : "...", 
          "options" : {
            "inline" : ["...", "..." , ...] | [{"prompt" : "...", "value" : "..."}, {...}, ...],
            "link" : {
              "href" : "...",
              "templated" : "false",
              "accept" : "application/json|text/csv..."
            },
            "promptField" : "prompt",
            "valueField" : "value",
            "minSelect" : "0",
            "maxSelect" : "1",
            "autocomplete" : "false"          
          }
        }
      ]
    }
  }
}
  • No longer tying the options control to the type property. This means options MAY appear on any property element (e.g. type=email, type=datetime, etc.). Should there be any restrictions on this (e.g. options SHOULD/MUST not appear (SHOULD/MUST be ingnored) when type=range, etc.?

  • Cardinality is handled by the new options.minSelect and options.maxSelect. They default to 0 and 1 respectively. IOW, you can pick no more than one and could leave it unselected. You can supply one of these or both, or none. If none, the defaults apply. Note this can cause a conflict if required=true. We'll need to offer guidance (e.g. required overrides options.minSelect when options.minSelect=0, etc.)

  • Default format for options.link.accept is application/json. If link.href is set and link.accept is missing, assume it is set to application/json. Also, if link.accept value sent to the server is invalid, unparseable, or not supported, the service SHOULD return application/json.

  • NOTE that autocomplete is a suggestion for supporting type-ahead search. In this version, autocomplete=true and options.inline are assumed compatible. That would mean the client would be in charge of rendering the type-ahead support. Is that acceptable? It's a big 'ask' for clients, I think.

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