Skip to content

Instantly share code, notes, and snippets.

@samuelgoto
Last active September 11, 2017 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelgoto/2fa79d168a1c0a0c419f4fce870c642e to your computer and use it in GitHub Desktop.
Save samuelgoto/2fa79d168a1c0a0c419f4fce870c642e to your computer and use it in GitHub Desktop.
A hypermedia API type

An exploration of a hypermedia API type with a syntax inspired by kotlin builders.

Main optimization factor here is to find a data format that is better at intermingling structure and semantics.

{
  itemtype: "http://schema.org/LocalBusiness"
  itemscope: true,
  name: "Cascal",
  address: "1234 Castro St, Mountain View, CA",

  form {
    itemprop: "potentialAction",
    itemscope: true,
    itemtype: "http://schema.org/ReserveAction",
    
    select {
      name: "size",
      itemprop: "partySize",
      caption { "Select your party size" }
      option { "1", "2", "3", "..." }
    }

    input {
      type: "date",
      name: "date",
      itemprop: "scheduleDate"
    }

    select {
      name: "time",
      itemprop: "scheduledTime",

      caption { "What time?" }
      option { "7pm", "8pm", "9pm", "..." }
    }   
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment