Create a gist now

Instantly share code, notes, and snippets.

@justinyoo /products.raml Secret
Last active May 13, 2017

What would you like to do?
API Mocking for Developers
#%RAML 1.0
title: Product API
version: v1
baseUri: https://myproduct.com/api
protocols:
- HTTPS
mediaType:
- application/json
types:
# Object used for request/response
product:
type: object
properties:
productId:
type: integer
required: false
name:
type: string
required: true
description:
type: string
required: false
price:
type: number
required: true
# Object used for error
error:
type: object
properties:
message:
type: string
required: true
/products:
displayName: Products
description: |
Handles product details as a whole
get:
description: |
Gets the list of products
responses:
200:
body:
type: product[]
# Sample response
example:
-
productId: 1
name: Product A
description: This is Product A
price: 12.34
-
productId: 2
name: Product B
description: This is Product B
price: 56.78
post:
body:
type: product
responses:
# Sample response
201:
body:
type: product
example:
productId: 3
name: Product A
description: This is Product A
price: 90.12
/{productId}:
displayName: Product
description: |
Handles individual product details
uriParameters:
productId:
type: integer
get:
description: |
Gets the product details corresponding to productId
responses:
200:
body:
type: product
# Sample response
example:
productId: 1
name: Product A
description: This is Product A
price: 12.34
404:
body:
type: error
# Sample response
example:
message: Product Not Found
patch:
description: |
Updates the product details corresponding to productId
responses:
200:
body:
type: product
# Sample response
example:
productId: 1
name: Product A
description: This is Product A
price: 12.34
404:
body:
type: error
# Sample response
example:
message: Product Not Found
delete:
description: |
Deletes the product details corresponding to productId
responses:
204:
body:
404:
body:
type: error
# Sample response
example:
message: Product Not Found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment