nquest/api/openapi.yaml

382 lines
8.6 KiB
YAML
Raw Normal View History

2023-11-01 23:21:12 +03:00
openapi: "3.1.0"
2023-11-01 23:21:12 +03:00
info:
version: 1.0.0
title: nQuest
2023-11-01 23:21:12 +03:00
servers:
- url: /api
2023-11-01 23:21:12 +03:00
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'
2023-11-02 23:38:50 +03:00
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'
2023-11-01 23:21:12 +03:00
/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'
2023-11-01 23:21:12 +03:00
/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 ]
2023-11-01 23:21:12 +03:00
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
2023-11-01 23:21:12 +03:00
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
2023-11-01 23:21:12 +03:00
responses:
200:
$ref: '#/components/responses/teamResponse'
404:
$ref: '#/components/responses/errorResponse'
# Game routes
/games:
get:
security: []
responses:
200:
$ref: '#/components/responses/gameListResponse'
2023-11-01 23:21:12 +03:00
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
2023-11-01 23:21:12 +03:00
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
2023-11-01 23:21:12 +03:00
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"
2023-11-01 23:21:12 +03:00
required:
- id
- username
- email
- role
2023-11-01 23:21:12 +03:00
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"
2023-11-01 23:21:12 +03:00
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"
2023-11-01 23:21:12 +03:00
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: session
security:
- cookieAuth: []