swagger: '2.0' info: description: 'This is a werewolf game engine for REST access. It is primarily developed for CPE200 class at Computer Engineering, Chiang Mai University.' version: 0.1.1 title: Werewolf Engine contact: email: pruetboonma@gmail.com license: name: Apache 2.0 url: 'http://www.apache.org/licenses/LICENSE-2.0.html' host: 'project-ile.net:1038' basePath: /v1 tags: - name: player description: Everything about your player. - name: role description: Game's role that will be play by each player. - name: game description: 'Individual game, either playing, played or ready to play.' schemes: - https - http paths: /player: get: tags: - player summary: Get list of players produces: - application/json responses: '200': description: successful operation schema: type: array items: $ref: '#/definitions/Player' '400': description: Invalid input post: tags: - player summary: Add a new player to the system description: '' operationId: addPlayer consumes: - application/json produces: - application/json parameters: - in: body name: body description: Player object that needs to be added to the system required: true schema: $ref: '#/definitions/Player' responses: '201': description: Player added successfully schema: $ref: '#/definitions/Player' '400': description: Invalid input '403': description: Player already exists put: tags: - player summary: Update an existing player description: '' operationId: updatePlayer consumes: - application/json produces: - application/json parameters: - in: body name: body description: Player object that needs to be added to the system required: true schema: $ref: '#/definitions/Player' responses: '200': description: Update sucessfull '400': description: Invalid ID supplied '404': description: Player not found /player/login: post: tags: - player summary: Login into a player account description: '' operationId: loginPlayer consumes: - application/json produces: - application/json parameters: - in: body name: body description: Player object that at least contains login/password required: true schema: $ref: '#/definitions/Player' responses: '201': description: Login Successfully schema: $ref: '#/definitions/Player' '400': description: Invalid input '404': description: Player not found or invalid password '/player/logout/{sessionID}': get: tags: - player summary: Player logout operationId: logoutPlayer produces: - application/json parameters: - name: sessionID in: path description: ID of player's session to logout required: true type: string responses: '200': description: successful operation schema: type: array items: $ref: '#/definitions/Player' '400': description: Invalid data '404': description: player not found '/player/findByGame/{gameID}': get: tags: - player summary: Finds Players by game operationId: findPlayersByGame produces: - application/json parameters: - name: gameID in: path description: Game id required: true type: string responses: '200': description: successful operation schema: type: array items: $ref: '#/definitions/Player' '404': description: Invalid game id '/player/{playerId}': get: tags: - player summary: Find player by ID description: Returns a single player operationId: getPlayerById produces: - application/json parameters: - name: playerId in: path description: ID of player to return required: true type: integer format: int64 responses: '200': description: successful operation schema: $ref: '#/definitions/Player' '404': description: Player not found delete: tags: - player summary: Deletes a player description: '' operationId: deletePlayer produces: - application/json parameters: - name: playerId in: path description: Player id to delete required: true type: integer format: int64 responses: '200': description: Player deleted '404': description: Player not found /role: get: tags: - role summary: Get list of roles produces: - application/json responses: '200': description: successful operation schema: type: array items: $ref: '#/definitions/Role' '400': description: Invalid input '/role/{roleId}': get: tags: - role summary: Find role by ID description: Returns a single role operationId: getRoleById produces: - application/json parameters: - name: roleId in: path description: ID of role to return required: true type: integer format: int64 responses: '200': description: successful operation schema: $ref: '#/definitions/Role' '400': description: Invalid ID supplied /action: get: tags: - action summary: Get list of actions produces: - application/json responses: '200': description: successful operation schema: type: array items: $ref: '#/definitions/Action' '400': description: Invalid input '/action/{actionID}': get: tags: - action summary: Find action by ID description: Returns a single action operationId: getActionById produces: - application/json parameters: - name: actionID in: path description: ID of action to return required: true type: integer format: int64 responses: '200': description: successful operation schema: $ref: '#/definitions/Action' '400': description: Invalid ID supplied '/action/findByRole/{roleId}': get: tags: - action summary: Finds actions by roleId operationId: findActionsByRoleId produces: - application/json parameters: - name: roleId in: path description: Role Id to find actions required: true type: integer format: int64 responses: '200': description: successful operation schema: type: array items: $ref: '#/definitions/Action' '400': description: Invalid role Id value /game: get: tags: - game summary: Get list of games produces: - application/json responses: '200': description: successful operation schema: type: array items: $ref: '#/definitions/Game' '400': description: Invalid input '/game/{gameId}': get: tags: - game summary: Find game by ID description: Returns a single game operationId: getGameById produces: - application/json parameters: - name: gameId in: path description: ID of game to return required: true type: integer format: int64 responses: '200': description: successful operation schema: $ref: '#/definitions/Game' '400': description: Invalid ID supplied '404': description: Game not found '/game/session/{sessionID}': get: tags: - game summary: Get game session description: Get game session information produces: - application/json parameters: - name: sessionID in: path description: ID of player'session to get game information required: true type: string responses: '200': description: successful operation schema: $ref: '#/definitions/Game' '400': description: Invalid session '404': description: Game not found post: tags: - game summary: Join a game description: Join an available game as a player produces: - application/json parameters: - name: sessionID in: path description: ID of player'session to join game required: true type: string responses: '201': description: successful operation schema: $ref: '#/definitions/Game' '400': description: Invalid data '403': description: No game to play '404': description: User in game already delete: tags: - game summary: Leave a game description: Leave game as a player produces: - application/json parameters: - name: sessionID in: path description: ID of player'session to leave game required: true type: string responses: '200': description: successful operation schema: $ref: '#/definitions/Game' '400': description: Invalid ID supplied '/game/action/{sessionID}/{actionID}/{targetID}': post: tags: - game summary: Perform action on a game description: Perform action of a user on a game produces: - application/json parameters: - name: sessionID in: path description: ID of player'session to perform action required: true type: string - name: actionID in: path description: ID of action to perform required: true type: integer format: int64 - name: targetID in: path description: ID of target of the action required: true type: integer format: int64 responses: '201': description: successful operation schema: $ref: '#/definitions/Game' '400': description: 'Invalid ID supplied, check error response' '404': description: Player not found '405': description: Action not found '406': description: Target not found '407': description: Perform on yourself '408': description: Not in game '409': description: Processing period '410': description: Game not playable '/chat/{sessionID}': post: tags: - chat summary: Post a message to game description: Post a message to game consumes: - application/json produces: - application/json parameters: - name: sessionID in: path description: ID of player'session to perform chat required: true type: string - in: body name: body description: Chat message object to post to the game required: true schema: $ref: '#/definitions/ChatMessage' responses: '200': description: successful operation '400': description: Invalid data '403': description: Player is not alive '404': description: Player not found '405': description: Player is not in game '406': description: Player is not allow to chat now '/chat/{sessionID}/{chatID}': get: tags: - chat summary: Retrieve list of chat messages produces: - application/json parameters: - name: sessionID in: path description: ID of player'session to perform chat required: true type: string - name: chatID in: path description: 'First chat message ID to retrieve, 0 for all message' required: true type: integer format: int64 responses: '200': description: successful operation schema: type: array items: $ref: '#/definitions/ChatMessage' '400': description: Invalid data '403': description: Player is not alive '404': description: Player not found '405': description: Player is not in game '406': description: Player is not in game definitions: Player: type: object required: - name - password - status properties: id: type: integer format: int64 name: type: string example: Anonymous Coward password: type: string game: $ref: '#/definitions/Game' role: $ref: '#/definitions/Role' session: type: string status: type: string description: Player status in a game enum: - alive - offline - not in game - votedead - shotdead - jaildead - holydead - killdead Role: type: object required: - name properties: id: type: integer format: int64 name: type: string example: Werewolf description: type: string actions: type: array items: $ref: '#/definitions/Action' type: type: string enum: - Villager - Wolf - Neutral Action: type: object required: - name properties: id: type: integer format: int64 name: type: string example: Vote roles: type: array items: $ref: '#/definitions/Role' description: type: string outcome: type: string enum: - Target Dead - Player Dead - Other Player Dead - Nothing Happened - Action Performed - Enchanted - Jailed - Revealed - Unknown - Werewolf - Villager - Not Valid Action - Target Is Not Alived target: type: string ChatMessage: type: object required: - message properties: id: type: integer format: int64 gameid: type: integer format: int64 playerid: type: integer format: int64 message: type: string channel: type: string description: Chat channel enum: - wolf - village - jail - dead Game: type: object properties: id: type: integer format: int64 hash: type: string day: type: integer format: int8 status: type: string description: Game status in the system enum: - playing - waiting - ended period: enum: - day - night - processing outcome: enum: - villagerwin - werewolfwin - foolwin - headhunterwin - serialkillerwin - nowin players: type: array items: $ref: '#/definitions/Player'