summaryrefslogtreecommitdiff
path: root/jws/endpoints
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /jws/endpoints
add: added projectsHEADmain
Diffstat (limited to 'jws/endpoints')
-rw-r--r--jws/endpoints/pom.xml186
-rw-r--r--jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/Endpoints.java35
-rw-r--r--jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/HelloWorldEndpoint.java15
-rw-r--r--jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/request/ReverseRequest.java10
-rw-r--r--jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/response/HelloResponse.java12
-rw-r--r--jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/response/ReverseResponse.java14
-rw-r--r--jws/endpoints/src/main/resources/application.properties7
-rw-r--r--jws/endpoints/src/main/resources/openapi.yaml80
8 files changed, 359 insertions, 0 deletions
diff --git a/jws/endpoints/pom.xml b/jws/endpoints/pom.xml
new file mode 100644
index 0000000..fc67629
--- /dev/null
+++ b/jws/endpoints/pom.xml
@@ -0,0 +1,186 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>fr.epita.assistants</groupId>
+ <artifactId>endpoints</artifactId>
+ <version>1.0</version>
+
+ <properties>
+ <maven.compiler.release>21</maven.compiler.release>
+ <maven.compiler.source>21</maven.compiler.source>
+ <maven.compiler.target>21</maven.compiler.target>
+
+ <compiler-plugin.version>3.13.0</compiler-plugin.version>
+ <maven.compiler.parameters>true</maven.compiler.parameters>
+
+ <versions.maven-surefire-plugin>3.0.0-M5</versions.maven-surefire-plugin>
+ <versions.maven-jar-plugin>3.4.1</versions.maven-jar-plugin>
+ <versions.maven-install-plugin>3.1.2</versions.maven-install-plugin>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+
+ <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
+ <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
+ <quarkus.platform.version>3.17.5</quarkus.platform.version>
+
+ <skipITs>true</skipITs>
+
+ <surefire.reportsDirectory>${project.build.directory}/surefire-reports</surefire.reportsDirectory>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>${quarkus.platform.group-id}</groupId>
+ <artifactId>${quarkus.platform.artifact-id}</artifactId>
+ <version>${quarkus.platform.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-rest</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.18.30</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.openapi</groupId>
+ <artifactId>microprofile-openapi-api</artifactId>
+ <version>4.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-rest-jackson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-smallrye-openapi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.26.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit-platform</artifactId>
+ <version>${versions.maven-surefire-plugin}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-api</artifactId>
+ <version>3.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>${versions.maven-jar-plugin}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>${versions.maven-install-plugin}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.7.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>${quarkus.platform.group-id}</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <version>${quarkus.platform.version}</version>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ <goal>generate-code</goal>
+ <goal>generate-code-tests</goal>
+ <goal>native-image-agent</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${compiler-plugin.version}</version>
+ <configuration>
+ <parameters>true</parameters>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${versions.maven-surefire-plugin}</version>
+ <configuration>
+ <systemPropertyVariables>
+ <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
+ <maven.home>${maven.home}</maven.home>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>${versions.maven-surefire-plugin}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <systemPropertyVariables>
+ <native.image.path>${project.build.directory}/${project.build.finalName}-runner
+ </native.image.path>
+ <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
+ <maven.home>${maven.home}</maven.home>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <skipITs>false</skipITs>
+ <quarkus.native.enabled>true</quarkus.native.enabled>
+ </properties>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/Endpoints.java b/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/Endpoints.java
new file mode 100644
index 0000000..cd4a49f
--- /dev/null
+++ b/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/Endpoints.java
@@ -0,0 +1,35 @@
+package fr.epita.assistants.presentation.rest;
+
+import fr.epita.assistants.presentation.rest.request.ReverseRequest;
+import fr.epita.assistants.presentation.rest.response.HelloResponse;
+import fr.epita.assistants.presentation.rest.response.ReverseResponse;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.core.Response;
+
+@Path("/")
+public class Endpoints {
+ @GET
+ @Path("hello/{name}")
+ public Response hello(@PathParam("name") String name) {
+ Response.ResponseBuilder res = Response.ok(new HelloResponse(name));
+ if (name == null || name.isEmpty())
+ res.status(Response.Status.BAD_REQUEST);
+ return res.build();
+ }
+
+ @POST
+ @Path("reverse")
+ public Response reverse(ReverseRequest request) {
+ if (request == null || request.getContent() == null) {
+ Response.ResponseBuilder res = Response.status(Response.Status.BAD_REQUEST);
+ return res.build();
+ }
+ Response.ResponseBuilder res = Response.ok(new ReverseResponse(request.getContent()));
+ if (request.getContent().isEmpty())
+ res.status(Response.Status.BAD_REQUEST);
+ return res.build();
+ }
+}
diff --git a/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/HelloWorldEndpoint.java b/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/HelloWorldEndpoint.java
new file mode 100644
index 0000000..4f8a59d
--- /dev/null
+++ b/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/HelloWorldEndpoint.java
@@ -0,0 +1,15 @@
+package fr.epita.assistants.presentation.rest;
+
+import jakarta.ws.rs.*;
+import jakarta.ws.rs.core.MediaType;
+
+@Path("/")
+@Consumes(MediaType.TEXT_PLAIN)
+@Produces(MediaType.TEXT_PLAIN)
+public class HelloWorldEndpoint {
+ @Path("/")
+ @GET
+ public String helloWorld() {
+ return "Hello World!";
+ }
+}
diff --git a/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/request/ReverseRequest.java b/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/request/ReverseRequest.java
new file mode 100644
index 0000000..0a8fc7d
--- /dev/null
+++ b/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/request/ReverseRequest.java
@@ -0,0 +1,10 @@
+package fr.epita.assistants.presentation.rest.request;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
+public class ReverseRequest {
+ String content;
+}
diff --git a/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/response/HelloResponse.java b/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/response/HelloResponse.java
new file mode 100644
index 0000000..2dbc9d0
--- /dev/null
+++ b/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/response/HelloResponse.java
@@ -0,0 +1,12 @@
+package fr.epita.assistants.presentation.rest.response;
+
+import lombok.Getter;
+
+@Getter
+public class HelloResponse {
+ String content;
+
+ public HelloResponse(String content) {
+ this.content = "hello " + content;
+ }
+}
diff --git a/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/response/ReverseResponse.java b/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/response/ReverseResponse.java
new file mode 100644
index 0000000..3f1bb9e
--- /dev/null
+++ b/jws/endpoints/src/main/java/fr/epita/assistants/presentation/rest/response/ReverseResponse.java
@@ -0,0 +1,14 @@
+package fr.epita.assistants.presentation.rest.response;
+
+import lombok.Getter;
+
+@Getter
+public class ReverseResponse {
+ String original;
+ String reversed;
+
+ public ReverseResponse(String original) {
+ this.original = original;
+ this.reversed = new StringBuilder(original).reverse().toString();
+ }
+}
diff --git a/jws/endpoints/src/main/resources/application.properties b/jws/endpoints/src/main/resources/application.properties
new file mode 100644
index 0000000..b3b3d13
--- /dev/null
+++ b/jws/endpoints/src/main/resources/application.properties
@@ -0,0 +1,7 @@
+%dev.quarkus.http.port=8082
+%dev.quarkus.swagger-ui.enable=true
+
+quarkus.log.category."org.apache.kafka".level=WARN
+quarkus.devservices.enabled=false
+
+quarkus.http.cors=true
diff --git a/jws/endpoints/src/main/resources/openapi.yaml b/jws/endpoints/src/main/resources/openapi.yaml
new file mode 100644
index 0000000..7e8ac48
--- /dev/null
+++ b/jws/endpoints/src/main/resources/openapi.yaml
@@ -0,0 +1,80 @@
+---
+openapi: 3.1.0
+tags:
+- name: Greeting
+- name: String Operations
+servers:
+ - url: http://localhost:8082/
+components:
+ schemas:
+ HelloResponse:
+ type: object
+ properties:
+ content:
+ type: string
+ example: "hello test"
+ ReverseRequest:
+ type: object
+ properties:
+ content:
+ type: string
+ example: "hello\ntest"
+ ReverseResponse:
+ type: object
+ properties:
+ original:
+ type: string
+ example: "hello\ntest"
+ reversed:
+ type: string
+ example: "tset\nolleh"
+paths:
+ /hello/{name}:
+ get:
+ summary: Greet by name
+ description: "Returns a greeting message in the format `hello {name}` using\
+ \ the provided name."
+ tags:
+ - Greeting
+ parameters:
+ - name: name
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: Greeting message returned successfully.
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/HelloResponse"
+ "400":
+ description: "Bad request: The name parameter is null or empty."
+ /reverse:
+ post:
+ summary: Reverse a string
+ description: "Accepts a JSON request containing a string, reverses the string,\
+ \ and returns both the original and reversed versions."
+ tags:
+ - String Operations
+ requestBody:
+ description: JSON object containing the string to be reversed.
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/ReverseRequest"
+ required: true
+ responses:
+ "200":
+ description: Reversed string returned successfully.
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/ReverseResponse"
+ "400":
+ description: "Bad request: Request body is null or the string content is\
+ \ null or empty."
+info:
+ title: endpoints API
+ version: "1.0"