Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e506f01
implemented email format validation
Marcus0410 Feb 26, 2025
66c1dac
implemented password validation
Marcus0410 Feb 26, 2025
249835d
Merge pull request #6 from boolean-uk/4-api---user-registration-valid…
magnus195 Feb 26, 2025
65ab60e
added new columns to profile table
Thomaskri0801 Feb 26, 2025
b110fe8
added profile creation for users
Magnus-droid Feb 26, 2025
4cbbed1
Added database migrations
Thomaskri0801 Feb 26, 2025
a3fcd07
Merge pull request #9 from boolean-uk/7-api---database-structure-updates
magnus195 Feb 27, 2025
1a73c86
added openapi spec for profile creation
Magnus-droid Feb 27, 2025
6aea037
Merge pull request #10 from boolean-uk/5-api---create-user-profile-af…
magnus195 Feb 27, 2025
612fe5e
Implemented getAll and getById for cohorts
Marcus0410 Feb 27, 2025
6b614fb
Merge pull request #16 from boolean-uk/12-api---getall-and-getbyid-fo…
magnus195 Feb 27, 2025
d546a7f
search students by name query has been implemented
Feb 27, 2025
91842e4
improved endpoint to use search queries in the url, i.e. /users/searc…
Feb 27, 2025
0d9bf5f
Merge branch 'main' into 13-api---searching---student-view
jonasmelonas Feb 27, 2025
026978b
refactor the database structure and added the specialism table
Thomaskri0801 Feb 27, 2025
372903a
Merge pull request #19 from boolean-uk/15-api---refactor-the-structur…
magnus195 Feb 27, 2025
1c2773e
openapi.yml file update with endpoint
Feb 27, 2025
8c97962
Merge branch '13-api---searching---student-view' of github.com:boolea…
Feb 27, 2025
405b9d9
openapi.yml file updated with endpoint for search
Feb 27, 2025
0f31706
Merge branch 'main' into 13-api---searching---student-view
magnus195 Feb 27, 2025
3a8da7f
Merge branch '13-api---searching---student-view' of github.com:boolea…
Feb 27, 2025
3e0652f
improved search algorithm
Feb 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
217 changes: 211 additions & 6 deletions docs/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.3
info:
title: Team Dev Server API
description: |-
version: 1.0
version: '1.0'

servers:
- url: http://localhost:4000/
Expand Down Expand Up @@ -65,6 +65,37 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'

/users/profile/{id}:
post:
tags:
- profile
summary: Create profile
description: Create new profile
operationId: createProfile
security:
- bearerAuth: []
parameters:
- name: id
in: path
description: 'The name that needs to be fetched. Use user1 for testing. '
required: true
schema:
type: string
requestBody:
description: User registration details
content:
application/json:
schema:
$ref: '#/components/schemas/CreateProfile'
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/CreatedProfile'

/login:
post:
tags:
Expand All @@ -88,6 +119,46 @@ paths:

'400':
description: Invalid username/password supplied

/users/search:
get:
tags:
- user
summary: Search users by first name and/or last name
description: 'Search for users by their first name, last name, or both. Either parameter is optional.'
operationId: searchUsers
security:
- bearerAuth: []
parameters:
- name: firstName
in: query
description: 'Search users by their first name (optional).'
schema:
type: string
- name: lastName
in: query
description: 'Search users by their last name (optional).'
schema:
type: string
responses:
'200':
description: 'Users found successfully'
content:
application/json:
schema:
$ref: '#/components/schemas/AllUsers'
'400':
description: 'Bad request, invalid query parameters.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: 'No users found matching the query.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/users/{id}:
get:
Expand Down Expand Up @@ -183,13 +254,13 @@ paths:
content:
type: string
responses:
201:
'201':
description: success
content:
application/json:
schema:
$ref: '#/components/schemas/Post'
400:
'400':
description: fail
content:
application/json:
Expand Down Expand Up @@ -244,7 +315,7 @@ paths:
content:
type: string
responses:
201:
'201':
description: success
content:
application/json:
Expand All @@ -266,7 +337,7 @@ paths:
security:
- bearerAuth: []
responses:
201:
'201':
description: success
content:
application/json:
Expand All @@ -279,7 +350,70 @@ paths:
properties:
cohort:
$ref: '#/components/schemas/Cohort'
400:
'400':
description: fail
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
get:
tags:
- cohort
summary: Get all cohorts
description: This can only be done by a logged in user.
operationId: getAllCohorts
security:
- bearerAuth: []
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/AllUsers'
'500':
description: fail
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/cohorts/{id}:
get:
tags:
- cohort
summary: Get cohort by id
description: This can only be done by a logged in user.
operationId: getCohortById
security:
- bearerAuth: []
parameters:
- name: id
in: path
description: 'Id of the cohort to fetch'
required: true
schema:
type: string
responses:
'200':
description: success
content:
application/json:
schema:
type: object
properties:
status:
type: string
data:
properties:
cohort:
$ref: '#/components/schemas/Cohort'
'404':
description: fail
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: fail
content:
application/json:
Expand Down Expand Up @@ -307,6 +441,19 @@ components:
content:
type: string

