From 79e949bdd4cba421037cef55c2a5330046ceebf2 Mon Sep 17 00:00:00 2001 From: MAILLAL Anas Date: Wed, 19 Feb 2025 01:36:52 +0100 Subject: [PATCH] feat: configured gradle file to generate code for api interface from swagger specification --- MyINPulse-back/build.gradle | 32 +++++ .../src/main/resources/openapi/main.yaml | 133 ++++++------------ 2 files changed, 75 insertions(+), 90 deletions(-) rename Documentation/BackendApi/openapi.yaml => MyINPulse-back/src/main/resources/openapi/main.yaml (85%) diff --git a/MyINPulse-back/build.gradle b/MyINPulse-back/build.gradle index abdd6a9..1f37fd3 100644 --- a/MyINPulse-back/build.gradle +++ b/MyINPulse-back/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '3.4.2' id 'io.spring.dependency-management' version '1.1.7' + id 'org.openapi.generator' version '7.11.0' } group = 'enseirb' @@ -20,8 +21,39 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' implementation 'org.springframework.boot:spring-boot-starter-web' + // swagger Codegen + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0' + implementation 'jakarta.validation:jakarta.validation-api:3.0.2' + implementation 'org.openapitools:jackson-databind-nullable:0.2.6' + testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + +} + +sourceSets { + main { + java { + srcDir "$buildDir/generated/src/main/java" + } + } +} +sourceSets { + main { + java.srcDir("$buildDir/generated/src/main/java") + } +} + +openApiGenerate { + generatorName.set("spring") + inputSpec.set("$rootDir/src/main/resources/openapi.yaml") + outputDir.set("$buildDir/generated") + apiPackage.set("enseirb.myinpulse.api") + modelPackage.set("enseirb.myinpulse.model") + configOptions.put("dateLibrary", "java8") + configOptions.put("useSpringBoot3", "true") + //configOptions.put("interfaceOnly", "true") + configOptions.put("library", "spring-boot") } tasks.named('test') { diff --git a/Documentation/BackendApi/openapi.yaml b/MyINPulse-back/src/main/resources/openapi/main.yaml similarity index 85% rename from Documentation/BackendApi/openapi.yaml rename to MyINPulse-back/src/main/resources/openapi/main.yaml index a116633..fd8d645 100644 --- a/Documentation/BackendApi/openapi.yaml +++ b/MyINPulse-back/src/main/resources/openapi/main.yaml @@ -15,22 +15,24 @@ tags: components: schemas: - founder: + user: + type: object + properties: + nom: + type: string + prenom: + type: string + email: + type: string + scondaryEmail: + type: string + tel: + type: string + user-entrepreneur: type: object properties: user: - type: object - properties: - nom: - type: string - prenom: - type: string - email: - type: string - scondaryEmail: - type: string - tel: - type: string + $ref: "#/components/schemas/user" entrepreneur: type: object properties: @@ -40,6 +42,11 @@ components: type: string status: type: string + user-admin: + type: object + properties: + admin: + $ref: "#/components/schemas/user" securitySchemes: MyINPulse: @@ -139,13 +146,13 @@ paths: name: type: string founder: - $ref: "#/components/schemas/founder" + $ref: "#/components/schemas/user-entrepreneur" "400": description: Bad request "401": description: Authorization information is missing or invalid - /projects/lcsection/{projectId}/{title}/{date}: + /shared/projects/lcsection/{projectId}/{title}/{date}: get: summary: Retourne la liste de sections de LC avec un titre donné tags: @@ -173,7 +180,7 @@ paths: description: the name of lc section - in: path name: date - required: true + required: false schema: type: string description: the date corresponding to the wanted version of lc section @@ -198,7 +205,7 @@ paths: "401": description: Authorization information is missing or invalid - /projects/entrepreneurs/{projectId}: + /shared/projects/entrepreneurs/{projectId}: get: summary: Retourne la liste d'entrepreneurs associée à un projet donné tags: @@ -224,14 +231,15 @@ paths: schema: type: array items: - type: string + $ref: "#/components/schemas/user-entrepreneur" "400": description: Bad request "401": description: Authorization information is missing or invalid - /projects/contacts/entrepreneurs/{projectId}: + + /shared/projects/admin/{projectId}: get: - summary: Retourne la liste des contactes d'entrepreneurs associée à un projet donné + summary: Retourne les inforùations de l'admin qui accompagne le projet tags: - Shared API security: @@ -239,9 +247,8 @@ paths: - MyINPulse-admin - MyINPulse-entrepreneur description: - JSON array of contacts for - each participant in the project with id - projectID. + JSON object containing information (name, gmail, tel, etc..) + the admin supervising the project with id projectID. parameters: - in: path name: projectId @@ -254,64 +261,16 @@ paths: content: application/json: schema: - type: array - items: - type: object - properties: - name: - type: string - email: - type: string - tel: - type: string + $ref: "#/components/schemas/user-admin" "400": description: Bad request "401": description: Authorization information is missing or invalid - /projects/contacts/admin/{projectId}: + /shared/projects/appointments/{projectId}: get: - summary: Retourne les contacts de l'admin que accompagne le projet - tags: - - Shared API - security: - - MyINPulse: - - MyINPulse-admin - - MyINPulse-entrepreneur - description: - JSON object containing contact information (name, gmail, tel, etc..) - the admin supervising the project with id - projectID. - parameters: - - in: path - name: projectId - schema: - type: integer - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - type: object - properties: - name: - type: string - email: - type: string - tel: - type: string - "400": - description: Bad request - "401": - description: Authorization information is - missing or invalid - - /projects/appointments/{projectId}: - get: - summary: Retourne les rendez-vous du project + summary: Retourne les rendez-vous du projet tags: - Shared API security: @@ -350,7 +309,7 @@ paths: "401": description: Authorization information is missing or invalid - /projects/appointments/report/{apointementId}: + /shared/projects/appointments/report/{apointementId}: get: summary: Retourne le rapport pdf du rendez-vous tags: @@ -382,7 +341,7 @@ paths: description: Authorization information is missing or invalid - /projects/request: + /entrepreneur/projects/request: post: summary: demander la création et validation d'un projet tags: @@ -404,7 +363,7 @@ paths: name: type: string founder: - $ref: "#/components/schemas/founder" + $ref: "#/components/schemas/user-entrepreneur" responses: "200": description: OK @@ -470,12 +429,8 @@ paths: properties: name: type: string - founderName: - type: string - founderEmail: - type: string - school: - type: string + founder: + $ref: "#/components/schemas/user-entrepreneur" responses: "200": @@ -513,7 +468,7 @@ paths: description: Authorization information is missing or invalid - /lcsection/add/{projectId}: + /entrepreneur/lcsection/add/{projectId}: post: summary: ajouter une sections au LC description: @@ -549,7 +504,7 @@ paths: "401": description: Authorization information is missing or invalid - /lcsection/modify/{sectionId}: + /entrepreneur/lcsection/modify/{sectionId}: put: summary: modifier les données d'une section LC description: @@ -587,7 +542,7 @@ paths: description: Authorization information is missing or invalid - /lcsection/remove/{sectionId}: + /entrepreneur/lcsection/remove/{sectionId}: delete: summary: supprimer une section LC. description: @@ -612,7 +567,7 @@ paths: description: Authorization information is missing or invalid - /appointments/request: + /shared/appointments/request: post: summary: demander une rendez-vous description: @@ -696,6 +651,4 @@ paths: "401": description: Authorization information is missing or invalid - - - \ No newline at end of file + \ No newline at end of file