You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to write a plugin which works in the response context and cannot access any environment values when handling the response. It would also be necessary to view the request ion the same context.
Context - I'm trying to write a plugin which validates a response body against a path in an API spec. I don't want to hardcode the spec file location on disk and make those assumptions. I want to be able to set up a different spec file by directing users to create a key called schema which will be a string with an absolute path that the response handlers can access.
Pseudo:
constfs=require('fs');module.exports.responseHooks=[context=>{letbody=context.response.getBody();if(body!==null){letschemaLocation=context.response.getEnvironmentVariable('schema');if(schemaLocation!==undefined&&fs.exists(schemaLocation)){// does validation work here}}}];
What you'll also notice is that where the validation work needs to happen, I would need to know the request method and endpoint so that I can dynamically search the schema based on path / method so really, the context in a response needs to have the request context available as well (minus any methods that can no longer apply - setHeader and other set methods for example).
The text was updated successfully, but these errors were encountered:
👋 Thanks for opening your first issue! If you're reporting a 🐞 bug, please make sure
you include steps to reproduce it. If you're requesting a feature 🎁, please provide real
use cases that would benefit. 👪
To help make this a smooth process, please be sure you have first read the contributing guidelines.
Details
I'm trying to write a plugin which works in the response context and cannot access any environment values when handling the response. It would also be necessary to view the request ion the same context.
Context - I'm trying to write a plugin which validates a response body against a path in an API spec. I don't want to hardcode the spec file location on disk and make those assumptions. I want to be able to set up a different spec file by directing users to create a key called
schema
which will be a string with an absolute path that the response handlers can access.Pseudo:
What you'll also notice is that where the validation work needs to happen, I would need to know the request method and endpoint so that I can dynamically search the schema based on path / method so really, the context in a response needs to have the request context available as well (minus any methods that can no longer apply -
setHeader
and other set methods for example).The text was updated successfully, but these errors were encountered: