push swagger
This commit is contained in:
@@ -33,8 +33,6 @@
|
||||
| DELETE | `/quizz/{quizz_id}/delete` | Suprrime le quizz |
|
||||
| PUT | `/quizz/{quizz_id}/deleteQ` | Supprime toute les questions de quizz |
|
||||
|
||||
|
||||
|
||||
#### Question Resource
|
||||
| Methode | URL | Description |
|
||||
|----------|----------------------------------------------------|-----------------------------------------------------------------------|
|
||||
@@ -50,7 +48,6 @@
|
||||
| PUT | `/question/{question_id}/addChoix` | rajoute un choix si Reponse est de type Choix |
|
||||
|
||||
|
||||
|
||||
## Auteurs
|
||||
|
||||
- Tuan Minh VU
|
||||
|
||||
@@ -39,6 +39,7 @@ public class TestApplication extends Application {
|
||||
clazzes.add(QuizzResource.class);
|
||||
clazzes.add(UtilisateurResource.class);
|
||||
clazzes.add(SessionResource.class);
|
||||
clazzes.add(SwaggerResource.class);
|
||||
return clazzes;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@ import fr.istic.taa.jaxrs.Mapper.QuestionMapper;
|
||||
import fr.istic.taa.jaxrs.metier.Choix;
|
||||
import fr.istic.taa.jaxrs.metier.Question;
|
||||
import fr.istic.taa.jaxrs.metier.Reponse;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.PATCH;
|
||||
|
||||
35
src/main/java/fr/istic/taa/jaxrs/rest/SwaggerResource.java
Normal file
35
src/main/java/fr/istic/taa/jaxrs/rest/SwaggerResource.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package fr.istic.taa.jaxrs.rest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
|
||||
@Path("/api")
|
||||
public class SwaggerResource {
|
||||
private static final Logger logger = Logger.getLogger(SwaggerResource.class.getName());
|
||||
|
||||
@GET
|
||||
public byte[] Get1() {
|
||||
try {
|
||||
return Files.readAllBytes(FileSystems.getDefault().getPath("src/main/webapp/swagger/index.html"));
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{path:.*}")
|
||||
public byte[] Get(@PathParam("path") String path) {
|
||||
try {
|
||||
return Files.readAllBytes(FileSystems.getDefault().getPath("src/main/webapp/swagger/"+path));
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,14 @@ import fr.istic.taa.jaxrs.DTO.SessionDTO;
|
||||
import fr.istic.taa.jaxrs.DTO.UtilisateurDTO;
|
||||
import fr.istic.taa.jaxrs.Mapper.SessionMapper;
|
||||
import fr.istic.taa.jaxrs.Mapper.UtilisateurMapper;
|
||||
import fr.istic.taa.jaxrs.metier.Question;
|
||||
import fr.istic.taa.jaxrs.metier.Session;
|
||||
import fr.istic.taa.jaxrs.metier.Utilisateur;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@@ -19,6 +25,7 @@ import java.util.List;
|
||||
public class UtilisateurResource {
|
||||
private final UtilisateurDAO utilisateurDAO = new UtilisateurDAO();
|
||||
private final UtilisateurMapper mapper = UtilisateurMapper.INSTANCE;
|
||||
|
||||
@GET
|
||||
public List<Utilisateur> listUtilisateur() {
|
||||
List<Utilisateur> utilisateurs = utilisateurDAO.findAll();
|
||||
@@ -59,7 +66,25 @@ public class UtilisateurResource {
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
public Response getUtilisateur(@PathParam("id") Integer id) {
|
||||
@Operation(summary = "Get user by ID",
|
||||
tags = {"utilisateur"},
|
||||
description = "Get User by ID",
|
||||
responses = {
|
||||
@ApiResponse(description = "Utilisateur", content = @Content(
|
||||
schema = @Schema(implementation = Utilisateur.class)
|
||||
)),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "User not found")
|
||||
})
|
||||
public Response getUtilisateur(@Parameter(
|
||||
description = "ID of user that needs to be fetched",
|
||||
schema = @Schema(
|
||||
type = "integer",
|
||||
format = "int32",
|
||||
description = "param ID of user that needs to be fetched"
|
||||
),
|
||||
required = true)
|
||||
@PathParam("id") Integer id) {
|
||||
Utilisateur utilisateur = utilisateurDAO.findById(id);
|
||||
if (utilisateur == null) {
|
||||
return Response.status(Response.Status.NOT_FOUND).build();
|
||||
|
||||
Reference in New Issue
Block a user