Question

Many of the server scripting packages/tools out there have the option to have a schema validation before the response is sent out to the clients. E.g. the fastify package for a Node.js has a pretty upfront one.

Only two use cases that I can think of is restricting excess data and security. I feel for the first one, we are in a pretty good bandwidth era to not think about optimizing some 0.2 KiB of data. As for security, a developer who is going to expose the private keys in a restricted environment will definitely do that with a schema-less environment.

I know there cannot be a theoretically answer to this question, but I am looking at a practical answer. Personally, I don't like having it as I think I would use the time for something else productive. At least at server side code. Think it should be covered in unit testing.

No correct solution

OTHER TIPS

I used to do this with XML back in the day. The idea is that you give your clients a schema and you should guarantee that you follow it, otherwise you might cause an error.

I agree with you though, Unit testing seem a better way of doing this for 99% of cases. You can imagine a complicated schema an a service which builds up a response with info from other services where it might be useful?

Licensed under: CC-BY-SA with attribution
scroll top