I’ve started implementing JSON schema validation in my tests and it’s a bit of pain, and of course, a maintenance nightmare.
I’ve currently got my schema defined in the “Pre-request Script” on a request and save it as an environment variable.
If this request is used several times in a test collection, then I have to make sure that the “original” request is made first as that’s where the JSON schema env variable is defined (Unless I define it in every “Pre-request Script” for this request!? Which would be an even bigger maintenance nightmare!)
Have the ability to upload/attach files (JSON/CSV) to an environment.
- This means I can define the JSON schema for given requests in ONE place
- This also removes the “snowballing” affecting that is required in the above example.
- The user should be able to edit/create the files within Postman (in a separate window). This way, if a schema has changed the user can update the file quickly instead of having to open a text editor, find the file, edit it, save it, re-import into Postman and then re-run the test.
I’m sure this feature could be used for other things, but JSON schema validation is the main headache for me.
There’s a great article about making these sort of tests easier to maintain below, but it would be nicer if Postman handled this better