README
@readme/oas-to-har
Utility to transform an OAS operation into a HAR representation
Installation
npm install --save @readme/oas-to-har
Usage
const Oas = require('oas');
const oasToHar = require('@readme/oas-to-har');
const spec = new Oas('petstore.json');
console.log(oasToHar(spec, { path: '/pets', method: 'post'}));
oasToHar(har, operationSchema, values, auth, opts) => Object
oas
{Oas}: Instance of our oas/tooling class.operationSchema
{Object|Operation}: Can either be an object withpath
andmethod
properties (that exist in the supplied OAS), or an instance of ourOperation
class from oas/tooling - accessed throughnew Oas(spec).operation(path, method)
.values
{Object}: A object of payload data, with key-value data therein, that should be used to construct the request. Available data you can define here:path
query
body
cookie
formData
header
server
— If the supplied OAS has multiple severs or server variables you can use this to set which server and variables to use. Shape of it should be:{ selected: Integer, variables: { ...key-values }}
.selected
should coorespond to index of theservers
array in your OAS.
auth
{Object}: Authentication information for the request.opts.proxyUrl
{Boolean}: Boolean to toggle if composed HAR objects should have theirurl
be sent through our CORS-friendly proxy. Defaults tofalse
.
Credits
License
ISC