nquest/api/openapi.yaml
2023-11-19 22:54:54 +03:00

405 lines
9.2 KiB
YAML

openapi: "3.1.0"
info:
version: 1.0.0
title: nQuest
servers:
- url: /api
paths:
# User routes
/user:
get:
responses:
200:
$ref: '#/components/responses/userResponse'
403:
$ref: '#/components/responses/errorResponse'
/user/login:
post:
security: []
requestBody:
$ref: '#/components/requestBodies/login'
responses:
200:
$ref: '#/components/responses/userResponse'
400:
$ref: '#/components/responses/errorResponse'
/user/register:
post:
security: []
requestBody:
$ref: '#/components/requestBodies/register'
responses:
200:
$ref: '#/components/responses/userResponse'
400:
$ref: '#/components/responses/errorResponse'
/user/logout:
post:
security: []
responses:
204:
description: "success logout"
400:
$ref: '#/components/responses/errorResponse'
# Team routes
/teams:
get:
responses:
200:
$ref: '#/components/responses/teamsListResponse'
403:
$ref: '#/components/responses/errorResponse'
post:
requestBody:
content:
'application/json':
schema:
type: object
properties:
name:
type: string
required: [ name ]
responses:
200:
$ref: '#/components/responses/teamResponse'
404:
$ref: '#/components/responses/errorResponse'
/teams/{teamID}:
get:
parameters:
- in: path
name: teamID
schema:
type: integer
required: true
responses:
200:
$ref: '#/components/responses/teamResponse'
404:
$ref: '#/components/responses/errorResponse'
delete:
parameters:
- in: path
name: teamID
schema:
type: integer
required: true
responses:
204:
description: ''
403:
$ref: '#/components/responses/errorResponse'
/teams/{teamID}/members:
post:
parameters:
- in: path
name: teamID
schema:
type: integer
required: true
requestBody:
content:
'application/json':
schema:
type: object
properties:
members:
type: array
items:
type: integer
required: [ members ]
responses:
200:
$ref: '#/components/responses/teamResponse'
404:
$ref: '#/components/responses/errorResponse'
delete:
parameters:
- in: path
name: teamID
schema:
type: integer
required: true
responses:
200:
$ref: '#/components/responses/teamResponse'
404:
$ref: '#/components/responses/errorResponse'
/teams/{teamID}/requests/{userID}:
post:
parameters:
- in: path
name: teamID
schema:
type: integer
required: true
- in: path
name: userID
schema:
type: integer
required: true
requestBody:
content:
'application/json':
schema:
type: object
properties:
approve:
type: boolean
required: [ approve ]
responses:
200:
$ref: '#/components/responses/teamResponse'
404:
$ref: '#/components/responses/errorResponse'
/teams/{teamID}/requests:
post:
parameters:
- in: path
name: teamID
schema:
type: integer
required: true
responses:
200:
$ref: '#/components/responses/teamResponse'
404:
$ref: '#/components/responses/errorResponse'
/admin/games:
get:
security:
- cookieAuth: [creator, admin]
responses:
200:
$ref: "#/components/responses/gameAdminList"
# Game routes
/games:
get:
security: []
responses:
200:
$ref: '#/components/responses/gameListResponse'
components:
schemas:
userTeam:
type: object
properties:
id:
type: integer
name:
type: string
role:
$ref: "#/components/schemas/userTeamRole"
required: [ id, name, role ]
userTeamRole:
type: string
enum:
- member
- captain
userRole:
type: string
enum:
- notVerified
- user
- creator
- admin
teamMember:
type: object
properties:
user:
$ref: "#/components/schemas/userView"
role:
$ref: "#/components/schemas/userTeamRole"
createdAt:
type: string
required: [ user, role, createdAt ]
teamRequest:
type: object
properties:
user:
$ref: "#/components/schemas/userView"
createdAt:
type: string
required: [ user, role, createdAt ]
userView:
type: object
properties:
id:
type: integer
username:
type: string
required: [ id, username ]
teamView:
type: object
properties:
id:
type: integer
name:
type: string
members:
type: integer
currentTeam:
type: boolean
createdAt:
type: string
required: [ id, name, createdAt ]
gameView:
type: object
properties:
id:
type: integer
title:
type: string
description:
type: string
startAt:
type: string
teams:
type: array
items:
$ref: "#/components/schemas/teamView"
required:
- id
- title
- description
- startAt
- teams
gameAdminListItem:
type: object
properties:
id:
type: integer
title:
type: string
createdAt:
type: string
required: [ id, title, createdAt ]
requestBodies:
login:
required: true
content:
'application/json':
schema:
type: object
properties:
email:
type: string
password:
type: string
required: [ email, password ]
register:
required: true
content:
'application/json':
schema:
type: object
properties:
username:
type: string
email:
type: string
password:
type: string
password2:
type: string
required: [ username, email, password, password2 ]
responses:
userResponse:
description: ''
content:
'application/json':
schema:
type: object
properties:
id:
type: integer
username:
type: string
email:
type: string
team:
$ref: "#/components/schemas/userTeam"
role:
$ref: "#/components/schemas/userRole"
required:
- id
- username
- email
- role
errorResponse:
description: ''
content:
'application/json':
schema:
type: object
properties:
code:
type: integer
message:
type: string
required: [ code, message ]
teamsListResponse:
description: ''
content:
'application/json':
schema:
type: array
items:
$ref: "#/components/schemas/teamView"
teamResponse:
description: ''
content:
'application/json':
schema:
type: object
properties:
id:
type: integer
name:
type: string
members:
type: array
items:
$ref: "#/components/schemas/teamMember"
requests:
type: array
items:
$ref: "#/components/schemas/teamRequest"
createdAt:
type: string
required: [ id, name, members, requests, createdAt ]
gameListResponse:
description: ''
content:
'application/json':
schema:
type: array
items:
$ref: "#/components/schemas/gameView"
gameResponse:
description: ''
content:
'application/json':
schema:
$ref: "#/components/schemas/gameView"
gameAdminList:
description: ''
content:
'application/json':
schema:
type: array
items:
$ref: "#/components/schemas/gameAdminListItem"
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: session
security:
- cookieAuth: []