Socket
Book a DemoInstallSign in
Socket

@har-sdk/validator

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

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.

2.6.1
latest
Source
npmnpm
Version published
Weekly downloads
309
95.57%
Maintainers
2
Weekly downloads
 
Created
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

swagger

FAQs

Package last updated on 25 Mar 2025

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.