Skip to content

Instantly share code, notes, and snippets.

@ericzon
Created April 6, 2017 09:16
Show Gist options
  • Save ericzon/401781bbd216ec808065137de43ad4a2 to your computer and use it in GitHub Desktop.
Save ericzon/401781bbd216ec808065137de43ad4a2 to your computer and use it in GitHub Desktop.
RAML pet shop test
#%RAML 1.0
title: Pet Shop
uses:
NewLibrary: NewLibrary.raml
version: v1
baseUri: /shop
types:
Mammal:
type: NewLibrary.Pet
Bird:
type: NewLibrary.Pet
properties:
wingLength: number
resourceTypes:
/pets:
type: { NewLibrary.Collection: {item : NewLibrary.Pet} }
get:
is: [NewLibrary.FilterableByPrice]
queryParameters:
petKind:
enum: [bird, mammal]
/{id}:
type: { NewLibrary.Member: {item : NewLibrary.Pet} }
/birds:
type: { NewLibrary.Collection: {item : Bird} }
get:
is: NewLibrary.FilterableByPrice
/{id}:
type: { NewLibrary.Member: {item : Bird} }
/mammals:
type: { NewLibrary.Collection: {item : Mammal} }
get:
is: NewLibrary.FilterableByPrice
/{id}:
type: { NewLibrary.Member: {item : Mammal} }
#%RAML 1.0 Library
traits:
FilterableByPrice:
queryParameters:
priceLessThen?:
type: number
priceMoreThen?:
type: number
resourceTypes:
Collection:
get:
responses:
200:
body:
application/json:
type: <<item>>[]
post:
body:
application/json:
type: <<item>>
Member:
delete:
responses:
204:
put:
body:
application/json:
type: <<item>>
types:
Pet:
discriminator: kind
properties:
name: string
kind: string
price: number
color:
enum:
- White
- Black
- Colored
example:
name: Snoopy
kind: Mammal
price: 100
color: White
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment