Skip to content

Commit 9628edc

Browse files
author
Piotr Kubicki
committed
feat: add OpenAPI spec and generator plugin to pom.xml
1 parent 9fba4a1 commit 9628edc

File tree

2 files changed

+326
-0
lines changed

2 files changed

+326
-0
lines changed

api/openapi.yml

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
openapi: 3.0.3
2+
info:
3+
title: Appointment Booking API
4+
description: API for managing appointments, treatments, clients, and specialists.
5+
version: 1.0.0
6+
7+
servers:
8+
- url: http://localhost:8080
9+
description: Local development server
10+
11+
paths:
12+
/treatments:
13+
get:
14+
summary: Get a list of available treatments
15+
operationId: getTreatments
16+
tags:
17+
- Treatments
18+
responses:
19+
"200":
20+
description: List of treatments
21+
content:
22+
application/json:
23+
schema:
24+
type: array
25+
items:
26+
$ref: "#/components/schemas/Treatment"
27+
28+
post:
29+
summary: Create a new treatment
30+
operationId: createTreatment
31+
tags:
32+
- Treatments
33+
requestBody:
34+
required: true
35+
content:
36+
application/json:
37+
schema:
38+
$ref: "#/components/schemas/TreatmentRequest"
39+
responses:
40+
"201":
41+
description: Treatment successfully created
42+
content:
43+
application/json:
44+
schema:
45+
$ref: "#/components/schemas/Treatment"
46+
"400":
47+
description: Invalid request data
48+
"403":
49+
description: Only specialists can create treatments
50+
51+
/treatments/{treatmentId}:
52+
get:
53+
summary: Get treatment details (with specialist info)
54+
operationId: getTreatmentDetails
55+
tags:
56+
- Treatments
57+
parameters:
58+
- name: treatmentId
59+
in: path
60+
required: true
61+
schema:
62+
type: string
63+
responses:
64+
"200":
65+
description: Treatment details including assigned specialist
66+
content:
67+
application/json:
68+
schema:
69+
$ref: "#/components/schemas/TreatmentDetails"
70+
"404":
71+
description: Treatment not found
72+
73+
/appointments:
74+
get:
75+
summary: Get all appointments with filtering options
76+
operationId: getAppointments
77+
tags:
78+
- Appointments
79+
parameters:
80+
- name: clientId
81+
in: query
82+
schema:
83+
type: string
84+
- name: specialistId
85+
in: query
86+
schema:
87+
type: string
88+
- name: status
89+
in: query
90+
schema:
91+
type: string
92+
enum: [SCHEDULED, CANCELLED, COMPLETED]
93+
responses:
94+
"200":
95+
description: List of appointments
96+
content:
97+
application/json:
98+
schema:
99+
type: array
100+
items:
101+
$ref: "#/components/schemas/Appointment"
102+
103+
post:
104+
summary: Schedule an appointment
105+
operationId: createAppointment
106+
tags:
107+
- Appointments
108+
requestBody:
109+
required: true
110+
content:
111+
application/json:
112+
schema:
113+
$ref: "#/components/schemas/AppointmentRequest"
114+
responses:
115+
"201":
116+
description: Appointment successfully created
117+
content:
118+
application/json:
119+
schema:
120+
$ref: "#/components/schemas/Appointment"
121+
"400":
122+
description: Invalid request data
123+
"409":
124+
description: Appointment slot conflict
125+
126+
/appointments/{appointmentId}:
127+
patch:
128+
summary: Update appointment status
129+
operationId: updateAppointmentStatus
130+
tags:
131+
- Appointments
132+
parameters:
133+
- name: appointmentId
134+
in: path
135+
required: true
136+
schema:
137+
type: string
138+
requestBody:
139+
required: true
140+
content:
141+
application/json:
142+
schema:
143+
$ref: "#/components/schemas/AppointmentStatusUpdate"
144+
responses:
145+
"200":
146+
description: Appointment status updated
147+
"400":
148+
description: Invalid status
149+
"404":
150+
description: Appointment not found
151+
152+
/availability:
153+
get:
154+
summary: Check appointment slot availability
155+
operationId: checkAvailability
156+
tags:
157+
- Appointments
158+
parameters:
159+
- name: specialistId
160+
in: query
161+
required: true
162+
schema:
163+
type: string
164+
- name: dateTime
165+
in: query
166+
required: true
167+
schema:
168+
type: string
169+
format: date-time
170+
responses:
171+
"200":
172+
description: Slot availability result
173+
content:
174+
application/json:
175+
schema:
176+
type: object
177+
properties:
178+
available:
179+
type: boolean
180+
181+
components:
182+
schemas:
183+
Treatment:
184+
type: object
185+
properties:
186+
id:
187+
type: string
188+
format: uuid
189+
name:
190+
type: string
191+
duration:
192+
type: integer
193+
description: Duration of the treatment in minutes
194+
specialistId:
195+
type: string
196+
format: uuid
197+
198+
TreatmentRequest:
199+
type: object
200+
properties:
201+
name:
202+
type: string
203+
duration:
204+
type: integer
205+
specialistId:
206+
type: string
207+
format: uuid
208+
209+
TreatmentDetails:
210+
allOf:
211+
- $ref: "#/components/schemas/Treatment"
212+
- type: object
213+
properties:
214+
specialist:
215+
type: object
216+
properties:
217+
id:
218+
type: string
219+
format: uuid
220+
name:
221+
type: string
222+
223+
AppointmentRequest:
224+
type: object
225+
required:
226+
- clientId
227+
- treatmentId
228+
- dateTime
229+
properties:
230+
clientId:
231+
type: string
232+
format: uuid
233+
treatmentId:
234+
type: string
235+
format: uuid
236+
dateTime:
237+
type: string
238+
format: date-time
239+
240+
Appointment:
241+
type: object
242+
properties:
243+
id:
244+
type: string
245+
format: uuid
246+
clientId:
247+
type: string
248+
format: uuid
249+
treatmentId:
250+
type: string
251+
format: uuid
252+
dateTime:
253+
type: string
254+
format: date-time
255+
status:
256+
type: string
257+
enum: [SCHEDULED, CANCELLED, COMPLETED]
258+
259+
AppointmentStatusUpdate:
260+
type: object
261+
required:
262+
- status
263+
properties:
264+
status:
265+
type: string
266+
enum: [CANCELLED, COMPLETED]

pom.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@
6161
<artifactId>spring-boot-starter-test</artifactId>
6262
<scope>test</scope>
6363
</dependency>
64+
65+
<!-- Dependencies required for OpenAPI code generation -->
66+
<dependency>
67+
<groupId>io.swagger.core.v3</groupId>
68+
<artifactId>swagger-annotations</artifactId>
69+
<version>2.2.28</version>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.openapitools</groupId>
73+
<artifactId>jackson-databind-nullable</artifactId>
74+
<version>0.2.6</version>
75+
</dependency>
76+
77+
<!-- Dependencies for OpenAPI documentation and Swagger UI -->
78+
<dependency>
79+
<groupId>org.springdoc</groupId>
80+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
81+
<version>2.8.5</version>
82+
</dependency>
6483
</dependencies>
6584

6685
<build>
@@ -123,6 +142,47 @@
123142
<aggregate>true</aggregate>
124143
</configuration>
125144
</plugin>
145+
<plugin>
146+
<groupId>org.openapitools</groupId>
147+
<artifactId>openapi-generator-maven-plugin</artifactId>
148+
<version>7.11.0</version>
149+
<executions>
150+
<execution>
151+
<id>appointmentBooking</id>
152+
<goals>
153+
<goal>generate</goal>
154+
</goals>
155+
<configuration>
156+
<inputSpec>${project.basedir}/api/openapi.yml</inputSpec>
157+
<output>${project.build.directory}/generated-sources/openapi</output>
158+
<cleanupOutput>true</cleanupOutput>
159+
<generatorName>spring</generatorName>
160+
<apiPackage>com.capgemini.training.appointment_booking_app.api</apiPackage>
161+
<modelPackage>com.capgemini.training.appointment_booking_app.model</modelPackage>
162+
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
163+
<generateApiTests>false</generateApiTests>
164+
<generateModelTests>false</generateModelTests>
165+
<configOptions>
166+
<!-- <delegatePattern>true</delegatePattern>-->
167+
<useTags>true</useTags>
168+
<library>spring-boot</library>
169+
<useSpringBoot3>true</useSpringBoot3>
170+
<useOptional>true</useOptional>
171+
<useBeanValidation>true</useBeanValidation>
172+
<dateLibrary>java-time</dateLibrary>
173+
<generateBuilders>false</generateBuilders>
174+
<generateConstructorWithAllArgs>true</generateConstructorWithAllArgs>
175+
<additionalModelTypeAnnotations>
176+
@lombok.Generated
177+
@lombok.ToString
178+
</additionalModelTypeAnnotations>
179+
<documentationProvider>source</documentationProvider>
180+
<annotationLibrary>swagger2</annotationLibrary>
181+
</configOptions>
182+
</configuration>
183+
</execution>
184+
</executions>
185+
</plugin>
126186
</plugins>
127187
</build>
128188

0 commit comments

Comments
 (0)