Socket
Socket
Sign inDemoInstall

@har-sdk/validator

Package Overview
Dependencies
16
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @har-sdk/validator

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


Version published
Weekly downloads
243
increased by115.04%
Maintainers
2
Install size
2.93 MB
Created
Weekly downloads
 

Readme

Source

@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

Keywords

FAQs

Last updated on 08 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc