Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ut-swagger2-validator

softwaregroup-bg286Apache-2.00.5.7

Swagger2 validator

swagger, swagger validator, swagger 2, swagger 2 validator

readme

UT Swagger2 Validator

Usage

    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
    }

changelog

0.5.7 (2022-05-09)

Bug Fixes

0.5.6 (2022-04-20)

Bug Fixes

  • proper body validation in openapi3 mode (c768af6)

0.5.5 (2022-04-20)

0.5.4 (2022-04-20)

Bug Fixes

  • add openapi 3 json validation support for request/response (#8) (d5f4e03)

0.5.3 (2021-11-19)

Bug Fixes

  • UTCORE-152 fix path match if basepath is set (#7) (b130967)

0.5.2 (2021-09-15)

Bug Fixes

  • pass valid parameters to ajv [UTCORE-121] (cbead7f)

0.5.1 (2021-09-02)

Bug Fixes

  • methodValidator is sync (6b0bfc8)

0.5.0 (2021-09-02)

Features

  • get validator by path and method (178126e)

0.4.2 (2021-06-30)

Bug Fixes

  • deprecated api [UTCORE-121] (ba9bcf2)

0.4.1 (2021-06-30)

Bug Fixes

  • upgrade dependencies [UTCORE-121] (82aa581)

0.3.4 (2020-03-19)

Bug Fixes

  • required fields validation (58c8c9c)

0.3.3 (2020-03-02)

Bug Fixes

0.3.2 (2020-02-18)

Bug Fixes

0.3.1 (2019-08-08)

Bug Fixes

  • clone schema properly (f29311e)
  • handle oneOf, anyOf, allOf and not (7ff6625)

0.3.0 (2019-08-07)

Features

  • add support for x-nullable keyword (7fe3148)

0.2.0 (2019-07-09)

Features

  • ALZDFA1-431: cast values for path and query params according to schema (f0a5e80)

0.1.1 (2019-06-24)

Bug Fixes

  • add an example in the documentation (681c5ba)
  • initial version (6a818e8)