gamenight/backend-actix/gamenight-api.yaml

329 lines
8.2 KiB
YAML

openapi: 3.0.0
info:
title: Gamenight
version: '1.0'
contact:
name: Dennis Brentjes
email: dennis@brentj.es
url: 'https://brentj.es'
description: Api specifaction for a Gamenight server
license:
name: MIT
servers:
- url: 'http://localhost:8080'
description: Gamenight
paths:
/token:
get:
summary: ''
operationId: get-token
responses:
'200':
$ref: '#/components/responses/TokenResponse'
'401':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/LoginRequest'
description: Submit your credentials to get a JWT-token to use with the rest of the api.
parameters: []
/user:
post:
summary: ''
operationId: post-register
requestBody:
$ref: '#/components/requestBodies/RegisterRequest'
responses:
'200':
description: ''
'422':
$ref: '#/components/responses/FailureResponse'
description: 'Create a new user given a registration token and user information, username and email must be unique, and password and password_repeat must match.'
parameters: []
security:
- JWT-Auth: []
get:
description: 'Get a user from primary id'
requestBody:
$ref: '#/components/requestBodies/GetUserRequest'
parameters: []
responses:
'200':
$ref: '#/components/responses/UserResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'404':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/gamenights:
get:
summary: Get a all gamenights
responses:
'200':
$ref: '#/components/responses/GamenightsResponse'
'400':
$ref: '#/components/responses/FailureResponse'
'401':
$ref: '#/components/responses/FailureResponse'
operationId: get-gamenights
security:
- JWT-Auth: []
description: Retrieve the list of gamenights on this gamenight server. Requires authorization.
/participants:
get:
summary: Get all participants for a gamenight
responses:
'200':
$ref: '#/components/responses/ParticipantsResponse'
'400':
$ref: '#/components/responses/FailureResponse'
'401':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/GetParticipants'
security:
- JWT-Auth: []
description: Retrieve the participants of a single gamenight by id.
/gamenight:
post:
summary: ''
operationId: post-gamenight
responses:
'200':
description: OK
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
requestBody:
$ref: '#/components/requestBodies/AddGamenight'
description: 'Add a gamenight by providing a name and a date, only available when providing an JWT token.'
get:
summary: ''
operationId: get-gamenight
responses:
'200':
$ref: '#/components/responses/GamenightResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/GetGamenight'
security:
- JWT-Auth: []
/join:
post:
responses:
'200':
description: OK
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/JoinGamenight'
security:
- JWT-Auth: []
components:
schemas:
Gamenight:
title: Gamenight
type: object
properties:
id:
type: string
name:
type: string
datetime:
type: string
owner_id:
type: string
required:
- id
- name
- datetime
- owner_id
Participants:
title: participants
type: object
properties:
participants:
type: array
items:
type: string
required:
- participants
Failure:
title: Failure
type: object
properties:
message:
type: string
description: 'Failure Reason'
Token:
title: Token
type: object
properties:
jwt_token:
type: string
Login:
title: Login
type: object
properties:
username:
type: string
password:
type: string
required:
- username
- password
Registration:
title: Registration
type: object
properties:
username:
type: string
email:
type: string
password:
type: string
password_repeat:
type: string
registration_token:
type: string
required:
- username
- email
- password
- password_repeat
- registration_token
UserId:
title: UserId
type: object
properties:
user_id:
type: string
required:
- user_id
AddGamenightRequestBody:
title: AddGamenightRequestBody
type: object
properties:
name:
type: string
datetime:
type: string
GamenightId:
title: GamenightId
type: object
properties:
gamenight_id:
type: string
required:
- gamenight_id
GetGamenightRequestBody:
type: object
properties:
id:
type: string
User:
type: object
properties:
id:
type: string
username:
type: string
email:
type: string
required:
- id
- username
requestBodies:
LoginRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/Login'
RegisterRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/Registration'
GetUserRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/UserId'
AddGamenight:
content:
application/json:
schema:
$ref: '#/components/schemas/AddGamenightRequestBody'
GetGamenight:
content:
application/json:
schema:
$ref: '#/components/schemas/GetGamenightRequestBody'
GetParticipants:
content:
application/json:
schema:
$ref: '#/components/schemas/GamenightId'
JoinGamenight:
content:
application/json:
schema:
$ref: '#/components/schemas/GamenightId'
responses:
TokenResponse:
description: Example response
content:
application/json:
schema:
$ref: '#/components/schemas/Token'
FailureResponse:
description: Example response
content:
application/json:
schema:
$ref: '#/components/schemas/Failure'
ParticipantsResponse:
description: Response with a list of participant uuids
content:
application/json:
schema:
$ref: '#/components/schemas/Participants'
GamenightsResponse:
description: Example response
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Gamenight'
GamenightResponse:
description: A gamenight being hosted
content:
application/json:
schema:
$ref: '#/components/schemas/Gamenight'
UserResponse:
description: A user in the gamenight system
content:
application/json:
schema:
$ref: '#/components/schemas/User'
securitySchemes:
JWT-Auth:
type: http
scheme: bearer
bearerFormat: JWT
description: ''