raml-tester
raml-tester copied to clipboard
use it to validate real requests?
Is this to say that it cannot validate real request? Because I tried and I cannot make it work (with JAX-RS). I just cannot figure out how to do it. What is assumingBaseUri
for?
With "real" I mean requests during the productive runtime of an application, not in tests. This issue is about special support/documentation for this, there's no reason it shouldn't work right now.
There are probably more JAX-RS specific possibilities, but the simplest thing that should work would be a ServletFilter along these lines:
public class RamlFilter implements Filter {
private RamlDefinition api;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
api = RamlLoaders.fromClasspath(getClass()).load("api.raml");
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
final RamlReport report = api.testAgainst(request, response, chain);
//do something with the report
}
}
Or you could use https://github.com/nidi3/raml-tester-proxy. It's a proxy that sits between the client and the server and logs all requests that are not conforming to the RAML.