1

I am creating a hypermedia api that conforms to the HAL spec

When a user submits a payment they need to specify what type of card they are using (Visa, Master Card etc)

So for a particular field that is submitted there is a specific list of values that can be used

How do I present that pick list to the user?

As embedded data?

Is there generally a way to associate a field with a given set of data?

I realise the HAL spec is very small and doesnt cover this issue specifically. But in general hypermedia apis how do people usually present this data?

Or should I simply explain the field in the CURIE link? thanks

ChrisCa
  • 10,876
  • 22
  • 81
  • 118
  • Are the card types just names? What about a simple list of card type names? –  Mar 03 '16 at 15:09
  • yes - it will be a list of strings. Im just wondering about how to associate that list with a given field. so you know that field can only be a value from the list – ChrisCa Mar 03 '16 at 15:15

1 Answers1

0

You are right, HAL does not specifically cover this issue. You can solve this by essentially copying HTML. There are different widgets defined in HTML to present stuff, for example a combobox with listed options.

You can define a media-type that has similar controls in it, and you can define the processing model for the media-type as well. It can be a json representation of course, does not need to be xml.

For example

{
    ...
    "cardType": {
       "inputType": "select",
       "possibleValues": ["Visa", "MasterCard", ... ]
    }
    ...
}

There is no ready-made format that I know of unfortunately.

Robert Bräutigam
  • 7,514
  • 1
  • 20
  • 38