Skip to content

Commit ffb1229

Browse files
committed
More fixes
1 parent b04af33 commit ffb1229

20 files changed

+45
-32
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/config/OpenAPIConfig.kt

+21-8
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,33 @@ class OpenAPIConfig {
5252
openApi.components
5353
.addSchemas(
5454
"BadRequest",
55-
Schema<ErrorResponse>()
56-
.example(ErrorResponse(400, userMessage = "Validation failure: No query parameters specified.", developerMessage = "No query parameters specified.")),
55+
Schema<ErrorResponse>().properties(
56+
mapOf(
57+
"status" to Schema<Int>().type("number").example(400),
58+
"userMessage" to Schema<String>().type("string").example("Validation failure: No query parameters specified."),
59+
"developerMessage" to Schema<String>().type("string").example("No query parameters specified."),
60+
),
61+
),
5762
)
5863
.addSchemas(
5964
"PersonNotFound",
60-
Schema<ErrorResponse>()
61-
.description("Failed to find a person with the provided HMPPS ID.")
62-
.example(ErrorResponse(404, userMessage = "404 Not found error: Could not find person with HMPPS id: 2003/0011991D.", developerMessage = "Could not find person with HMPPS id: 2003/0011991D.")),
65+
Schema<ErrorResponse>().description("Failed to find a person with the provided HMPPS ID.").properties(
66+
mapOf(
67+
"status" to Schema<Int>().type("number").example(404),
68+
"userMessage" to Schema<String>().type("string").example("404 Not found error: Could not find person with HMPPS id: 2003/0011991D."),
69+
"developerMessage" to Schema<String>().type("string").example("Could not find person with HMPPS id: 2003/0011991D."),
70+
),
71+
),
6372
)
6473
.addSchemas(
6574
"InternalServerError",
66-
Schema<ErrorResponse>()
67-
.description("An upstream service was not responding, so we cannot verify the accuracy of any data we did get.")
68-
.example(ErrorResponse(500, userMessage = "Internal Server Error", developerMessage = "Unable to complete request as an upstream service is not responding.")),
75+
Schema<ErrorResponse>().description("An upstream service was not responding, so we cannot verify the accuracy of any data we did get.").properties(
76+
mapOf(
77+
"status" to Schema<Int>().type("number").example(500),
78+
"userMessage" to Schema<String>().type("string").example("Internal Server Error"),
79+
"developerMessage" to Schema<String>().type("string").example("Unable to complete request as an upstream service is not responding."),
80+
),
81+
),
6982
)
7083
}
7184
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class EPFPersonDetailController(
3434
reduce the need for the EPF user to re-key information already held in Delius.</p>
3535
""",
3636
responses = [
37-
ApiResponse(responseCode = "200"),
37+
ApiResponse(responseCode = "200", useReturnTypeSchema = true),
3838
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3939
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
4040
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ImageController(
2727
@Operation(
2828
summary = "Returns an image in bytes as a JPEG.",
2929
responses = [
30-
ApiResponse(responseCode = "200", description = "Successfully found an image with the provided ID."),
30+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found an image with the provided ID."),
3131
ApiResponse(responseCode = "404", description = "Failed to find an image with the provided ID.", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3232
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3333
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class RiskManagementController(
3434
@Operation(
3535
summary = "Returns a list of Risk Management Plans created for the person with the provided HMPPS ID.",
3636
responses = [
37-
ApiResponse(responseCode = "200", description = "Successfully found risk management plans for a person with the provided HMPPS ID."),
37+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found risk management plans for a person with the provided HMPPS ID."),
3838
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3939
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
4040
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AddressController(
3131
@Operation(
3232
summary = "Returns addresses associated with a person, ordered by startDate.",
3333
responses = [
34-
ApiResponse(responseCode = "200", description = "Successfully found a person with the provided HMPPS ID."),
34+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found a person with the provided HMPPS ID."),
3535
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3636
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3737
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AdjudicationsController(
3232
@Operation(
3333
summary = "Returns adjudications associated with a person, sorted by dateTimeOfIncident (newest first).",
3434
responses = [
35-
ApiResponse(responseCode = "200", description = "OK"),
35+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "OK"),
3636
ApiResponse(responseCode = "404", description = "Failed to find adjudications for the person with the provided hmppsId.", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3737
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3838
],

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AlertsController(
3333
@Operation(
3434
summary = "Returns alerts associated with a person, sorted by dateCreated (newest first).",
3535
responses = [
36-
ApiResponse(responseCode = "200", description = "Successfully found alerts for a person with the provided HMPPS ID."),
36+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found alerts for a person with the provided HMPPS ID."),
3737
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3838
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3939
],
@@ -57,7 +57,7 @@ class AlertsController(
5757
@Operation(
5858
summary = "Returns alerts associated with a person, sorted by dateCreated (newest first).",
5959
responses = [
60-
ApiResponse(responseCode = "200", description = "Successfully found alerts for a person with the provided HMPPS ID."),
60+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found alerts for a person with the provided HMPPS ID."),
6161
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
6262
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
6363
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class CaseNotesController(
3636
@Operation(
3737
summary = "Returns case notes associated with a person.",
3838
responses = [
39-
ApiResponse(responseCode = "200", description = "Successfully found case notes for a person with the provided HMPPS ID."),
39+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found case notes for a person with the provided HMPPS ID."),
4040
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
4141
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
4242
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DynamicRisksController(
3333
@Operation(
3434
summary = "Returns dynamic risks associated with a person.",
3535
responses = [
36-
ApiResponse(responseCode = "200", description = "Successfully found dynamic risks for a person with the provided HMPPS ID."),
36+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found dynamic risks for a person with the provided HMPPS ID."),
3737
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3838
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3939
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LicenceConditionController(
3030
@Operation(
3131
summary = "Returns license conditions associated with a person, sorted by createdDateTime (newest first).",
3232
responses = [
33-
ApiResponse(responseCode = "200", description = "Successfully found licenses for a person with the provided HMPPS ID."),
33+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found licenses for a person with the provided HMPPS ID."),
3434
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3535
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3636
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MappaDetailController(
3030
@Operation(
3131
summary = "Returns the mappa detail related to a person.",
3232
responses = [
33-
ApiResponse(responseCode = "200", description = "Successfully found mappa detail for a person with the provided HMPPS ID."),
33+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found mappa detail for a person with the provided HMPPS ID."),
3434
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3535
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3636
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class NeedsController(
3535
However, the process by which needs are assessed is changing as early as next year (2024), specifically moving to a strength-based model that seeks to identify and develop the strengths of people with convictions. As a consequence of this, the information provided by this endpoint will also change.
3636
""",
3737
responses = [
38-
ApiResponse(responseCode = "200", description = "Successfully found criminogenic needs for a person with the provided HMPPS ID."),
38+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found criminogenic needs for a person with the provided HMPPS ID."),
3939
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
4040
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
4141
],

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class PersonController(
4646
@Operation(
4747
summary = "Returns person(s) by search criteria, sorted by date of birth (newest first). At least one query parameter must be specified.",
4848
responses = [
49-
ApiResponse(responseCode = "200", description = "Successfully performed the query on upstream APIs. An empty list is returned when no results are found."),
49+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully performed the query on upstream APIs. An empty list is returned when no results are found."),
5050
ApiResponse(
5151
responseCode = "400",
5252
description = "There were no query parameters passed in. At least one must be specified.",
@@ -85,7 +85,7 @@ class PersonController(
8585
@Operation(
8686
summary = "Returns a person.",
8787
responses = [
88-
ApiResponse(responseCode = "200", description = "Successfully found a person with the provided HMPPS ID."),
88+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found a person with the provided HMPPS ID."),
8989
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
9090
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
9191
],
@@ -109,7 +109,7 @@ class PersonController(
109109
@Operation(
110110
summary = "Returns metadata of images associated with a person sorted by captureDateTime (newest first).",
111111
responses = [
112-
ApiResponse(responseCode = "200", description = "Successfully found a person with the provided HMPPS ID. If a person doesn't have any images, then an empty list (`[]`) is returned in the `data` property."),
112+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found a person with the provided HMPPS ID. If a person doesn't have any images, then an empty list (`[]`) is returned in the `data` property."),
113113
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
114114
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
115115
],
@@ -135,7 +135,7 @@ class PersonController(
135135
@Operation(
136136
summary = "Returns a person's name",
137137
responses = [
138-
ApiResponse(responseCode = "200", description = "Successfully found a person with the provided HMPPS ID."),
138+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found a person with the provided HMPPS ID."),
139139
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
140140
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
141141
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PersonResponsibleOfficerController(
3232
@Operation(
3333
summary = "Returns the person responsible officer associated with a person.",
3434
responses = [
35-
ApiResponse(responseCode = "200", description = "Successfully found the person responsible officer for a person with the provided HMPPS ID."),
35+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found the person responsible officer for a person with the provided HMPPS ID."),
3636
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3737
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3838
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ProtectedCharacteristicsController(
3030
@Operation(
3131
summary = "Returns protected characteristics of a person.",
3232
responses = [
33-
ApiResponse(responseCode = "200"),
33+
ApiResponse(responseCode = "200", useReturnTypeSchema = true),
3434
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3535
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3636
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class RiskCategoriesController(
3030
@Operation(
3131
summary = "Returns the categories related to an offender.",
3232
responses = [
33-
ApiResponse(responseCode = "200", description = "Successfully found risk categories for a person with the provided HMPPS ID."),
33+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found risk categories for a person with the provided HMPPS ID."),
3434
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3535
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3636
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class RiskPredictorScoresController(
3232
@Operation(
3333
summary = "Returns risk scores from the last year associated with a person, sorted by completedDate (newest first). This endpoint does not serve LAO (Limited Access Offender) data.",
3434
responses = [
35-
ApiResponse(responseCode = "200", description = "Successfully found risk scores for a person with the provided HMPPS ID."),
35+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found risk scores for a person with the provided HMPPS ID."),
3636
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3737
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3838
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class RiskSeriousHarmController(
3030
@Operation(
3131
summary = "Returns Risk of Serious Harm (ROSH) risks associated with a person. Returns only assessments completed in the last year. This endpoint does not serve LAO (Limited Access Offender) data.",
3232
responses = [
33-
ApiResponse(responseCode = "200", description = "Successfully found risks for a person with the provided HMPPS ID."),
33+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found risks for a person with the provided HMPPS ID."),
3434
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3535
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3636
],

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class SentencesController(
3737
@Operation(
3838
summary = "Returns sentences associated with a person, sorted by dateOfSentencing (newest first).",
3939
responses = [
40-
ApiResponse(responseCode = "200", description = "Successfully found sentences for a person with the provided HMPPS ID."),
40+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found sentences for a person with the provided HMPPS ID."),
4141
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
4242
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
4343
],
@@ -61,7 +61,7 @@ class SentencesController(
6161
@Operation(
6262
summary = "Returns the key dates and adjustments about a person's release from prison for their latest sentence.",
6363
responses = [
64-
ApiResponse(responseCode = "200", description = "Successfully found latest sentence key dates and adjustments for a person with the provided HMPPS ID."),
64+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found latest sentence key dates and adjustments for a person with the provided HMPPS ID."),
6565
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
6666
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
6767
],

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class StatusInformationController(
3333
@Operation(
3434
summary = "Returns the status information associated with a person.",
3535
responses = [
36-
ApiResponse(responseCode = "200", description = "Successfully found status information for a person with the provided HMPPS ID."),
36+
ApiResponse(responseCode = "200", useReturnTypeSchema = true, description = "Successfully found status information for a person with the provided HMPPS ID."),
3737
ApiResponse(responseCode = "404", content = [Content(schema = Schema(ref = "#/components/schemas/PersonNotFound"))]),
3838
ApiResponse(responseCode = "500", content = [Content(schema = Schema(ref = "#/components/schemas/InternalServerError"))]),
3939
],

0 commit comments

Comments
 (0)