Skip to main content

Posts

Showing posts from October, 2016

JSON Schema testing with Postman

Postman is becoming quite the popular tool for accessing and testing REST api services. One of the cool features is that you can write some Javascript tests on your responses. Built into Postman is also the Tiny Validator v4 and Cheerio. Cheerio is a small core JQuery like implementation. The problem I have is that there is no way to import a schema file from a remote place or a file. This will be about how I get around that issue.Pre-request Script var uri='http://someUrl.com'; $.get(uri + '/someFolder/schema.json', function(schema) { postman.setEnvironmentVariable('schema', JSON.stringify(schema)); }); This Pre-request script is what saves the day. There are a couple of timing issues that are present due to async processing. If you were to put this in your test script your chances of it not completing in time are very high and you would get inconsistent results. If you are familiar with JQuery the $.get should look familiar as a ajax call that d…