Converted the Api to a Restful api.

This commit is contained in:
2026-01-22 22:51:03 +01:00
parent 79ba1e1b44
commit 9d3c5afb07
50 changed files with 2194 additions and 1939 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-token
responses:
'200':
$ref: '#/components/responses/TokenResponse'
@@ -40,6 +41,8 @@ paths:
- JWT-Auth: []
/users:
get:
summary: 'Get all users'
operationId: get-users
responses:
'200':
$ref: '#/components/responses/UsersResponse'
@@ -48,11 +51,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-users
requestBody:
$ref: '#/components/requestBodies/RegisterRequest'
responses:
@@ -61,18 +63,24 @@ 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: []
operationId: 'get-user'
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,9 +88,30 @@ paths:
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/user/{userId}/owned_games:
get:
summary: Get owned games of user
operationId: get-user-owned_games
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
operationId: get-gamenights
responses:
'200':
$ref: '#/components/responses/GamenightsResponse'
@@ -90,29 +119,12 @@ paths:
$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
summary: 'Gets the gamenight'
operationId: post-gamenights
responses:
'200':
description: OK
@@ -121,13 +133,21 @@ paths:
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
- 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: ''
summary: 'get the specified gamenight'
operationId: get-gamenight
parameters:
- in: path
name: gamenightId
schema:
type: string
required: true
description: Uuid of gamenight to get.
responses:
'200':
$ref: '#/components/responses/GamenightResponse'
@@ -135,12 +155,39 @@ paths:
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/GetGamenight'
security:
- JWT-Auth: []
/join:
/gamenight/{gamenightId}/participants:
get:
summary: Get all participants for a gamenight
operationId: get-gamenight-participants
parameters:
- in: path
name: gamenightId
schema:
type: string
required: true
description: Uuid of gamenight to get participants for.
responses:
'200':
$ref: '#/components/responses/ParticipantsResponse'
'400':
$ref: '#/components/responses/FailureResponse'
'401':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: [ ]
description: Retrieve the participants of a single gamenight by id.
post:
summary: Add a participant
operationId: post-gamenight-participants
parameters:
- in: path
name: gamenightId
schema:
type: string
required: true
description: Uuid of gamenight to add participants for.
responses:
'200':
description: OK
@@ -149,11 +196,26 @@ 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:
summary: deletes a gamenight participant
operationId: delete-gamenight-participant
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"
@@ -161,12 +223,12 @@ paths:
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/LeaveGamenight'
security:
- JWT-Auth: []
- JWT-Auth: [ ]
/games:
get:
summary: get all games
operationId: get-games
responses:
'200':
$ref: '#/components/responses/GamesResponse'
@@ -176,21 +238,10 @@ 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:
summary: add a game
operationId: post-games
responses:
'200':
$ref: '#/components/responses/GameIdResponse'
'401':
@@ -199,9 +250,38 @@ paths:
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/AddGameRequest'
security:
- JWT-Auth: [ ]
/game/{gameId}:
get:
summary: Get this specific game
operationId: get-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.
operationId: delete-game
parameters:
- in: path
name: gameId
schema:
type: string
required: true
description: Uuid of game to delete.
responses:
'200':
description: "Ok"
@@ -209,12 +289,18 @@ paths:
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/RemoveGameRequest'
security:
- JWT-Auth: [ ]
/rename_game:
post:
put:
summary: Changes this game resource
operationId: put-game
parameters:
- in: path
name: gameId
schema:
type: string
required: true
description: Uuid of game to change.
responses:
'200':
description: "OK"
@@ -223,62 +309,73 @@ paths:
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/RenameGameRequest'
$ref: '#/components/requestBodies/EditGameRequest'
security:
- JWT-Auth: []
/own:
/game/{gameId}/owners:
post:
responses:
'200':
description: "OK"
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
summary: Own this game
operationId: post-game-owners
parameters:
- in: path
name: gameId
schema:
type: string
required: true
description: Uuid of game to own.
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:
$ref: '#/components/requestBodies/OwnGameRequestBody'
responses:
'200':
$ref: '#/components/responses/LocationResponse'
description: "OK"
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
requestBody:
$ref: '#/components/requestBodies/GetLocationRequest'
security:
- JWT-Auth: []
/game/{gameId}/owner/{userId}:
delete:
summary: no longer own this game
operationId: delete-game-owner
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"
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/locations:
get:
summary: get all locations
operationId: get-locations
responses:
'200':
$ref: '#/components/responses/LocationsResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: [ ]
post:
summary: add a location
operationId: post-locations
responses:
'200':
$ref: '#/components/responses/LocationIdResponse'
@@ -289,20 +386,57 @@ paths:
requestBody:
$ref: '#/components/requestBodies/AddLocationRequest'
security:
- JWT-Auth: []
/locations:
- JWT-Auth: [ ]
/location/{locationId}:
get:
summary: gets this location
operationId: get-location
parameters:
- in: path
name: locationId
schema:
type: string
required: true
description: Uuid of location to get.
responses:
'200':
$ref: '#/components/responses/LocationsResponse'
$ref: '#/components/responses/LocationResponse'
'401':
$ref: '#/components/responses/FailureResponse'
'422':
$ref: '#/components/responses/FailureResponse'
security:
- JWT-Auth: []
/location_authorize:
/location/{locationId}/authorized_users/:
get:
summary: gets this locations authorized users
operationId: get-location-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
operationId: post-location-authorized_users
parameters:
- in: path
name: locationId
schema:
type: string
required: true
description: Uuid location to authorize for.
responses:
'200':
description: 'Ok'
@@ -311,22 +445,36 @@ 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:
summary: remove an authorized user from a location
operationId: delete-location-authorized_user
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 +558,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 +616,6 @@ components:
type: string
required:
- game_id
GetGamenightRequestBody:
type: object
properties:
id:
type: string
User:
type: object
properties:
@@ -489,7 +645,7 @@ components:
type: string
required:
- name
RenameGameRequestBody:
EditGameRequestBody:
type: object
properties:
id:
@@ -499,19 +655,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 +688,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,91 +709,31 @@ 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:
schema:
$ref: '#/components/schemas/GamenightId'
JoinGamenight:
content:
application/json:
schema:
$ref: '#/components/schemas/GamenightId'
LeaveGamenight:
content:
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'
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'
$ref: '#/components/schemas/EditGameRequestBody'
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 +826,6 @@ components:
application/json:
schema:
$ref: '#/components/schemas/LocationId'
LocationsResponse:
description: A list of all LocationsResponse
content:
@@ -752,6 +834,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: