Skip to content

Commit 07fb15b

Browse files
author
Bingjie Liu
authored
Merge pull request #355 from ministryofjustice/HIA-540
Adding data key for person response
2 parents 3e135ed + 374452d commit 07fb15b

File tree

4 files changed

+39
-32
lines changed

4 files changed

+39
-32
lines changed

openapi.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,13 @@ paths:
7575
schema:
7676
type: object
7777
properties:
78-
prisonerOffenderSearch:
79-
$ref: "#/components/schemas/Person"
80-
probationOffenderSearch:
81-
$ref: "#/components/schemas/Person"
78+
data:
79+
type: object
80+
properties:
81+
prisonerOffenderSearch:
82+
$ref: "#/components/schemas/Person"
83+
probationOffenderSearch:
84+
$ref: "#/components/schemas/Person"
8285
"404":
8386
description: Failed to find a person with the provided HMPPS ID.
8487
content:

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/PersonController.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class PersonController(
4949
}
5050

5151
@GetMapping("{encodedHmppsId}")
52-
fun getPerson(@PathVariable encodedHmppsId: String): Person? {
52+
fun getPerson(@PathVariable encodedHmppsId: String): Map<String, Person?> {
5353
val hmppsId = encodedHmppsId.decodeUrlCharacters()
5454
val response = getPersonService.execute(hmppsId)
5555

@@ -58,7 +58,7 @@ class PersonController(
5858
}
5959

6060
auditService.createEvent("GET_PERSON_DETAILS", "Person details with hmpps id: $hmppsId has been retrieved")
61-
return response.data
61+
return mapOf("data" to response.data)
6262
}
6363

6464
@GetMapping("{encodedHmppsId}/images")

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/PersonControllerTest.kt

+2
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ internal class PersonControllerTest(
277277
result.response.contentAsString.shouldBe(
278278
"""
279279
{
280+
"data": {
280281
"firstName": "Silly",
281282
"lastName": "Sobbers",
282283
"middleName": null,
@@ -292,6 +293,7 @@ internal class PersonControllerTest(
292293
"pncId": null,
293294
"hmppsId": null
294295
}
296+
}
295297
""".removeWhitespaceAndNewlines(),
296298
)
297299
}

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/smoke/person/PersonSmokeTest.kt

+28-26
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,34 @@ class PersonSmokeTest : DescribeSpec(
4444

4545
response.body().shouldBe(
4646
"""
47-
{
48-
"firstName": "string",
49-
"lastName": "string",
50-
"middleName": "string",
51-
"dateOfBirth": "2019-08-24",
52-
"gender": "string",
53-
"ethnicity": "string",
54-
"aliases": [
55-
{
56-
"firstName": "string",
57-
"lastName": "string",
58-
"middleName": "string",
59-
"dateOfBirth": "2019-08-24",
60-
"gender": "string",
61-
"ethnicity": null
62-
}
63-
],
64-
"identifiers": {
65-
"nomisNumber": "string",
66-
"croNumber": "string",
67-
"deliusCrn": "string"
68-
},
69-
"pncId": "string",
70-
"hmppsId": "string"
71-
}
72-
""".removeWhitespaceAndNewlines(),
47+
{
48+
"data": {
49+
"firstName": "string",
50+
"lastName": "string",
51+
"middleName": "string",
52+
"dateOfBirth": "2019-08-24",
53+
"gender": "string",
54+
"ethnicity": "string",
55+
"aliases": [
56+
{
57+
"firstName": "string",
58+
"lastName": "string",
59+
"middleName": "string",
60+
"dateOfBirth": "2019-08-24",
61+
"gender": "string",
62+
"ethnicity": null
63+
}
64+
],
65+
"identifiers": {
66+
"nomisNumber": "string",
67+
"croNumber": "string",
68+
"deliusCrn": "string"
69+
},
70+
"pncId": "string",
71+
"hmppsId": "string"
72+
}
73+
}
74+
""".removeWhitespaceAndNewlines(),
7375
)
7476
}
7577

0 commit comments

Comments
 (0)