openapi-exec

0.9.1 • Public • Published

openapi-node

OpenAPI executer for Nodejs

js-standard-style Codeship Status for blockenio/openapi-node codecov.io

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.

  1. Fork this repo
  2. Create topic branch
  3. Run npm test
  4. Make pull request

Readme

Keywords

Package Sidebar

Install

npm i openapi-exec

Weekly Downloads

1

Version

0.9.1

License

MIT

Last publish

Collaborators

  • lekoleko