2.5.0 • Published 11 months ago

@har-sdk/validator v2.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@har-sdk/validator

A validator for HAR v1.2 Spec, OpenAPI and Postman documents.

Setup

npm i --save @har-sdk/validator

Usage

import { OpenAPIV2 } from '@har-sdk/types';
import { OASValidator, ErrorHumanizer } from '@har-sdk/validator';

const apiDoc = {
  swagger: '2.0',
  host: 'localhost',
  info: {
    title: 'Some valid API document'
  },
  paths: {}
} as OpenAPIV2.Document;

const errors = await new OASValidator().verify(apiDoc as any);
console.log(errors);
// [
//   {
//     "instancePath": "/info",
//     "schemaPath": "#/required",
//     "keyword": "required",
//     "params": {
//       "missingProperty": "version"
//     },
//     "message": "must have required property 'version'"
//   }
// ]

const humanizedErrors = await new ErrorHumanizer().humanizeErrors(errors);
console.log(humanizedErrors);
// [
//   {
//     "originalError": {
//       "instancePath": "/info",
//       "schemaPath": "#/required",
//       "keyword": "required",
//       "params": {
//         "missingProperty": "version"
//       },
//       "message": "must have required property 'version'"
//     },
//     "message": "the value at /info is missing the required field `version`",
//     "messageParts": [
//       {
//         "text": "the value at /info",
//         "jsonPointer": "/info"
//       },
//       {
//         "text": "is missing the required field `version`"
//       }
//     ]
//   }
// ]

See Error Object

2.5.0

11 months ago

2.4.19

1 year ago

2.4.18

2 years ago

2.4.17

2 years ago

2.4.14

2 years ago

2.4.13

2 years ago

2.4.16

2 years ago

2.4.15

2 years ago

2.4.10

2 years ago

2.4.12

2 years ago

2.4.11

2 years ago

2.4.9

2 years ago

2.4.7

2 years ago

2.4.6

2 years ago

2.4.8

2 years ago

2.3.0

2 years ago

2.2.1

2 years ago

2.4.1

2 years ago

2.4.0

2 years ago

2.4.3

2 years ago

2.4.2

2 years ago

2.4.5

2 years ago

2.4.4

2 years ago

2.0.3

2 years ago

2.2.0

2 years ago

2.0.2

2 years ago

2.1.0

2 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago