# ut-swagger2-validator

> Swagger2 validator

Latest version **0.5.7** (published 2022-05-09) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ut-swagger2-validator
pnpm add ut-swagger2-validator
yarn add ut-swagger2-validator
bun add ut-swagger2-validator
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.5.7 |
| Published | 2022-05-09 |
| First published | 2019-06-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 350.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | kalin.krustev |
| Keywords | swagger, swagger validator, swagger 2, swagger 2 validator |

## Links

- npm: https://www.npmjs.com/package/ut-swagger2-validator
- Repository: https://github.com/softwaregroup-bg/ut-swagger2-validator
- Homepage: https://github.com/softwaregroup-bg/ut-swagger2-validator#readme
- Issues: https://github.com/softwaregroup-bg/ut-swagger2-validator/issues
- npm.io page: https://npm.io/package/ut-swagger2-validator

## Dependencies (3)

- [ajv](https://npm.io/package/ajv.md) 8.6.3
- [ajv-formats](https://npm.io/package/ajv-formats.md) 2.1.1
- [@apidevtools/swagger-parser](https://npm.io/package/@apidevtools/swagger-parser.md) 10.0.3

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.5.7 (latest) — 2022-05-09
- 0.5.6 — 2022-04-20
- 0.5.5 — 2022-04-20
- 0.5.4 — 2022-04-20
- 0.5.3 — 2021-11-19
- 0.5.2 — 2021-09-15
- 0.5.1 — 2021-09-02
- 0.5.0 — 2021-09-02
- 0.4.2 — 2021-06-30
- 0.4.1 — 2021-06-30
- 0.3.4 — 2020-03-19
- 0.3.3 — 2020-03-02
- 0.3.2 — 2020-02-18
- 0.3.1 — 2019-08-08
- 0.3.0 — 2019-08-07
- … 2 more at https://npm.io/package/ut-swagger2-validator/versions

## README

# UT Swagger2 Validator

## Usage

```js
    const swaggerDocument = require('./swagger.json'); // some swagger document
    const swagger2Validator = requrie('ut-swagger2-validator');
    const validators = swagger2Validator(swaggerDocument);
    // some operationId corresponding to a given swagger document route
    const operationId = 'namespace.entity.action';
    const validator = validators[operationId];
    if (!validator) {
        // there is no validator matching the given operationId
    }
    // Note: 'pathParameters' might not be provided if 'path' is
    // provided and vice versa
    const requestValidationErrors = await validator.request({
        query,
        body,
        files,
        headers,
        pathParameters,
        path
    });
    if (requestValidationErrors.length > 0) {
        // there are request validation errors
    }
    const responseValidationErrors = await validator.response({status, body});
    if (responseValidationErrors.length > 0) {
        // there are response validation errors
    }
```

---
_Source: https://npm.io/package/ut-swagger2-validator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
