Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
266 changes: 266 additions & 0 deletions api/openapi.yml
Original file line number Diff line number Diff line change
@@ -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]
62 changes: 62 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<!-- Dependencies required for OpenAPI code generation -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.28</version>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>

<!-- Dependencies for OpenAPI documentation and Swagger UI -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.5</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -168,6 +187,49 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.11.0</version>
<executions>
<execution>
<id>appointmentBooking</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/api/openapi.yml</inputSpec>
<output>${project.build.directory}/generated-sources/openapi</output>
<cleanupOutput>true</cleanupOutput>
<generatorName>spring</generatorName>
<apiPackage>com.capgemini.training.appointmentbooking.service.api</apiPackage>
<modelPackage>com.capgemini.training.appointmentbooking.service.model</modelPackage>
<!--<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>-->
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<configOptions>
<!-- <delegatePattern>true</delegatePattern>-->
<useTags>true</useTags>
<library>spring-boot</library>
<interfaceOnly>true</interfaceOnly>
<skipDefaultInterface>true</skipDefaultInterface>
<useSpringBoot3>true</useSpringBoot3>
<useOptional>true</useOptional>
<useBeanValidation>true</useBeanValidation>
<dateLibrary>java-time</dateLibrary>
<generateBuilders>false</generateBuilders>
<generateConstructorWithAllArgs>true</generateConstructorWithAllArgs>
<additionalModelTypeAnnotations>
@lombok.Generated
@lombok.ToString
</additionalModelTypeAnnotations>
<documentationProvider>source</documentationProvider>
<annotationLibrary>swagger2</annotationLibrary>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.capgemini.training.appointmentbooking.service.config;

import com.capgemini.training.appointmentbooking.service.mapper.AppointmentApiMapper;
import com.capgemini.training.appointmentbooking.service.mapper.TreatmentApiMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ServiceMappingConfiguration {

@Bean
AppointmentApiMapper getAppointmentApiMapper() {
return new AppointmentApiMapper();
}

@Bean
TreatmentApiMapper getTreatmentApiMapper() {
return new TreatmentApiMapper();
}
}
Loading
Loading