Skip to content

Instantly share code, notes, and snippets.

@baronfel
Last active August 29, 2015 14:03
Show Gist options
  • Save baronfel/8b1fbfae235e5084b17a to your computer and use it in GitHub Desktop.
Save baronfel/8b1fbfae235e5084b17a to your computer and use it in GitHub Desktop.
Example of a RAML description for a REST API dealing with songs.
#%RAML 0.8
title: World Music API
baseUri: http://example.api.com/{version}
version: v1
traits:
- paged:
queryParameters:
pages:
description: The number of pages to return
type: number
- secured: !include http://raml-example.com/secured.yml
/songs:
is: [ paged, secured ]
get:
queryParameters:
genre:
description: filter the songs by genre
post:
/{songId}:
get:
responses:
200:face
body:
application/json:
schema: |
{ "$schema": "http://json-schema.org/schema",
"type": "object",
"description": "A canonical song",
"properties": {
"title": { "type": "string" },
"artist": { "type": "string" }
},
"required": [ "title", "artist" ]
}
application/xml:
delete:
description: |
This method will *delete* an **individual song**"
module AST
type RamlDef = {
version : float
}
open FParsec
open AST
open parser
match run parser.raml "#%RAML 0.8" with
| Success raml,_,_ -> printfn "success"
| Failure errorStr,ex,state -> printrn "failure :("
open FParsec
let versionSentinel = skipString "#%RAML"
open FParsec
let versionSentinel = skipString "#%RAML"
let advanceToEOL = restOfLine true
let ramlVer = versionSentinel .>> ws >>. pfloat .>> advanceToEOL
open FParsec
open AST
let versionSentinel = skipString "#%RAML"
let advanceToEOL = restOfLine true
let ramlVer = versionSentinel .>> ws >>. pfloat .>> advanceToEOL
let makeRamlDef version =
{
version = version
}
let raml = ramlVer |>> makeRamlDef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment