fix: made endpoints match documentation naming conventions 'just the mapping' and noted endpoints not yet implemented in documentation/openapi/notes.md
Some checks failed
Format / formatting (push) Failing after 6s
Build / build (push) Successful in 40s
CI / build (push) Successful in 11s

This commit is contained in:
MAILLAL Anas 2025-04-21 23:55:14 +02:00
parent 561f6d16b3
commit 8a13993d8a
9 changed files with 38 additions and 113 deletions

View File

@ -57,7 +57,7 @@ public class AdminApi {
*
* @return the status code of the request
*/
@PostMapping("/admin/projects/decision")
@PostMapping("/admin/projects/pending/decision")
public void validateProject(@RequestBody ProjectDecision decision) {
adminApiService.validateProject(decision);
}
@ -67,7 +67,7 @@ public class AdminApi {
*
* @return the status code of the request
*/
@PostMapping("/admin/project/add")
@PostMapping("/admin/project")
public void addNewProject(@RequestBody Project project) {
adminApiService.addNewProject(project);
}
@ -79,7 +79,7 @@ public class AdminApi {
*
* @return the status code of the request
*/
@PostMapping("/admin/appoitements/report/{appointmentId}")
@PostMapping("/admin/appointments/report/{appointmentId}")
public void createAppointmentReport(
@PathVariable long appointmentId,
@RequestBody Report report,
@ -95,23 +95,23 @@ public class AdminApi {
*
* @return the status code of the request
*/
@DeleteMapping("/admin/projects/remove/{projectId}")
@DeleteMapping("/admin/projects/{projectId}")
public void deleteProject(@PathVariable long projectId) {
adminApiService.deleteProject(projectId);
}
@GetMapping("/admin/setadmin/{userId}")
@PostMapping("/admin/make-admin/{userId}")
public void setAdmin(@PathVariable long userId, @AuthenticationPrincipal Jwt principal) {
this.adminApiService.setAdmin(userId, principal.getTokenValue());
}
@GetMapping("/admin/validate_user_account/{userId}")
@PostMapping("/admin/accounts/validate/{userId}")
public void validateEntrepreneurAcc(
@PathVariable long userId, @AuthenticationPrincipal Jwt principal) {
this.adminApiService.validateEntrepreneurAccount(userId, principal.getTokenValue());
}
@GetMapping("/admin/get_pending_accounts")
@GetMapping("/admin/pending-accounts")
public Iterable<User> validateEntrepreneurAcc() {
return this.adminApiService.getPendingUsers();
}

View File

@ -1,14 +1,19 @@
package enseirb.myinpulse.controller;
import enseirb.myinpulse.model.Project;
import enseirb.myinpulse.model.SectionCell;
import enseirb.myinpulse.service.EntrepreneurApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import enseirb.myinpulse.model.Project;
import enseirb.myinpulse.model.SectionCell;
import enseirb.myinpulse.service.EntrepreneurApiService;
@SpringBootApplication
@RestController
@ -28,13 +33,13 @@ public class EntrepreneurApi {
*
* @return status code
*/
@PutMapping("/entrepreneur/lcsection/modify/{sectionId}")
@PutMapping("/entrepreneur/sectionCells/{sectionCellId}")
public void editSectionCell(
@PathVariable Long sectionId,
@PathVariable Long sectionCellId,
@RequestBody String content,
@AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.editSectionCell(
sectionId, content, principal.getClaimAsString("email"));
sectionCellId, content, principal.getClaimAsString("email"));
}
/**
@ -44,10 +49,10 @@ public class EntrepreneurApi {
*
* @return status code
*/
@DeleteMapping("/entrepreneur/lcsection/remove/{sectionId}")
@DeleteMapping("/entrepreneur/sectionCells/{sectionCellId}")
public void removeSectionCell(
@PathVariable Long sectionId, @AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.removeSectionCell(sectionId, principal.getClaimAsString("email"));
@PathVariable Long sectionCellId, @AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.removeSectionCell(sectionCellId, principal.getClaimAsString("email"));
}
/**
@ -57,7 +62,7 @@ public class EntrepreneurApi {
*
* @return status code
*/
@PostMapping("/entrepreneur/lcsection/add") // remove id from doc aswell
@PostMapping("/entrepreneur/sectionCells")
public void addLCSection(
@RequestBody SectionCell sectionCell, @AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.addSectionCell(sectionCell, principal.getClaimAsString("email"));
@ -70,7 +75,7 @@ public class EntrepreneurApi {
*
* @return status code
*/
@PostMapping("/entrepreneur/project/request")
@PostMapping("/entrepreneur/projects/request")
public void requestNewProject(
@RequestBody Project project, @AuthenticationPrincipal Jwt principal) {
entrepreneurApiService.requestNewProject(project, principal.getClaimAsString("email"));

View File

@ -30,7 +30,7 @@ public class SharedApi {
*
* @return a list of lean canvas sections
*/
@GetMapping("/shared/project/lcsection/{projectId}/{sectionId}/{date}")
@GetMapping("/shared/projects/sectionCells/{projectId}/{sectionId}/{date}")
public Iterable<SectionCell> getLCSection(
@PathVariable("projectId") Long projectId,
@PathVariable("sectionId") Long sectionId,
@ -45,7 +45,7 @@ public class SharedApi {
*
* @return a list of all entrepreneurs in a project
*/
@GetMapping("/shared/entrepreneurs/{projectId}")
@GetMapping("/shared/projects/entrepreneurs/{projectId}")
public Iterable<Entrepreneur> getEntrepreneursByProjectId(
@PathVariable int projectId, @AuthenticationPrincipal Jwt principal) {
return sharedApiService.getEntrepreneursByProjectId(
@ -80,7 +80,7 @@ public class SharedApi {
*
* @return a PDF file? TODO: how does that works ?
*/
@GetMapping("/shared/projects/appointments/report/{appointmentId}")
@GetMapping("/shared/appointments/report/{appointmentId}")
public void getPDFReport(
@PathVariable int appointmentId, @AuthenticationPrincipal Jwt principal) {
try {
@ -97,7 +97,7 @@ public class SharedApi {
/**
* @return TODO
*/
@PostMapping("/shared/appointment/request")
@PostMapping("/shared/appointments/request")
public void createAppointmentRequest(
@RequestBody Appointment appointment, @AuthenticationPrincipal Jwt principal) {
sharedApiService.createAppointmentRequest(appointment, principal.getClaimAsString("email"));

View File

@ -20,7 +20,7 @@ public class UnauthApi {
this.entrepreneurApiService = entrepreneurApiService;
}
@GetMapping("/unauth/create_account")
@GetMapping("/unauth/finalize")
public void createAccount(@AuthenticationPrincipal Jwt principal) {
boolean sneeStatus;
if (principal.getClaimAsString("sneeStatus") != null) {

View File

@ -5,43 +5,9 @@
- `/entrepreneur/lcsection/modify/{sectionId}``/entrepreneur/sectionCell/modify/{sectionId}`
### Admin api
- `/admin/appointments/upcoming`: is shared not admin
- `/admin/projects/decision`: instanciates classes with `adminId` instead of taking the id from the token
- `/admin/project/add`:
- point 1: the doc has this `projects` everywhere this should be `/admin/projects/add` to avoid confusion I think
- point 2: this doesn't assiociate users with a project I need to add other endopint for that
- `/admin/appoitements/report/{appointmentId}`:
- typo: `appoitements``appointments`
- `/admin/projects/remove/{projectId}`, `/admin/project/add`, `/admin/projects/decision`, `/admin/projects/pending`:
- should need token to delete or add project
- `/admin/appointments/report/{appointmentId}` has no PUT and DELETE
- `/admin/request-join` and `/admin/request-join/decision/{joinRequestId}` have not yet been implemented
### Entrepreneur api
- `/entrepreneur/sectionCell/modify/{sectionId}`:
- the section-id because of the definition of `sectionCell` schema the `sectionId` is given twice possibly leading to inconsistency. Which is why the path var to be removed:
- → `/entrepreneur/sectionCell/modify`
### Shared api
- `/shared/project/sectionCell/{projectId}/{sectionId}/{date}`:
- point 1:
same point for `project``projects`
- point 2:
have yet to read `sharedApiService` to see how dates are handled and to see if we agree on values of `date` to make it so it gets the version relative to current date
- `/shared/entrepreneurs/{projectId}`:
- maybe change to `/shared/projects/entrepreneurs/{projectId}` to match other similair endpoints like `/shared/projects/admin/{projectId}`
- `/shared/appointment/request`:
- creates the apointement but don't know how it associates other users, potentially multiple classes in one request body, is that possible ?
## TODOs for me
### list 1:
- add back-end server links (backend and auth) for interacting with api through swagger
- get config for that set up in the project
### list 2:
- see what to do about logo img
- see format for date and add it in examples
- ask the form of return of the json of iterables, for now I have put array
- add endpoint for adding users to a project
- update endpoint descriptions
- add examples for values in schemas
### Unauth api
- `/unauth/request-join/{projectId}` has not yet been implemented

View File

@ -124,7 +124,7 @@ paths:
description: Unauthorized.
/admin/projects/pending/decision/{pendingProjectId}:
/admin/projects/pending/decision:
post:
operationId: decidePendingProject
summary: Approve or reject a pending project

View File

@ -445,7 +445,7 @@ paths:
$ref: '#/components/schemas/project'
'401':
description: Unauthorized.
'/admin/projects/pending/decision/{pendingProjectId}':
/admin/projects/pending/decision:
post:
operationId: decidePendingProject
summary: Approve or reject a pending project
@ -601,28 +601,6 @@ paths:
description: Bad Request - Invalid user ID format or user is already an admin.
'401':
description: Unauthorized.
/shared/appointments/upcoming:
get:
operationId: getUpcomingAppointments
summary: Get upcoming appointments for the user
tags:
- Shared API
security:
- MyINPulse:
- MyINPulse-entrepreneur
- MyINPulse-admin
description: Retrieves a list of appointments scheduled for the authenticated user (either entrepreneur or admin) in the future.
responses:
'200':
description: OK - List of upcoming appointments.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/appointment'
'401':
description: Unauthorized.
'/shared/projects/sectionCells/{projectId}/{sectionId}/{date}':
get:
operationId: getSectionCellsByDate

View File

@ -98,8 +98,8 @@ paths:
$ref: "./adminApi.yaml#/paths/~1admin~1projects"
/admin/projects/pending:
$ref: "./adminApi.yaml#/paths/~1admin~1projects~1pending"
/admin/projects/pending/decision/{pendingProjectId}:
$ref: "./adminApi.yaml#/paths/~1admin~1projects~1pending~1decision~1{pendingProjectId}"
/admin/projects/pending/decision:
$ref: "./adminApi.yaml#/paths/~1admin~1projects~1pending~1decision"
/admin/appointments/report/{appointmentId}:
$ref: "./adminApi.yaml#/paths/~1admin~1appointments~1report~1{appointmentId}"
/admin/projects/{projectId}:
@ -113,8 +113,6 @@ paths:
# ___) | | | | (_| | | | __/ (_| | / ___ \| __/| |
# |____/|_| |_|\__,_|_| \___|\__,_| /_/ \_\_| |___|
#
/shared/appointments/upcoming:
$ref: "./sharedApi.yaml#/paths/~1shared~1appointments~1upcoming"
/shared/projects/sectionCells/{projectId}/{sectionId}/{date}:
$ref: "./sharedApi.yaml#/paths/~1shared~1projects~1sectionCells~1{projectId}~1{sectionId}~1{date}"
/shared/projects/entrepreneurs/{projectId}:

View File

@ -1,27 +1,5 @@
# Shared API Endpoints
paths:
/shared/appointments/upcoming:
get:
operationId: getUpcomingAppointments
summary: Get upcoming appointments for the user
tags:
- Shared API
security:
- MyINPulse: [MyINPulse-entrepreneur, MyINPulse-admin] # Accessible by both
description: Retrieves a list of appointments scheduled for the authenticated user (either entrepreneur or admin) in the future.
responses:
"200":
description: OK - List of upcoming appointments.
content:
application/json:
schema:
type: array
items:
$ref: "./main.yaml#/components/schemas/appointment"
"401":
description: Unauthorized.
/shared/projects/sectionCells/{projectId}/{sectionId}/{date}:
get:
operationId: getSectionCellsByDate