Socket
Socket
Sign inDemoInstall

@swagger-api/apidom-json-pointer

Package Overview
Dependencies
16
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @swagger-api/apidom-json-pointer

Evaluate JSON Pointer expressions against ApiDOM.


Version published
Weekly downloads
366K
decreased by-2.83%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@swagger-api/apidom-json-pointer

apidom-json-pointer is a package that evaluates JSON Pointer against ApiDOM.

Installation

You can install this package via npm CLI by running the following command:

 $ npm install @swagger-api/apidom-json-pointer

Evaluating

import { ObjectElement } from '@swagger-api/apidom-core';
import { evaluate } from '@swagger-api/apidom-json-pointer';

const apidom = new ObjectElement({ a: { b: 'c' } });
const result =  evaluate('/a/b', apidom);
// => StringElement('c')

Parsing

Parses JSON Pointer into list of tokens.

import { parse } from '@swagger-api/apidom-json-pointer';

const tokens = parse('/a/b'); // => ['a', 'b']

Compiling

Compiles list of tokens into JSON Pointer.

import { compile } from '@swagger-api/apidom-json-pointer';

const jsonPointer = compile(['a', 'b']); // => '/a/b'

Escaping

Escapes/unescapes tokens of JSON Pointer.

import { escape, unescape } from '@swagger-api/apidom-json-pointer';

escape('~a/'); // => '~0a~1'
unescape('~0a~1'); // => '~a/'

Transforming URI to JSON Pointer

Handles case of URI Fragment Identifier Representation.

import { uriToPointer } from '@swagger-api/apidom-json-pointer';

uriToPointer('https://example.com/path/#/a/b'); // => '/a/b'

Invalid JSON Pointers

If invalid JSON Pointer is supplied to parse or evaluate functions, InvalidJsonPointerError is thrown.

import { InvalidJsonPointerError } from '@swagger-api/apidom-json-pointer';

If valid JSON Pointer is supplied to evaluate function and the pointer cannot be evaluated against ApiDOM fragment, EvaluationJsonPointerError is thrown.

import { EvaluationJsonPointerError } from '@swagger-api/apidom-json-pointer';

FAQs

Last updated on 30 Apr 2024

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