From b7963e56dce4b99e36f6cd541a3bdaa7bfc7bf27 Mon Sep 17 00:00:00 2001 From: Piotr Kubicki Date: Thu, 27 Feb 2025 12:41:58 +0100 Subject: [PATCH] feat: add OpenAPI spec and generator plugin to pom.xml --- api/openapi.yml | 266 ++++++++++++++++++++++++++++++++++++++++++++++++ pom.xml | 61 ++++++++++- 2 files changed, 326 insertions(+), 1 deletion(-) create mode 100644 api/openapi.yml diff --git a/api/openapi.yml b/api/openapi.yml new file mode 100644 index 0000000..5899a97 --- /dev/null +++ b/api/openapi.yml @@ -0,0 +1,266 @@ +openapi: 3.0.3 +info: + title: Appointment Booking API + description: API for managing appointments, treatments, clients, and specialists. + version: 1.0.0 + +servers: + - url: http://localhost:8080 + description: Local development server + +paths: + /treatments: + get: + summary: Get a list of available treatments + operationId: getTreatments + tags: + - Treatments + responses: + "200": + description: List of treatments + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/Treatment" + + post: + summary: Create a new treatment + operationId: createTreatment + tags: + - Treatments + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/TreatmentRequest" + responses: + "201": + description: Treatment successfully created + content: + application/json: + schema: + $ref: "#/components/schemas/Treatment" + "400": + description: Invalid request data + "403": + description: Only specialists can create treatments + + /treatments/{treatmentId}: + get: + summary: Get treatment details (with specialist info) + operationId: getTreatmentDetails + tags: + - Treatments + parameters: + - name: treatmentId + in: path + required: true + schema: + type: string + responses: + "200": + description: Treatment details including assigned specialist + content: + application/json: + schema: + $ref: "#/components/schemas/TreatmentDetails" + "404": + description: Treatment not found + + /appointments: + get: + summary: Get all appointments with filtering options + operationId: getAppointments + tags: + - Appointments + parameters: + - name: clientId + in: query + schema: + type: string + - name: specialistId + in: query + schema: + type: string + - name: status + in: query + schema: + type: string + enum: [SCHEDULED, CANCELLED, COMPLETED] + responses: + "200": + description: List of appointments + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/Appointment" + + post: + summary: Schedule an appointment + operationId: createAppointment + tags: + - Appointments + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AppointmentRequest" + responses: + "201": + description: Appointment successfully created + content: + application/json: + schema: + $ref: "#/components/schemas/Appointment" + "400": + description: Invalid request data + "409": + description: Appointment slot conflict + + /appointments/{appointmentId}: + patch: + summary: Update appointment status + operationId: updateAppointmentStatus + tags: + - Appointments + parameters: + - name: appointmentId + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AppointmentStatusUpdate" + responses: + "200": + description: Appointment status updated + "400": + description: Invalid status + "404": + description: Appointment not found + + /availability: + get: + summary: Check appointment slot availability + operationId: checkAvailability + tags: + - Appointments + parameters: + - name: specialistId + in: query + required: true + schema: + type: string + - name: dateTime + in: query + required: true + schema: + type: string + format: date-time + responses: + "200": + description: Slot availability result + content: + application/json: + schema: + type: object + properties: + available: + type: boolean + +components: + schemas: + Treatment: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + duration: + type: integer + description: Duration of the treatment in minutes + specialistId: + type: string + format: uuid + + TreatmentRequest: + type: object + properties: + name: + type: string + duration: + type: integer + specialistId: + type: string + format: uuid + + TreatmentDetails: + allOf: + - $ref: "#/components/schemas/Treatment" + - type: object + properties: + specialist: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + + AppointmentRequest: + type: object + required: + - clientId + - treatmentId + - dateTime + properties: + clientId: + type: string + format: uuid + treatmentId: + type: string + format: uuid + dateTime: + type: string + format: date-time + + Appointment: + type: object + properties: + id: + type: string + format: uuid + clientId: + type: string + format: uuid + treatmentId: + type: string + format: uuid + dateTime: + type: string + format: date-time + status: + type: string + enum: [SCHEDULED, CANCELLED, COMPLETED] + + AppointmentStatusUpdate: + type: object + required: + - status + properties: + status: + type: string + enum: [CANCELLED, COMPLETED] diff --git a/pom.xml b/pom.xml index fa69e55..cff0385 100644 --- a/pom.xml +++ b/pom.xml @@ -76,6 +76,25 @@ spring-security-test test + + + + io.swagger.core.v3 + swagger-annotations + 2.2.28 + + + org.openapitools + jackson-databind-nullable + 0.2.6 + + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.8.5 + @@ -135,10 +154,50 @@ - Test Report true + + org.openapitools + openapi-generator-maven-plugin + 7.11.0 + + + appointmentBooking + + generate + + + ${project.basedir}/api/openapi.yml + ${project.build.directory}/generated-sources/openapi + true + spring + com.capgemini.training.appointment_booking_app.api + com.capgemini.training.appointment_booking_app.model + ApiUtil.java + false + false + + + true + spring-boot + true + true + true + java-time + false + true + + @lombok.Generated + @lombok.ToString + + source + swagger2 + + + + +