Converted the Api to a Restful api.

This commit is contained in:
2026-01-22 22:51:03 +01:00
parent 79ba1e1b44
commit ea9ad80336
34 changed files with 1779 additions and 1497 deletions

View File

@@ -14,9 +14,9 @@ servers:
description: Gamenight
paths:
/token:
get:
summary: ''
operationId: get-token
post:
summary: 'Login a user.'
operationId: post-token
responses:
'200':
$ref: '#/components/responses/TokenResponse'
@@ -26,9 +26,10 @@ paths:
$ref: '#/components/requestBodies/LoginRequest'
description: Submit your credentials to get a JWT-token to use with the rest of the api.
parameters: []
/refresh_token:
post:
summary: ''
operationId: post-token
summary: 'Refresh a user token'
operationId: post-refresh-tokenz
responses:
'200':
$ref: '#/components/responses/TokenResponse'
@@ -40,6 +41,7 @@ paths:
- JWT-Auth: []
/users:
get:
summary: 'Get all users'
responses:
'200':
$ref: '#/components/responses/UsersResponse'
@@ -48,11 +50,10 @@ paths:
'401':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/user:
- JWT-Auth: []
post:
summary: ''
operationId: post-register
summary: 'Registers a user into gamenight.'
operationId: post-user
requestBody:
$ref: '#/components/requestBodies/RegisterRequest'
responses:
@@ -61,18 +62,23 @@ paths:
'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: []
parameters: [ ]
security:
- JWT-Auth: []
- JWT-Auth: [ ]
/user/{userId}:
get:
description: 'Get a user from primary id'
requestBody:
$ref: '#/components/requestBodies/GetUserRequest'
parameters: []
parameters:
- in: path
name: userId
schema:
type: string
required: true
description: Uuid of user to get
responses:
'200':
$ref: '#/components/responses/UserResponse'
'401':
'401':
$ref: '#/components/responses/FailureResponse'
'404':
$ref: '#/components/responses/FailureResponse'
@@ -80,6 +86,25 @@ paths:
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/user/{userId}/owned_games:
get:
summary: Get owned games of user
parameters:
- in: path
name: userId
schema:
type: string
required: true
description: Uuid of user to get owned games for.
responses:
'200':
$ref: '#/components/responses/OwnedGamesResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: [ ]
/gamenights:
get:
summary: Get a all gamenights
@@ -94,9 +119,51 @@ paths:
security:
- JWT-Auth: []
description: Retrieve the list of gamenights on this gamenight server. Requires authorization.
/participants:
post:
summary: 'Gets the gamenight'
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.'
/gamenight/{gamenightId}:
get:
summary: ''
parameters:
- in: path
name: gamenightId
schema:
type: string
required: true
description: Uuid of gamenight to get.
operationId: get-gamenight
responses:
'200':
$ref: '#/components/responses/GamenightResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/gamenight/{gamenightId}/participants:
get:
summary: Get all participants for a gamenight
parameters:
- in: path
name: gamenightId
schema:
type: string
required: true
description: Uuid of gamenight to get participants for.
responses:
'200':
$ref: '#/components/responses/ParticipantsResponse'
@@ -107,40 +174,17 @@ paths:
requestBody:
$ref: '#/components/requestBodies/GetParticipants'
security:
- JWT-Auth: []
- 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:
summary: Add a participant
parameters:
- in: path
name: gamenightId
schema:
type: string
required: true
description: Uuid of gamenight to add participants for.
responses:
'200':
description: OK
@@ -149,11 +193,24 @@ paths:
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/JoinGamenight'
$ref: '#/components/requestBodies/UserIdRequestBody'
security:
- JWT-Auth: []
/leave:
post:
/gamenight/{gamenightId}/participant/{userId}:
delete:
parameters:
- in: path
name: gamenightId
schema:
type: string
required: true
description: Uuid of gamenight to delete participant for
- in: path
name: userId
schema:
type: string
required: true
description: Uuid of the of the participant to remove
responses:
'200':
description: "OK"
@@ -164,7 +221,7 @@ paths:
requestBody:
$ref: '#/components/requestBodies/LeaveGamenight'
security:
- JWT-Auth: []
- JWT-Auth: [ ]
/games:
get:
responses:
@@ -176,21 +233,8 @@ paths:
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/game:
get:
responses:
'200':
$ref: '#/components/responses/GameResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/GetGameRequest'
security:
- JWT-Auth: []
post:
responses:
responses:
'200':
$ref: '#/components/responses/GameIdResponse'
'401':
@@ -199,9 +243,36 @@ paths:
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/AddGameRequest'
security:
- JWT-Auth: [ ]
/game/{gameId}:
get:
summary: Get this specific game
parameters:
- in: path
name: gameId
schema:
type: string
required: true
description: Uuid of game to get.
responses:
'200':
$ref: '#/components/responses/GameResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
delete:
summary: Delete this game.
parameters:
- in: path
name: gameId
schema:
type: string
required: true
description: Uuid of game to delete.
responses:
'200':
description: "Ok"
@@ -213,8 +284,15 @@ paths:
$ref: '#/components/requestBodies/RemoveGameRequest'
security:
- JWT-Auth: [ ]
/rename_game:
post:
put:
summary: Changes this game resource
parameters:
- in: path
name: gameId
schema:
type: string
required: true
description: Uuid of game to change.
responses:
'200':
description: "OK"
@@ -223,11 +301,46 @@ paths:
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/RenameGameRequest'
$ref: '#/components/requestBodies/EditGameRequest'
security:
- JWT-Auth: []
/own:
/game/{gameId}/owners:
post:
summary: Own this game
parameters:
- in: path
name: gameId
schema:
type: string
required: true
description: Uuid of game to own.
requestBody:
$ref: '#/components/requestBodies/OwnGameRequestBody'
responses:
'200':
description: "OK"
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/game/{gameId}/owner/{userId}:
delete:
summary: Own this game
parameters:
- in: path
name: gameId
schema:
type: string
required: true
description: Uuid of game that user no longer owns.
- in: path
name: userId
schema:
type: string
required: true
description: Uuid of user that no longer owns.
responses:
'200':
description: "OK"
@@ -235,59 +348,6 @@ paths:
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/OwnGameRequest'
security:
- JWT-Auth: []
/disown:
post:
responses:
'200':
description: "OK"
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/DisownGameRequest'
security:
- JWT-Auth: []
/owned_games:
get:
responses:
'200':
$ref: "#/components/responses/GameIdsResponse"
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/OwnedGamesRequest'
security:
- JWT-Auth: []
/location:
get:
responses:
'200':
$ref: '#/components/responses/LocationResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/GetLocationRequest'
security:
- JWT-Auth: []
post:
responses:
'200':
$ref: '#/components/responses/LocationIdResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/AddLocationRequest'
security:
- JWT-Auth: []
/locations:
@@ -300,9 +360,66 @@ paths:
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/location_authorize:
- JWT-Auth: [ ]
post:
responses:
'200':
$ref: '#/components/responses/LocationIdResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/AddLocationRequest'
security:
- JWT-Auth: [ ]
/location/{locationId}:
get:
summary: gets this location
parameters:
- in: path
name: locationId
schema:
type: string
required: true
description: Uuid of location to get.
responses:
'200':
$ref: '#/components/responses/LocationResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/location/{locationId}/authorized_users/:
get:
summary: gets this locations authorized users
parameters:
- in: path
name: locationId
schema:
type: string
required: true
description: Uuid of location to get authorized users for.
responses:
'200':
$ref: "#/components/responses/UserIdsResponse"
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: [ ]
post:
summary: Authorize a user
parameters:
- in: path
name: locationId
schema:
type: string
required: true
description: Uuid location to authorize for.
responses:
'200':
description: 'Ok'
@@ -311,22 +428,34 @@ paths:
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/AuthorizeLocationRequest'
$ref: '#/components/requestBodies/UserIdRequestBody'
security:
- JWT-Auth: []
/authorized_location_user_ids:
get:
responses:
/location/{locationId}/authorized_user/{userId}:
delete:
parameters:
- in: path
name: locationId
schema:
type: string
required: true
description: Uuid of location to deauthorize for.
- in: path
name: userId
schema:
type: string
required: true
description: Uuid of user ot deauthorize.
responses:
'200':
$ref: "#/components/responses/UserIdsResponse"
description: 'Ok'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/AuthorizedLocationUserIdsRequest'
security:
- JWT-Auth: []
- JWT-Auth: [ ]
components:
schemas:
Gamenight:
@@ -410,15 +539,28 @@ components:
type: string
required:
- user_id
OwnGame:
title: OwnGame
type: object
properties:
user_id:
type: string
location_id:
type: string
required:
- user_id
OwnedGame:
title: OwnedGame
type: object
properties:
user_id:
type: string
game_id:
type: string
location_id:
type: string
required:
- user_id
- game_id
LocationId:
title: LocationId
@@ -455,11 +597,6 @@ components:
type: string
required:
- game_id
GetGamenightRequestBody:
type: object
properties:
id:
type: string
User:
type: object
properties:
@@ -489,7 +626,7 @@ components:
type: string
required:
- name
RenameGameRequestBody:
EditGameRequestBody:
type: object
properties:
id:
@@ -499,19 +636,10 @@ components:
required:
- id
- name
OwnGameRequestBody:
type: object
properties:
game_id:
type: string
location_id:
type: string
required:
- game_id
GameIdsResponse:
type: array
items:
$ref: "#/components/schemas/OwnedGame"
$ref: "#/components/schemas/GameId"
UserIdsResponse:
type: array
items:
@@ -541,21 +669,17 @@ components:
required:
- id
- name
AuthorizeLocationRequestBody:
type: object
properties:
location_id:
type: string
user_id:
type: string
op:
type: string
enum: [grant, revoke]
required:
- location_id
- user_id
- op
requestBodies:
UserIdRequestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UserId'
OwnGameRequestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/OwnGame'
LoginRequest:
content:
application/json:
@@ -566,21 +690,11 @@ components:
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:
@@ -596,61 +710,26 @@ components:
application/json:
schema:
$ref: '#/components/schemas/GamenightId'
GetGameRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/GameId'
AddGameRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/AddGameRequestBody'
RenameGameRequest:
EditGameRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/RenameGameRequestBody'
$ref: '#/components/schemas/EditGameRequestBody'
RemoveGameRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/GameId'
OwnGameRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/OwnGameRequestBody'
DisownGameRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/GameId'
OwnedGamesRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/UserId'
GetLocationRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/LocationId'
AddLocationRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/AddLocationRequestBody'
AuthorizeLocationRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/AuthorizeLocationRequestBody'
AuthorizedLocationUserIdsRequest:
content:
application/json:
schema:
$ref: '#/components/schemas/LocationId'
responses:
TokenResponse:
@@ -743,7 +822,6 @@ components:
application/json:
schema:
$ref: '#/components/schemas/LocationId'
LocationsResponse:
description: A list of all LocationsResponse
content:
@@ -752,6 +830,14 @@ components:
type: array
items:
$ref: '#/components/schemas/Location'
OwnedGamesResponse:
description: A list of OwnedGames
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/OwnedGame'
securitySchemes:
JWT-Auth: