Last active
January 27, 2017 16:49
-
-
Save battermann/724e6db91aea7b2c3eb6332183ad34a8 to your computer and use it in GitHub Desktop.
An F# representation of the Siren media type https://github.com/kevinswiber/siren
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Siren | |
open System | |
open Hypermedia.Models | |
type Rel = Rel of string | |
type Title = Title of string | |
type Class = Class of string | |
type MediaType = MediaType of string | |
type Href = Href of Uri | |
type Name = Name of string | |
type Value = Value of string | |
type HttpMethod = GET | PUT | POST | DELETE | PATCH | |
type InputType = | |
| Hidden | Text | Search | Tel | Url | Email | Password | |
| Datetime | Date | Month | Week | Time | DatetimeLocal | Number | |
| Range | Color | Checkbox | Radio | File | |
type Field = { | |
classes: Class list | |
inputTpye: InputType option | |
value: Value option | |
title: Title option | |
} | |
type Action = { | |
classes: Class list | |
httpMethod: HttpMethod option | |
href: Href | |
title: Title option | |
mediaType: MediaType option | |
fields: Map<Name, Field> | |
} | |
type Link = { | |
href: Href | |
rel: Rel * Rel list | |
classes: Class list | |
title: Title option | |
mediaType: MediaType option | |
} | |
type Entity<'a> = { | |
properties: Map<Name, AbstractJsonObject<'a>> | |
entities: SubEntity<'a> list | |
actions: Map<Name, Action> | |
links: Link list | |
classes: Class list | |
title: Title option | |
} | |
and SubEntity<'a> = | |
| EmbeddedRepresentation of Entity<'a> * Rel | |
| EmbeddeLink of Link |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment