DEV Community

OpenAPI (Swagger) specifications that write your tests for you (sort of)

Chris Williams on September 23, 2019

I recently wrote the article Handling API validation with OpenAPI (Swagger) documents in NodeJS, which went into how to pass on the work of input v...
Collapse
 
okbrown profile image
Orlando Brown

Hi, for point 2 of what your working on, is this error in operation?

As you can simply validate your output against your schema to ensure the output expectancies are as required. Anything foreign you set it to throw.

I have a working example somewhere I can get for you, that you should be able to integrate into your existing process.

Collapse
 
danjou profile image
Max Ludwig

Really nice, have been thinking about the same thing recently, specifically in the context of consumer driven contract testing.

There's something you've not covered though: all the write operations, i.e. POST, PUT, PATCH, and maybe even DELETE.

Collapse
 
scampiuk profile image
Chris Williams

Valid point, I may ammended this or follow it up with covering that and different response codes also