Created
July 16, 2016 18:15
-
-
Save programmarchy/104efdf5ad6ff45b76a8edc199168db8 to your computer and use it in GitHub Desktop.
The Siren specification in Swift protocols
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
// Siren: a hypermedia specification for representing entities | |
// https://github.com/kevinswiber/siren | |
protocol SirenRoot: SirenEntity {} | |
protocol SirenEntity { | |
var classNames: [String]? { get } | |
var properties: [String: AnyObject]? { get } | |
var entities: [SirenSubEntityType]? { get } | |
var links: [SirenLink]? { get } | |
var actions: [SirenAction]? { get } | |
var title: String? { get } | |
} | |
typealias SirenSubEntityType = SirenSubEntity<SirenLink, SirenEmbeddedEntity> | |
enum SirenSubEntity<Link, Entity> { | |
case embeddedLink(Link) | |
case embeddedEntity(Entity) | |
} | |
protocol SirenEmbeddedEntity: SirenEntity { | |
var rel: [String] { get } | |
} | |
protocol SirenLink { | |
var rel: [String] { get } | |
var classNames: [String]? { get } | |
var href: String { get } | |
var hrefURL: NSURL { get } | |
var title: String? { get } | |
var type: String? { get } | |
} | |
protocol SirenAction { | |
var name: String { get } | |
var classNames: [String]? { get } | |
var method: String { get } | |
var title: String? { get } | |
var href: String { get } | |
var hrefURL: NSURL { get } | |
var type: String? { get } | |
var fields: [SirenField]? { get } | |
} | |
protocol SirenField { | |
var name: String { get } | |
var classNames: [String]? { get } | |
var type: String { get } | |
var value: AnyObject? { get } | |
var title: AnyObject? { get } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment