Newman Reporter



I plan to implement a custom reporter for Newman, a CLI runner for Postman. My goal is to validate requests executed by Newman against a RAML definition to find deviations, calculate test coverage, spec coverage etc.

Since I’ve little to no experice with NodeJS and JS I’d like to start with a simple use-case, JSON response body validation. For that I need the JSON Schema of a particular response. I already found raml-1-parser, but what’s the result of JSONBody.schema()? Is it really a ready-to-use JSON Schema that can be used by a validator, e.g. ajv?



How do you access the JS parser?


I didn’t even start yet, I’m rather trying to find out what’s already there (libs etc.).

I’d probably try that:

var raml1Parser = require('some/path');
var api = raml1Parser.loadApiSync('path/to/api.raml');


There is a little handy tool that we currently look at integrating into the parsers load method.

That tool gives you a JSON object back that usually is much more convenient to handle in NodeJS. Although, it is not as powerful as using the AST which you get using loadApiSync indeed. That AST is more powerful since you have much more information you can work with and also analyse types in more details. JSON object vs AST? It really depends on your use case and how much from the original document you need.

Maybe share the link to your project and I see how much I can help you.


It looks like we talked past each other. I need to validate actual request and response body data against what is defined in an API spec for compliance testing.

This is what finally worked (for RAML 1.0):

var api = ramlParser.loadApiSync(myFile);
var body =  api.resources()[0].methods()[0].responses()[0].body()[0];

// find out if actual response body is valid
var testResponseBody = JSON.parse("{\"bar\": \"Hello, I\'m bar!\"}");