Currently working on an API using NestJS and typeorm. I am in need of a way to verify the format of the data being returned to clients who make requests to it.
For instance, when accessing the /players
route, I expect the data to have a specific structure like so (represented in TypeScript):
[
{
id: number,
name: string,
hasCats: boolean, // optional
birthday: date-time,
team: {
id: number,
name: string
}
},
...
]
I haven't come across any tool that can validate whether the data matches this expected structure. As a workaround, I've had to create my own function. To define the pattern, I utilize the documentation data generated as JSON by Swagger at the /api-json
endpoint.
Are there any tools available for testing data structure conformity?