Skip to content

Commit f1a7ef5

Browse files
committed
Exclude errors from response if none populated
1 parent a40a4c0 commit f1a7ef5

File tree

1 file changed

+3
-1
lines changed
  • src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps

1 file changed

+3
-1
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/Response.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps
22

3-
data class Response<T>(val data: T, val errors: List<UpstreamApiError> = emptyList()) {
3+
import com.fasterxml.jackson.annotation.JsonInclude
4+
5+
data class Response<T>(val data: T, @JsonInclude(JsonInclude.Include.NON_EMPTY) val errors: List<UpstreamApiError> = emptyList()) {
46
companion object {
57
fun <T> merge(responses: List<Response<List<T>>>): Response<List<T>> = Response(data = responses.flatMap { it.data }, errors = responses.flatMap { it.errors })
68
}

0 commit comments

Comments
 (0)