diff --git a/spec.json b/spec.json index 26570a49b0bae494c990a7ffb525e6bedf4c6a7f..39d296813341dac9fecbc619df7eb63d3a4287e9 100644 --- a/spec.json +++ b/spec.json @@ -1,535 +1 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "Sparesti API", - "description": "The Sparesti API", - "version": "3.0" - }, - "servers": [ - { - "url": "http://localhost:8080", - "description": "Generated server url" - } - ], - "security": [ - { - "Bearer Authentication": [] - } - ], - "tags": [ - { - "name": "Authentication", - "description": "User authentication" - }, - { - "name": "Leaderboard", - "description": "Retrieving leaderboard data" - } - ], - "paths": { - "/api/auth/valid-email/{email}": { - "post": { - "tags": [ - "Authentication" - ], - "summary": "Validate email", - "description": "Check that the given email is valid", - "operationId": "validateEmail", - "parameters": [ - { - "name": "email", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "409": { - "description": "Email already exists", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ExceptionResponse" - } - } - } - }, - "200": { - "description": "Email is valid", - "content": { - "*/*": { - "schema": { - "type": "object" - } - } - } - } - }, - "security": [] - } - }, - "/api/auth/signup": { - "post": { - "tags": [ - "Authentication" - ], - "summary": "User Signup", - "description": "Sign up a new user", - "operationId": "signup", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SignUpRequest" - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "Successfully signed up", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AuthenticationResponse" - } - } - } - }, - "409": { - "description": "Email already exists", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ExceptionResponse" - } - } - } - } - }, - "security": [] - } - }, - "/api/auth/login": { - "post": { - "tags": [ - "Authentication" - ], - "summary": "User Login", - "description": "Log in with an existing user", - "operationId": "login", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/LoginRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successfully logged in", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AuthenticationResponse" - } - } - } - }, - "401": { - "description": "Invalid credentials", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ExceptionResponse" - } - } - } - }, - "404": { - "description": "User not found", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ExceptionResponse" - } - } - } - } - }, - "security": [] - } - }, - "/api/users": { - "patch": { - "tags": [ - "user-controller" - ], - "summary": "Update profile", - "description": "Update the profile of the authenticated user", - "operationId": "update", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserUpdateDTO" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successfully updated profile", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserDTO" - } - } - } - } - } - } - }, - "/api/users/{userId}/profile": { - "get": { - "tags": [ - "user-controller" - ], - "summary": "Get profile", - "description": "Get user profile", - "operationId": "getProfile", - "parameters": [ - { - "name": "userId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "Successfully got profile", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProfileDTO" - } - } - } - } - } - } - }, - "/api/users/me": { - "get": { - "tags": [ - "user-controller" - ], - "summary": "Get user", - "description": "Get user information", - "operationId": "getUser", - "responses": { - "200": { - "description": "Successfully got user", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserDTO" - } - } - } - } - } - } - }, - "/api/leaderboard": { - "get": { - "tags": [ - "Leaderboard" - ], - "operationId": "getLeaderboard", - "parameters": [ - { - "name": "type", - "in": "query", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "filter", - "in": "query", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "entryCount", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "format": "int32", - "default": 10 - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/LeaderboardDTO" - } - } - } - } - } - } - }, - "/api/leaderboard/surrounding": { - "get": { - "tags": [ - "Leaderboard" - ], - "operationId": "getSurrounding", - "parameters": [ - { - "name": "type", - "in": "query", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "filter", - "in": "query", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "entryCount", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "format": "int32", - "default": 10 - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/LeaderboardDTO" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "ExceptionResponse": { - "type": "object", - "properties": { - "status": { - "type": "integer", - "format": "int32" - }, - "message": { - "type": "string" - } - } - }, - "SignUpRequest": { - "type": "object", - "properties": { - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "email": { - "type": "string" - }, - "password": { - "type": "string" - }, - "commitment": { - "type": "string" - }, - "experience": { - "type": "string" - }, - "challengeTypes": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "AuthenticationResponse": { - "type": "object", - "properties": { - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "role": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, - "LoginRequest": { - "type": "object", - "properties": { - "email": { - "type": "string" - }, - "password": { - "type": "string" - } - } - }, - "UserUpdateDTO": { - "type": "object", - "properties": { - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "email": { - "type": "string" - }, - "password": { - "type": "string" - }, - "commitment": { - "type": "string" - }, - "experience": { - "type": "string" - }, - "challengeTypes": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "UserDTO": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "email": { - "type": "string" - }, - "createdAt": { - "type": "string", - "format": "date-time" - }, - "role": { - "type": "string" - } - } - }, - "ProfileDTO": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "createdAt": { - "type": "string", - "format": "date-time" - } - } - }, - "LeaderboardDTO": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "filter": { - "type": "string" - }, - "entries": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LeaderboardEntryDTO" - } - } - } - }, - "LeaderboardEntryDTO": { - "type": "object", - "properties": { - "user": { - "$ref": "#/components/schemas/UserDTO" - }, - "score": { - "type": "integer", - "format": "int32" - } - } - } - }, - "securitySchemes": { - "Bearer Authentication": { - "type": "http", - "scheme": "bearer", - "bearerFormat": "JWT" - } - } - } -} \ No newline at end of file +{"openapi":"3.0.1","info":{"title":"Sparesti API","description":"The Sparesti API","version":"3.0"},"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"security":[{"Bearer Authentication":[]}],"tags":[{"name":"Authentication","description":"User authentication"},{"name":"Leaderboard","description":"Retrieving leaderboard data"}],"paths":{"/api/auth/valid-email/{email}":{"post":{"tags":["Authentication"],"summary":"Validate email","description":"Check that the given email is valid","operationId":"validateEmail","parameters":[{"name":"email","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"409":{"description":"Email already exists","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ExceptionResponse"}}}},"200":{"description":"Email is valid","content":{"*/*":{"schema":{"type":"object"}}}}},"security":[]}},"/api/auth/signup":{"post":{"tags":["Authentication"],"summary":"User Signup","description":"Sign up a new user","operationId":"signup","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignUpRequest"}}},"required":true},"responses":{"409":{"description":"Email already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExceptionResponse"}}}},"201":{"description":"Successfully signed up","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthenticationResponse"}}}}},"security":[]}},"/api/auth/login":{"post":{"tags":["Authentication"],"summary":"User Login","description":"Log in with an existing user","operationId":"login","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}},"required":true},"responses":{"200":{"description":"Successfully logged in","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthenticationResponse"}}}},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExceptionResponse"}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExceptionResponse"}}}}},"security":[]}},"/api/users":{"patch":{"tags":["user-controller"],"summary":"Update profile","description":"Update the profile of the authenticated user","operationId":"update","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserUpdateDTO"}}},"required":true},"responses":{"200":{"description":"Successfully updated profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserDTO"}}}}}}},"/api/users/{userId}/profile":{"get":{"tags":["user-controller"],"summary":"Get profile","description":"Get user profile","operationId":"getProfile","parameters":[{"name":"userId","in":"path","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Successfully got profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProfileDTO"}}}}}}},"/api/users/me":{"get":{"tags":["user-controller"],"summary":"Get user","description":"Get user information","operationId":"getUser","responses":{"200":{"description":"Successfully got user","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserDTO"}}}}}}},"/api/leaderboard":{"get":{"tags":["Leaderboard"],"operationId":"getLeaderboard","parameters":[{"name":"type","in":"query","required":true,"schema":{"type":"string"}},{"name":"filter","in":"query","required":true,"schema":{"type":"string"}},{"name":"entryCount","in":"query","required":false,"schema":{"type":"integer","format":"int32","default":10}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeaderboardDTO"}}}}}}},"/api/leaderboard/surrounding":{"get":{"tags":["Leaderboard"],"operationId":"getSurrounding","parameters":[{"name":"type","in":"query","required":true,"schema":{"type":"string"}},{"name":"filter","in":"query","required":true,"schema":{"type":"string"}},{"name":"entryCount","in":"query","required":false,"schema":{"type":"integer","format":"int32","default":10}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeaderboardDTO"}}}}}}}},"components":{"schemas":{"ExceptionResponse":{"type":"object","properties":{"status":{"type":"integer","format":"int32"},"message":{"type":"string"}}},"SignUpRequest":{"type":"object","properties":{"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string"},"password":{"type":"string"},"commitment":{"type":"string"},"experience":{"type":"string"},"challengeTypes":{"type":"array","items":{"type":"string"}}}},"AuthenticationResponse":{"type":"object","properties":{"firstName":{"type":"string"},"lastName":{"type":"string"},"role":{"type":"string"},"token":{"type":"string"}}},"LoginRequest":{"type":"object","properties":{"email":{"type":"string"},"password":{"type":"string"}}},"UserUpdateDTO":{"type":"object","properties":{"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string"},"password":{"type":"string"},"commitment":{"type":"string"},"experience":{"type":"string"},"challengeTypes":{"type":"array","items":{"type":"string"}}}},"UserDTO":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"role":{"type":"string"}}},"ProfileDTO":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"firstName":{"type":"string"},"lastName":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"LeaderboardDTO":{"type":"object","properties":{"type":{"type":"string"},"filter":{"type":"string"},"entries":{"type":"array","items":{"$ref":"#/components/schemas/LeaderboardEntryDTO"}}}},"LeaderboardEntryDTO":{"type":"object","properties":{"user":{"$ref":"#/components/schemas/UserDTO"},"score":{"type":"integer","format":"int32"},"rank":{"type":"integer","format":"int64"}}}},"securitySchemes":{"Bearer Authentication":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}}} \ No newline at end of file diff --git a/src/api/models/LeaderboardEntryDTO.ts b/src/api/models/LeaderboardEntryDTO.ts index 9a93b2ff579409b4fa78077ba9f9cb47befc465d..6a7dc1d7c916baae5ea0b496ac69ef08792f4e98 100644 --- a/src/api/models/LeaderboardEntryDTO.ts +++ b/src/api/models/LeaderboardEntryDTO.ts @@ -6,5 +6,6 @@ import type { UserDTO } from './UserDTO'; export type LeaderboardEntryDTO = { user?: UserDTO; score?: number; + rank?: number; };