openapi-exec
v0.9.1
Published
OpenAPI executer for Nodejs
Downloads
2
Readme
openapi-node
OpenAPI executer for Nodejs
Installation
Install using npm:
npm i openapi-exec
Example
Execute official example with node-fetch
const load = require('js-yaml').safeLoad
const fetch = require('node-fetch')
const OpenAPI = require('openapi-exec')
fetch('https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/yaml/uber.yaml')
.then((res) => res.text())
.then((yaml) => load(yaml))
.then((schema) => OpenAPI.createWithResolve(schema))
.then((client) => {
client.setCredentials('apiKey', { server_token: 'xxxxxxxxxxxxxxxxx' })
return client.operate('/products', 'get', {
latitude: 35.681382,
longitude: 139.7638953,
})
})
.then((res) => res.json())
.then((json) => console.log('OK:', json))
.catch((e) => console.error(e.stack))
Contributing
This repository uses JavaScript Standard Style.
Please check format & test compatibility.
- Fork this repo
- Create topic branch
- Run
npm test
- Make pull request