Trying to build a config validator in Kotlin that checks if specific API scopes are assigned to our integration clients. The goal is to prevent deployment failures by verifying scope presence before we spin up services. I’m hitting GET /api/v2/oauth/clients with a bearer token. The response comes back with a entities list, but the structure is a bit messy. Each client object has a scopes field, but it’s not always a simple list of strings. Sometimes it’s empty, sometimes it’s nested.
Here’s what I’m seeing in the JSON payload:
{
"entities": [
{
"id": "abc-123",
"name": "TestClient",
"scopes": ["admin:users:read", "webmessaging:guest:send"]
},
{
"id": "def-456",
"name": "LegacyClient",
"scopes": []
}
]
}
I’m using Jackson to deserialize this into a data class. The issue is handling the scopes array correctly when some clients have no scopes defined. My current data class throws a MismatchedInputException if the array is missing entirely, even though the docs say it should be present. Should I be using @JsonProperty with a default value? Or is there a better way to filter these clients programmatically in Kotlin without blowing up on empty arrays? The docs for this endpoint are sparse on the exact schema details.