JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3385
  • Score
    100M100P100Q124064F
  • License MIT

Constructs request.js options from swagger endpoint

Package Exports

  • node-request-by-swagger

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-request-by-swagger) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Request by Swagger

The library constructs request options object, based on Swagger schema endpoint.

Objectives

Using REST one has to deal with many delivering data options: GET query, headers, body json, body multipart. All of these options can be described using Swagger schema parameters section. This library is an attempt to separate request logic from HTTP implementation details. So you can consider you endpoint as a function, that takes some arguments

Install

npm i --save node-request-by-swagger

Usage

const getRequestOptions = require('node-request-by-swagger');
const options = getRequestOptions(schema['/pet'].post, {
    method: 'post',
    baseUrl: `http://${schema.host}${schema.basePath}`,
    path: '/pet',
    args: {
        body: {
            name: 'bob'
        }
    },
});