Skip to content

Instantly share code, notes, and snippets.

@marbemac
Last active March 18, 2016 00:19
Show Gist options
  • Save marbemac/ab1cad6cb1e4c85e63e5 to your computer and use it in GitHub Desktop.
Save marbemac/ab1cad6cb1e4c85e63e5 to your computer and use it in GitHub Desktop.
A barebones swagger example, that includes the StopLight extension to instruct Prism to validate and add a response header to all requests.
{
"swagger": "2.0",
"host": "myapi.com",
"schemes": ["http"],
"info": {},
"paths": {},
"definitions": {},
"x-stoplight": {
"beforeScript": "function(ctx, request) {}",
"afterScript": "function(ctx, request, response) { // messages contain any warnings or errors var messages = response.validate(); var isValid = response.valid.get(); // Set a header here, so that your testing tools can throw errors appropriately if (isValid) { response.header.set('Validation', 'Passed'); } else { response.header.set('Validation', 'Failed'); } }",
"mock": {
"enabled": false,
"dynamic": false
},
"functions": {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment