0.5.7 • Published 2 years ago

ut-swagger2-validator v0.5.7

Weekly downloads
7
License
Apache-2.0
Repository
github
Last release
2 years ago

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
    }
0.5.7

2 years ago

0.5.4

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.3

2 years ago

0.5.2

3 years ago

0.5.0

3 years ago

0.5.1

3 years ago

0.4.1

3 years ago

0.4.2

3 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago