New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

@swagger-api/apidom-json-pointer

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swagger-api/apidom-json-pointer

Evaluate JSON Pointer expressions against ApiDOM.

Source
npmnpm
Version
1.0.0-rc.2
Version published
Weekly downloads
862K
1.4%
Maintainers
1
Weekly downloads
 
Created
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

Modern API

This is the recommended API for use in new projects. It is fully compliant with RFC 6901 and supports all aspects of JSON Pointer. Uses @swaggerexpert/json-pointer under the hood and fully reflects its API.

Evaluation is contextual to ApiDOM realm - meaning evaluate function expects only ApiDOM as the first argument.

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

Legacy API

This is a legacy API not recommended for use in new projects. It is provided for backward compatibility only. The legacy API implementation is not RFC 6901 compliant, nor does it support all features of JSON Pointer.

Importing legacy API from @swagger-api/apidom-json-pointer is equivalent to importing from @swagger-api/apidom-json-pointer/legacy.

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

or

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

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

Package last updated on 07 Nov 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