Hi Postman community!
I have recently started using postman for our API documentation + testing and am learning about the various functionality it offers… something I’d love to do but can’t seem to figure out whether it’s possible, is to extract part of the API schema into a variable in a pre-request script. The reason I’d like to do this is that for testing generally I want to test that the response matches a schema, but I don’t want to have to duplicate parts of the API schema in the different tests across collections. To have 2 sets of response schemas defined for each endpoint (one in the API schema, another in each test area) feels icky, would like to keep redundancy to a minimum. One thing I’ve noticed is that the responses are validated against the API schema already, which is kind of what I’m looking to do, but there’s no way of turning this validation into a test that I can run?
Any advice on how I can meet my testing reqs one way or another would be highly appreciated.