AllCohorts:
type: object
properties:
status:
type: string
data:
type: object
properties:
cohorts:
type: array
items:
$ref: '#/components/schemas/Cohort'

Cohort:
type: object
properties:
Expand Down Expand Up @@ -368,6 +515,30 @@ components:
password:
type: string

CreateProfile:
type: object
properties:
firstName:
type: string
lastName:
type: string
bio:
type: string
githubUrl:
type: string
username:
type: string
mobile:
type: string
startDate:
type: string
endDate:
type: string
specialism:
type: string
jobTitle:
type: string

UpdateUser:
type: object
properties:
Expand Down Expand Up @@ -457,6 +628,40 @@ components:
type: string
githubUrl:
type: string

CreatedProfile:
type: object
properties:
status:
type: string
example: success
data:
properties:
user:
properties:
id:
type: integer
firstName:
type: string
lastName:
type: string
bio:
type: string
githubUrl:
type: string
username:
type: string
mobile:
type: string
startDate:
type: string
endDate:
type: string
specialism:
type: string
jobTitle:
type: string

login:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- AlterTable
ALTER TABLE "Profile" ADD COLUMN "endDate" TEXT,
ADD COLUMN "jobTitle" TEXT,
ADD COLUMN "mobile" TEXT,
ADD COLUMN "specialism" TEXT,
ADD COLUMN "startDate" TEXT,
ADD COLUMN "username" TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Warnings:

- You are about to drop the column `endDate` on the `Profile` table. All the data in the column will be lost.
- You are about to drop the column `jobTitle` on the `Profile` table. All the data in the column will be lost.
- You are about to drop the column `specialism` on the `Profile` table. All the data in the column will be lost.
- You are about to drop the column `startDate` on the `Profile` table. All the data in the column will be lost.

*/
-- AlterTable
ALTER TABLE "Cohort" ADD COLUMN "endDate" TEXT,
ADD COLUMN "jobTitle" TEXT,
ADD COLUMN "specialismId" INTEGER,
ADD COLUMN "startDate" TEXT;

-- AlterTable
ALTER TABLE "Profile" DROP COLUMN "endDate",
DROP COLUMN "jobTitle",
DROP COLUMN "specialism",
DROP COLUMN "startDate";

-- CreateTable
CREATE TABLE "Specialism" (
"id" SERIAL NOT NULL,
"specialismName" TEXT NOT NULL,

CONSTRAINT "Specialism_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "Cohort" ADD CONSTRAINT "Cohort_specialismId_fkey" FOREIGN KEY ("specialismId") REFERENCES "Specialism"("id") ON DELETE SET NULL ON UPDATE CASCADE;
15 changes: 14 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,25 @@ model Profile {
lastName String
bio String?
githubUrl String?
username String?
mobile String?
}

model Cohort {
id Int @id @default(autoincrement())
specialismId Int?
specialism Specialism? @relation(fields: [specialismId], references: [id])
users User[]
deliveryLogs DeliveryLog[]
startDate String?
endDate String?
jobTitle String?
}

model Specialism {
id Int @id @default(autoincrement())
specialismName String
cohorts Cohort[]
}

model Post {
Expand All @@ -66,4 +79,4 @@ model DeliveryLogLine {
content String
logId Int
log DeliveryLog @relation(fields: [logId], references: [id])
}
}
Loading
Loading