Skip to content

Instantly share code, notes, and snippets.

@bendavis78
Created January 16, 2016 21:55
Show Gist options
  • Save bendavis78/30a3c281ca778a633b79 to your computer and use it in GitHub Desktop.
Save bendavis78/30a3c281ca778a633b79 to your computer and use it in GitHub Desktop.
# TODO:
# * Add authentication schemes
# * Venue registration
## http://docs.aws.amazon.com/cognito/devguide/identity/developer-authenticated-identities/
# * WePay workflow
swagger: '2.0'
info:
version: 1.0.0
title: All ATX
description: under development
contact:
name: Touch Titans
email: [email protected]
url: 'http://touchtitans.com'
x-apigateway-api-id: k0ykq5cjwa
host: api.allatx.org
basePath: /
schemes:
- https
consumes:
- application/json
produces:
- application/json
paths:
/bands:
x-lambda-function: band
post:
tags: [bands]
description: Creates a band
operationId: createBand
parameters:
- name: body
in: body
description: the band object
required: true
schema:
$ref: '#/definitions/band'
responses:
200:
description: the band was successfully created
schema:
$ref: '#/definitions/bandResource'
400:
description: validation error
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
/bands/{urlName}:
x-lambda-function: band
get:
tags: [bands]
operationId: getBand
description: Returns band details
parameters:
- name: urlName
type: string
in: path
required: true
description: 'unique URL name for the band, eg "black-keys"'
responses:
200:
description: band object
schema:
$ref: '#/definitions/bandResource'
404:
description: not found
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
put:
tags: [bands]
description: Creates or updates a band with the given urlName.
operationId: putBand
parameters:
- name: urlName
type: string
in: path
required: true
description: 'unique URL-name for the band, eg "black-keys"'
- name: body
in: body
description: the band object (all fields are required during PUT)
required: true
schema:
$ref: '#/definitions/band'
responses:
# API Gateway doesn't support more than one 2xx response. Fail.
200:
description: the band was successfully created or updated
schema:
$ref: '#/definitions/bandResourcePut'
400:
description: validation error
schema:
$ref: '#/definitions/error'
404:
description: not found
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
patch:
tags: [bands]
description: Updates the band with the given urlName.
operationId: updateBand
parameters:
- name: urlName
type: string
in: path
required: true
description: 'unique URL-name for the band, eg "black-keys"'
- name: body
in: body
description: an object containing properties to be updated
required: true
schema:
$ref: '#/definitions/band'
responses:
# API Gateway doesn't support more than one 2xx response. Fail.
200:
description: the band was successfully updated
schema:
$ref: '#/definitions/bandResource'
400:
description: validation error
schema:
$ref: '#/definitions/error'
404:
description: not found
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
delete:
tags: [bands]
operationId: deleteBand
description: Deletes the band with the given urlName
parameters:
- name: urlName
type: string
in: path
required: true
description: 'unique URL-name for the band, eg "black-keys"'
responses:
# API Gateway doesn't support more than one 2xx response. Fail.
200:
description: the band was successfully deleted
404:
description: not found
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
/bands/{urlName}/wepay-account:
x-lambda-function: wepay-account
post:
tags: [bands]
description: register a WePay account on behalf of the band
parameters:
- name: urlName
type: string
in: path
required: true
description: 'unique URL-name for the band, eg "black-keys"'
- name: body
in: body
description: WePay account registration details
required: true
schema:
$ref: '#/definitions/wepayAccount'
responses:
200:
description: the band was successfully created
400:
description: validation error
schema:
$ref: '#/definitions/error'
404:
description: band not found
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
delete:
tags: [bands]
operationId: deleteBand
description: Deletes the wepay account associated with the band (dev stage only)
parameters:
- name: urlName
type: string
in: path
required: true
description: 'unique URL-name for the band, eg "black-keys"'
responses:
# API Gateway doesn't support more than one 2xx response. Fail.
200:
description: the band was successfully deleted
404:
description: not found
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
/bands/{urlName}/tips:
x-lambda-function: tip
post:
tags: [bands]
operationId: payTip
description: make a tip payment to a band
paramters:
- name: urlName
type: string
in: path
required: true
description: 'unique URL-name for the band, eg "black-keys"'
- name: body
in: body
required: true
description: the payment info
schema:
$ref: '#/definitions/tipPayment'
responses:
200:
description: the payment was successfully submitted
404:
description: the band was not found, or the user's credit card
/venues:
x-lambda-function: venue
# TODO authorized only be user that has that venue id
post:
tags: [venues]
description: Creates a venue
operationId: createVenue
parameters:
- name: body
in: body
description: the venue object
required: true
scheme:
$ref '#definitions/venue'
responses:
200:
description: the venue was successfully created
schema:
$ref: '#/definitions/venueResource'
400:
description: validation error
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
/venues/{id}:
x-lambda-function: venue
get:
tags: [venues]
description: Returns venue details
operationId: getVendor
responses:
200:
description: venue object
schema:
type: array
items:
$ref: '#/definitions/venueResource'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
parameters:
- name: id
type: string
format: uuid
in: path
required: true
description: 'unique URL name for the band, eg "black-keys"'
put:
tags: [venues]
description: Creates or updates a venue with the given id
operationId: putVenue
parameters:
- name: id
type: string
format: uuid
in: path
required: true
description: venue id
- name: body
in: body
description: the venue object (all fields are required during PUT)
required: true
schema:
$ref: '#/definitions/venue'
responses:
200:
description: the venue was successfully created or updated
schema:
$ref: '#/definitions/venueResourcePut'
400:
description: validation error
schema:
$ref: '#/definitions/error'
404:
description: not found
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
patch:
tags: [venues]
description: Updates the venue with the given id.
operationId: updateVenue
parameters:
- name: id
type: string
format: uuid
in: path
required: true
description: 'Venue id'
- name: body
in: body
description: an object containing properties to be updated
required: true
schema:
$ref: '#/definitions/band'
responses:
# API Gateway doesn't support more than one 2xx response. Fail.
200:
description: the venue was successfully updated
schema:
$ref: '#/definitions/venueResource'
400:
description: validation error
schema:
$ref: '#/definitions/error'
404:
description: not found
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
delete:
tags: [venues]
operationId: deleteVenue
description: Deletes the venue with the given id
parameters:
- name: id
type: string
in: path
required: true
description: 'unique URL-name for the band, eg "black-keys"'
responses:
# API Gateway doesn't support more than one 2xx response. Fail.
200:
description: the band was successfully deleted
404:
description: not found
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
/credit-cards:
x-lambda-function: credit-card
get:
tags: [payments]
operationId: getCreditCards
description: get a list of previously-used credit cards for the authenticated user
resposes:
200:
description: a list of the user's previously-used credit cards
schema:
$ref: '#/definitions/creditCardList'
post:
tags: [payments]
operationId: addCreditCard
description: add a credit card for an authenticated user
parameters:
- name: body
in: body
required: true
description: the tokenized card information
schema:
$ref: '#/definitions/tokenizedCardInfo'
responses:
200:
description: the credit card was successfully created
schema:
$ref: '#/definitions/creditCardResource'
404:
description: not found
schema:
$ref: '#/definitions/error'
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
/credit-cards/${creditCardId}:
x-lambda-function: credit-card
get:
tags: [payments]
operationId: getCreditCard
description: get credit card details for the authenticated user
resposes:
200:
description: credit card
schema:
$ref: '#/definitions/creditCardResource'
delete:
tags: [payments]
description: delete an authenticated user's credit card
operationId: deleteCreditCard
parameters:
- name: creditCardId
type: integer
in: path
required: true
description: the card id to delete
responses:
200:
description: the credit card was successfully deleted
500:
description: unexpected error
schema:
$ref: '#/definitions/error'
definitions:
band:
type: object
required:
- urlName
- bandName
- description
- photo
properties:
urlName:
type: string
pattern: ^[a-z0-9-]+$
maxLength: 50
description: unique URL-name
bandName:
type: string
description: full band name
description:
type: string
maxLength: 500
description: a one-paragraph description of the band
photo:
type: string
format: uri
description: URL to the band's photo
genre:
type: string
maxLength: 50
description: genre or list of genres
similarTo:
type: string
description: other bands that are similar
website:
type: string
format: uri
description: "band's website"
bandResource:
properties:
url:
type: string
format: uri
data:
$ref: '#/definitions/band'
bandResourcePut:
properties:
url:
type: string
format: uri
created:
type: boolean
data:
$ref: '#/definitions/band'
venue:
type: object
required:
- venueName
- website
- email
- password
properties:
venueName:
type: string
website:
type: string
format: uri
email:
type: string
format: email
password:
type: string
venueResource:
properties:
url:
type: string
format: uri
data:
$ref: '#/definitions/venue'
venueResourcePut:
properties:
url:
type: string
format: uri
created:
type: boolean
data:
$ref: '#/definitions/venue'
wepayAccount:
type: object
required:
- bandUrlName
- email
- firstName
- lastName
- originalIp
- originalDevice
- acceptedTos
properties:
bandUrlName:
type: string
pattern: ^[a-z0-9-]+$
maxLength: 50
description: unique URL-name of the band
email:
type: string
format: email
description: the email address for the WePay account
firstName:
type: string
description: account holder's first name
lastName:
type: string
description: account holder's last name
originalIp:
type: string
description: the ip address of the user you want to register
originalDevice:
type: string
description: the user-agent (for web) or the IMEI (for mobile) of the user you want to register
tosAcceptanceTime:
type: integer
description: a Unix timestamp referencing the time the user accepted WePay's terms of service
tokenizedCardInfo:
type: object
required:
- creditCardId
properties:
creditCardId:
type: integer
description: the card id provided by wepay
creditCardList:
type: array
items:
$ref: '#/definitions/creditCard'
creditCard:
type: object
required:
- creditCardId
- userId
properties:
creditCardId:
type: integer
description: the card id provided by wepay
userID:
type: string
description: the user id associated with the card
creditCardName:
type: string
description: the string that identifies the credit card, eg "MasterCard xxxxxx4769"
userName:
type: string
description: the name on the card (eg "Bob Smith")
email:
type: string
description: the card owner's email address
createTime:
type: integer
description: a unix timestamp of when the credit_card was created
expirationMonth:
type: integer
description: the expiration month of the credit card (1-12)
expirationYear:
type: integer
description: the expiration year of the credit card
lastFour:
type: string
description: the last four digits of the card number
creditCardResource:
type: object
required:
- url
- creditCard
properties:
url:
type: string
format: uri
creditCard:
$ref: '#/definitions/creditCard'
tipPayment:
type: object
required:
- amount
properties:
amount:
type: float
description: the payment amount (in USD)
creditCardId:
type: integer
description: the user's credit card id, if not the default
performance:
type: object
required:
- title
- date
- time
properties:
title:
type: string
date:
type: string
format: date-time
time:
type: integer
format: int32
error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
x-request-templates:
application/json: |
{
"body" : $input.json('$'),
"method": "$context.httpMethod",
"resourcePath": "$context.resourcePath",
"stage": "$context.stage",
#if($context.identity)
"user": {
#foreach($key in $context.identity.keySet())
"$key": "$util.escapeJavaScript($context.identity.get($key))" #if($foreach.hasNext),#end
#end
},
#end
"headers": {
#foreach($header in $input.params().header.keySet())
"$header": "$util.escapeJavaScript($input.params().header.get($header))" #if($foreach.hasNext),#end
#end
},
"params": {
#foreach($param in $input.params().path.keySet())
"$param": "$util.escapeJavaScript($input.params().path.get($param))" #if($foreach.hasNext),#end
#end
},
"query": {
#foreach($queryParam in $input.params().querystring.keySet())
"$queryParam": "$util.escapeJavaScript($input.params().querystring.get($queryParam))" #if($foreach.hasNext),#end
#end
},
"env": {
#foreach($var in $stageVariables.keySet())
"$var": "$util.escapeJavaScript($stageVariables.get($var))" #if($foreach.hasNext),#end
#end
}
}
x-response-templates:
errors:
application/json: |
#set($error = $input.json('$.errorMessage'))
#set($error = $error.replaceAll('\\(.)', '$1'))
#set($error = $error.replaceAll('^"|"$', ''))
#set($error = $error.replaceAll('"status":\d+,?', ''))
$error
# vim: sw=2 ts=2 et
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment