nquest/api/openapi.yaml

255 lines
5.8 KiB
YAML
Raw Normal View History

2023-11-01 23:21:12 +03:00
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'
/teams/{teamID}:
get:
parameters:
- in: path
name: teamID
schema:
type: integer
required: true
responses:
200:
$ref: '#/components/responses/teamResponse'
404:
$ref: '#/components/responses/errorResponse'
/teams/{teamID}/members:
post:
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
requestBody:
content:
'application/json':
schema:
userID:
type: integer
responses:
200:
$ref: '#/components/responses/teamResponse'
404:
$ref: '#/components/responses/errorResponse'
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
teamListItem:
type: object
properties:
id:
type: integer
name:
type: string
members:
type: integer
currentTeam:
type: boolean
createdAt:
type: string
required: [ id, name, members, currentTeam, createdAt ]
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 ]
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"
required:
- id
- username
- email
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/teamListItem'
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 ]
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: session
security:
- cookieAuth: []