RAML by Example
Published in

RAML by Example

Read the Spec

Arrays in query params

?foo=bar&foo=qux
?foo[]=bar&foo[]=qux # URL-encoded: ?foo%5B%5D=bar&foo%5B%5D=qux
?foo=bar,qux

Why so many different ways?

The “fields” example

JSON API

?fields[articles]=title,body&fields[people]=name
queryParameters:
/^fields\[[a-zA-Z]\]+$/: # matches `fields[<string>]`
type: string
pattern: “[^,]+” # matches both `title,body` and `name`

Bitbucket API

?fields=-*,+foo,+bar
queryParameters:
fields:
type: string
pattern: (-|\+)?[^,]+

Google Drive API

?fields=kind,items(title,characteristics/length)
queryParameters:
fields:
type: string
pattern: “[^,]+”

Using RAML Traits for fine-grained control

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store