autodesk-forks-sway
v2.2.0
Published
A forked library that simplifies OpenAPI integrations.
Downloads
392
Readme
autodesk-forks-sway
This package is a fork of apigee-127/sway. The purpose of this fork is to update dependencies and continue to maintain the original package.
Would you like to contribute? Read our contribution guidelines.
:book: Resources
Getting started
You can install this fork via npm:
npm i autodesk-forks-swagger-node-runner
Sample usage:
const Sway = require("autodesk-forks-sway");
const YAML = require('js-yaml');
const fs = require("fs");
const path = require("path");
Sway.create({
definition: YAML.load(fs.readFileSync(path.join(__dirname, './test/browser/documents/2.0/swagger.yaml'), 'utf8')),
})
.then(apiDef => {
const goodParamValue = apiDef.getOperation('/pet/findByStatus', 'get').getParameter('status').getValue({
query: {
status: 'available'
}
});
console.log(goodParamValue.valid); // will be true
const badParamValue = apiDef.getOperation('/pet/findByStatus', 'get').getParameter('status').getValue({
query: {
status: 1
}
});
console.log(badParamValue.valid); // will be false
})
.catch(console.error)