Skip to content
Snippets Groups Projects
Commit 4316114c authored by Henrik's avatar Henrik
Browse files

feat: add user and leaderboard service

parent 16305e08
Branches ImageInStorage
No related tags found
No related merge requests found
Pipeline #275309 failed
spec.json 0 → 100644
{
"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}": {
"get": {
"tags": [
"user-controller"
],
"summary": "Get user",
"description": "Get user information",
"operationId": "getUser",
"parameters": [
{
"name": "userId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"200": {
"description": "Successfully got user",
"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/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
......@@ -9,7 +9,14 @@ export type { OpenAPIConfig } from './core/OpenAPI';
export type { AuthenticationResponse } from './models/AuthenticationResponse';
export type { ExceptionResponse } from './models/ExceptionResponse';
export type { LeaderboardDTO } from './models/LeaderboardDTO';
export type { LeaderboardEntryDTO } from './models/LeaderboardEntryDTO';
export type { LoginRequest } from './models/LoginRequest';
export type { ProfileDTO } from './models/ProfileDTO';
export type { SignUpRequest } from './models/SignUpRequest';
export type { UserDTO } from './models/UserDTO';
export type { UserUpdateDTO } from './models/UserUpdateDTO';
export { AuthenticationService } from './services/AuthenticationService';
export { LeaderboardService } from './services/LeaderboardService';
export { UserControllerService } from './services/UserControllerService';
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { LeaderboardEntryDTO } from './LeaderboardEntryDTO';
export type LeaderboardDTO = {
type?: string;
filter?: string;
entries?: Array<LeaderboardEntryDTO>;
};
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { UserDTO } from './UserDTO';
export type LeaderboardEntryDTO = {
user?: UserDTO;
score?: number;
};
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type ProfileDTO = {
id?: number;
firstName?: string;
lastName?: string;
createdAt?: string;
};
......@@ -7,8 +7,8 @@ export type SignUpRequest = {
lastName?: string;
email?: string;
password?: string;
changeWilling?: string;
commitment?: string;
experience?: string;
challenges?: Array<string>;
challengeTypes?: Array<string>;
};
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type UserDTO = {
id?: number;
firstName?: string;
lastName?: string;
email?: string;
createdAt?: string;
role?: string;
};
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type UserUpdateDTO = {
firstName?: string;
lastName?: string;
email?: string;
password?: string;
commitment?: string;
experience?: string;
challengeTypes?: Array<string>;
};
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { LeaderboardDTO } from '../models/LeaderboardDTO';
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
export class LeaderboardService {
/**
* @returns LeaderboardDTO OK
* @throws ApiError
*/
public static getLeaderboard({
type,
filter,
entryCount = 10,
}: {
type: string,
filter: string,
entryCount?: number,
}): CancelablePromise<LeaderboardDTO> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/leaderboard',
query: {
'type': type,
'filter': filter,
'entryCount': entryCount,
},
});
}
/**
* @returns LeaderboardDTO OK
* @throws ApiError
*/
public static getSurrounding({
type,
filter,
entryCount = 10,
}: {
type: string,
filter: string,
entryCount?: number,
}): CancelablePromise<LeaderboardDTO> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/leaderboard/surrounding',
query: {
'type': type,
'filter': filter,
'entryCount': entryCount,
},
});
}
}
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ProfileDTO } from '../models/ProfileDTO';
import type { UserDTO } from '../models/UserDTO';
import type { UserUpdateDTO } from '../models/UserUpdateDTO';
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
export class UserControllerService {
/**
* Update profile
* Update the profile of the authenticated user
* @returns UserDTO Successfully updated profile
* @throws ApiError
*/
public static update({
requestBody,
}: {
requestBody: UserUpdateDTO,
}): CancelablePromise<UserDTO> {
return __request(OpenAPI, {
method: 'PATCH',
url: '/api/users',
body: requestBody,
mediaType: 'application/json',
});
}
/**
* Get user
* Get user information
* @returns UserDTO Successfully got user
* @throws ApiError
*/
public static getUser({
userId,
}: {
userId: number,
}): CancelablePromise<UserDTO> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/users/{userId}',
path: {
'userId': userId,
},
});
}
/**
* Get profile
* Get user profile
* @returns ProfileDTO Successfully got profile
* @throws ApiError
*/
public static getProfile({
userId,
}: {
userId: number,
}): CancelablePromise<ProfileDTO> {
return __request(OpenAPI, {
method: 'GET',
url: '/api/users/{userId}/profile',
path: {
'userId': userId,
},
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment