Skip to content

Instantly share code, notes, and snippets.

@santouras
Created May 15, 2016 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santouras/febbdcb0fa71f2d9fb8be547b5e869fb to your computer and use it in GitHub Desktop.
Save santouras/febbdcb0fa71f2d9fb8be547b5e869fb to your computer and use it in GitHub Desktop.
Foosball swagger file
swagger: '2.0'
info:
title: Foosball API
description: Play games, calculate winners and losers.
version: "1.0.0"
# the domain of the service
host: api.playfoosball.com
# array of all schemes that your API supports
schemes:
- https
# will be prefixed to all paths
basePath: /v1
produces:
- application/vnd.api+json
consumes:
- application/vnd.api+json
paths:
/users:
get:
tags:
- user
summary: Get a list of users
produces:
- application/json
parameters:
- in: query
name: limit
description: How many users to return
required: false
type: integer
default: 12
- in: query
name: start
description: Starting record
required: false
type: integer
default: 0
responses:
200:
description: OK
schema:
$ref: '#/definitions/UserList'
default:
description: Unexpected Error
schema:
$ref: '#/definitions/Error'
post:
tags:
- user
summary: Create a user
responses:
201:
description: Created
schema:
$ref: '#/definitions/User'
/users/{user_id}:
parameters:
- in: path
name: user_id
type: integer
description: The user id
required: true
get:
tags:
- user
summary: Get a specific user
responses:
200:
description: OK
schema:
$ref: '#/definitions/UserData'
patch:
tags:
- user
summary: Update a user
responses:
204:
description: No Content
delete:
tags:
- user
summary: Delete a user
responses:
204:
description: No Content
/users/{user_id}/games:
parameters:
- in: path
name: user_id
type: integer
description: The user id
required: true
- in: query
name: limit
description: How many users to return
required: false
type: integer
default: 12
- in: query
name: start
description: Starting record
required: false
type: integer
default: 0
get:
tags:
- user
- game
summary: Get a list of games for this user
responses:
200:
description: OK
schema:
$ref: '#/definitions/GameList'
definitions:
User:
type: object
properties:
data:
$ref: '#/definitions/UserData'
UserList:
type: object
properties:
data:
type: array
items:
$ref: '#/definitions/User'
links:
type: object
properties:
first:
type: string
last:
type: string
next:
type: string
prev:
type: string
UserData:
type: object
properties:
type:
type: string
default: 'user'
id:
type: integer
attributes:
type: object
properties:
display_name:
type: string
description: The display name of the user.
first_name:
type: string
last_name:
type: string
points:
type: number
format: float
links:
type: object
properties:
self:
type: string
description: 'URI of this resource'
Game:
type: object
properties:
data:
$ref: '#/definitions/GameData'
included:
type: array
items:
$ref: '#/definitions/UserData'
GameList:
type: object
properties:
data:
type: array
items:
$ref: '#/definitions/Game'
GameData:
type: object
properties:
type:
type: string
default: 'game'
id:
type: integer
attributes:
type: object
properties:
score_user1:
type: integer
score_user2:
type: integer
points:
type: number
format: float
game_time:
type: string
format: date-time
links:
type: object
properties:
self:
type: string
description: 'URI of this resource'
Error:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
fields:
type: string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment