Skip to content

Commit fca1f78

Browse files
AMP-203 Added separate object for week commencing.
1 parent 67052f8 commit fca1f78

File tree

4 files changed

+101
-22
lines changed

4 files changed

+101
-22
lines changed

gradle/openapi.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ openApiGenerate {
1616
useTags : "true", // use tag for api name
1717
generatedConstructorWithRequiredArgs: "false", // else conflicts with lombok AllArgsConstructor
1818
openApiNullable : "false", // else generates classes JsonNullable imports
19-
additionalModelTypeAnnotations : "@lombok.Builder;@lombok.AllArgsConstructor;@lombok.NoArgsConstructor",
19+
additionalModelTypeAnnotations : "@lombok.Builder;@lombok.AllArgsConstructor;@lombok.NoArgsConstructor;@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)",
2020
]
2121
}

src/main/resources/openapi/openapi-spec.yml

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ info:
1313
name: MIT
1414
url: 'https://opensource.org/licenses/MIT'
1515

16+
tags:
17+
- name: Court Schedule
18+
description: Court Schedule API
1619
paths:
1720
/case/{case_urn}/courtschedule:
1821
get:
22+
tags:
23+
- Court Schedule
1924
description: Retrieve details of a court schedule by case URN and court room.
2025
operationId: getCourtScheduleByCaseUrn
21-
tags:
22-
- court Schedule
2326
parameters:
2427
- in: path
2528
name: case_urn
@@ -35,6 +38,37 @@ paths:
3538
application/json:
3639
schema:
3740
$ref: "#/components/schemas/CourtScheduleResponse"
41+
examples:
42+
Allocated:
43+
summary: Allocated Hearing
44+
value:
45+
hearings:
46+
hearingId: "HRG-123410"
47+
hearingType: "Trial"
48+
hearingDescription: "Sentencing for theft case"
49+
listNote: "Requires interpreter"
50+
courtSittings: [ {
51+
sittingStart: "2025-03-18T09:00:00Z",
52+
sittingEnd: "2025-03-25T12:00:00Z",
53+
judiciaryId: "123e4567-e89b-12d3-a456-426614174000",
54+
courtHouse: "223e4567-e89b-12d3-a456-426614174111",
55+
courtRoom: "b7a9cb95-4f7c-4aba-b9a2-8cb1ad3330b2"
56+
}]
57+
Week Commencing:
58+
summary: Week Commencing Hearing
59+
value:
60+
hearings:
61+
hearingId: "HRG-123906"
62+
hearingType: "Trial"
63+
hearingDescription: "Sentencing for theft case"
64+
listNote: "Requires interpreter"
65+
courtSittings: []
66+
weekCommencing:
67+
endDate: "2026-02-22"
68+
startDate: "2026-02-16"
69+
durationInWeeks: 1
70+
courtHouse: "223e4567-e89b-12d3-a456-426614174111"
71+
3872
'400':
3973
description: Bad input parameter
4074
content:
@@ -72,24 +106,32 @@ components:
72106
description: Will always be required but can be null
73107
type: string
74108
example: "Judge prefers afternoon start"
75-
weekCommencingStartDate:
76-
description: "Proposed hearing week start date"
77-
type: string
78-
example: "2026-02-16"
79-
weekCommencingEndDate:
80-
description: "One week calculated end date"
81-
type: string
82-
example: "2026-02-22"
83-
weekCommencingDurationInWeeks:
84-
description: "Number of week(s) hearing is proposed for"
85-
type: integer
86-
example: 1
109+
weekCommencing:
110+
description: Details of Week Commencing Hearing
111+
type: object
112+
properties:
113+
startDate:
114+
description: "Proposed hearing week start Date"
115+
type: string
116+
example: "2026-02-16"
117+
endDate:
118+
description: "One week calculated end Date"
119+
type: string
120+
example: "2026-02-22"
121+
durationInWeeks:
122+
description: "Number of week(s) hearing is proposed for"
123+
type: integer
124+
example: 1
125+
courtHouse:
126+
description: Court house details ref id
127+
type: string
128+
pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
129+
example: "223e4567-e89b-12d3-a456-426614174111"
87130
courtSittings:
88131
type: array
89132
items:
90133
$ref: '#/components/schemas/CourtSitting'
91134

92-
93135
CourtSitting:
94136
description: Details of court sittings
95137
type: object

src/main/resources/openapi/schema/courtSchedule.schema.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,41 @@
4343
"Judge prefers afternoon start"
4444
]
4545
},
46+
"weekCommencing": {
47+
"description": "Proposed hearing week start date",
48+
"type": "object",
49+
"properties": {
50+
"startDate": {
51+
"description": "Proposed hearing week start date",
52+
"type": "string",
53+
"examples": [
54+
"2026-02-16"
55+
]
56+
},
57+
"endDate": {
58+
"description": "One week calculated end date",
59+
"type": "string",
60+
"examples": [
61+
"2026-02-22"
62+
]
63+
},
64+
"durationInWeeks": {
65+
"description": "Number of week(s) hearing is proposed for",
66+
"type": "integer",
67+
"examples": [
68+
1
69+
]
70+
},
71+
"courtHouse": {
72+
"description": "Court house details ref id",
73+
"type": "string",
74+
"pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
75+
"examples": [
76+
"223e4567-e89b-12d3-a456-426614174111"
77+
]
78+
}
79+
}
80+
},
4681
"courtSittings": {
4782
"description": "Details of court sittings",
4883
"type": "array",

src/test/java/uk/gov/hmcts/cp/config/OpenApiObjectsTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
import lombok.extern.slf4j.Slf4j;
44
import org.junit.jupiter.api.Test;
55
import uk.gov.hmcts.cp.openapi.api.CourtScheduleApi;
6-
import uk.gov.hmcts.cp.openapi.model.CourtSchedule;
7-
import uk.gov.hmcts.cp.openapi.model.CourtScheduleResponse;
8-
import uk.gov.hmcts.cp.openapi.model.CourtSitting;
9-
import uk.gov.hmcts.cp.openapi.model.ErrorResponse;
10-
import uk.gov.hmcts.cp.openapi.model.Hearing;
6+
import uk.gov.hmcts.cp.openapi.model.*;
7+
118
import java.lang.reflect.Field;
129
import java.time.Instant;
1310

@@ -37,7 +34,12 @@ void generated_court_sitting_should_have_expected_fields() {
3734

3835
@Test
3936
void generated_hearing_should_have_expected_fields() {
40-
assertThat(Hearing.class).hasDeclaredFields("hearingId", "hearingType", "hearingDescription", "listNote", "weekCommencingStartDate", "weekCommencingEndDate", "weekCommencingDurationInWeeks", "courtSittings");
37+
assertThat(Hearing.class).hasDeclaredFields("hearingId", "hearingType", "hearingDescription", "listNote", "weekCommencing", "courtSittings");
38+
}
39+
40+
@Test
41+
void generated_week_commencing_should_have_expected_fields() {
42+
assertThat(HearingWeekCommencing.class).hasDeclaredFields("startDate", "endDate", "durationInWeeks", "courtHouse");
4143
}
4244

4345
@Test

0 commit comments

Comments
 (0)