# node-request-by-swagger

> Constructs request.js options from swagger endpoint

Latest version **1.1.4** (published 2018-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-request-by-swagger
pnpm add node-request-by-swagger
yarn add node-request-by-swagger
bun add node-request-by-swagger
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2018-11-01 |
| First published | 2016-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 27 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Roman Krivtsov |
| Maintainers | yarax |
| Keywords | swagger, request, request.js |

## Links

- npm: https://www.npmjs.com/package/node-request-by-swagger
- Repository: https://github.com/yarax/node-request-by-swagger
- Homepage: https://github.com/yarax/node-request-by-swagger#readme
- Issues: https://github.com/yarax/node-request-by-swagger/issues
- npm.io page: https://npm.io/package/node-request-by-swagger

## Recent versions

- 1.1.4 (latest) — 2018-11-01
- 1.1.3 — 2018-06-02
- 1.1.2 — 2018-06-01
- 1.1.1 — 2018-06-01
- 1.1.0 — 2018-05-20
- 1.0.7 — 2018-03-01
- 1.0.6 — 2017-08-11
- 1.0.5 — 2016-12-08
- 1.0.4 — 2016-10-16
- 1.0.3 — 2016-10-16
- 1.0.2 — 2016-10-16
- 1.0.1 — 2016-10-16
- 1.0.0 — 2016-09-20

## README

# Request by Swagger

The library constructs [request](https://github.com/request/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](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterObject).
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'
        }
    },
});

```

---
_Source: https://npm.io/package/node-request-by-swagger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
