@swagger-api/apidom-json-pointer 1.0.0-rc.2 → 1.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +136 -5
  3. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-rc.4](https://github.com/swagger-api/apidom/compare/v1.0.0-rc.3...v1.0.0-rc.4) (2025-11-25)
7
+
8
+ **Note:** Version bump only for package @swagger-api/apidom-json-pointer
9
+
10
+ # [1.0.0-rc.3](https://github.com/swagger-api/apidom/compare/v1.0.0-rc.2...v1.0.0-rc.3) (2025-11-07)
11
+
12
+ **Note:** Version bump only for package @swagger-api/apidom-json-pointer
13
+
6
14
  # [1.0.0-rc.2](https://github.com/swagger-api/apidom/compare/v1.0.0-rc.1...v1.0.0-rc.2) (2025-11-07)
7
15
 
8
16
  **Note:** Version bump only for package @swagger-api/apidom-json-pointer
package/README.md CHANGED
@@ -13,7 +13,7 @@ You can install this package via [npm CLI](https://docs.npmjs.com/cli) by runnin
13
13
  ## Modern API
14
14
 
15
15
  This is the recommended API for use in new projects. It is fully compliant with [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901) and supports all aspects of JSON Pointer.
16
- Uses [@swaggerexpert/json-pointer](https://www.npmjs.com/package/@swaggerexpert/json-pointer) under the hood and fully reflects its API.
16
+ Uses [@swaggerexpert/json-pointer](https://www.npmjs.com/package/@swaggerexpert/json-pointer) under the hood and fully reflects its API. For additional options and details, refer to the `@swaggerexpert/json-pointer` [documentation](https://www.npmjs.com/package/@swaggerexpert/json-pointer#usage).
17
17
 
18
18
  Evaluation is contextual to [ApiDOM realm](https://github.com/swaggerexpert/json-pointer?tab=readme-ov-file#apidom-evaluation-realm) - meaning `evaluate` function
19
19
  expects only ApiDOM as the first argument.
@@ -22,7 +22,138 @@ expects only ApiDOM as the first argument.
22
22
  import { evaluate } from '@swagger-api/apidom-json-pointer/modern';
23
23
  ```
24
24
 
25
+ ### Evaluating
26
+
27
+ ```js
28
+ import { ObjectElement } from '@swagger-api/apidom-core';
29
+ import { evaluate } from '@swagger-api/apidom-json-pointer/modern';
30
+
31
+ const apidom = new ObjectElement({ a: { b: 'c' } });
32
+ const result = evaluate(apidom, '/a/b');
33
+ // => StringElement('c')
34
+ ```
35
+
36
+ ### Parsing
37
+
38
+ Parses JSON Pointer into a list of tokens, which can be accessed through the `tree` property of the parse result.
39
+
40
+ ```js
41
+ import { parse } from '@swagger-api/apidom-json-pointer/modern';
42
+
43
+ const parseResult = parse('/a/b');
44
+ // =>
45
+ // {
46
+ // result: {
47
+ // success: true,
48
+ // state: 101,
49
+ // stateName: 'MATCH',
50
+ // length: 4,
51
+ // matched: 4,
52
+ // maxMatched: 4,
53
+ // maxTreeDepth: 8,
54
+ // nodeHits: 31
55
+ // },
56
+ // tree: [ 'a', 'b' ],
57
+ // stats: undefined,
58
+ // trace: undefined
59
+ // }
60
+ ```
61
+
62
+ ### Compiling
63
+
64
+ Compiles a list of tokens into JSON Pointer.
65
+
66
+ ```js
67
+ import { compile } from '@swagger-api/apidom-json-pointer/modern';
68
+
69
+ const jsonPointer = compile(['a', 'b']); // => '/a/b'
70
+ ```
71
+
72
+ ### Escaping
73
+
74
+ Escapes/unescapes tokens of JSON Pointer.
75
+
76
+ ```js
77
+ import { escape, unescape } from '@swagger-api/apidom-json-pointer/modern';
25
78
 
79
+ escape('~a/'); // => '~0a~1'
80
+ unescape('~0a~1'); // => '~a/'
81
+ ```
82
+
83
+ ### Transforming URI to JSON Pointer
84
+
85
+ Handles case of [URI Fragment Identifier Representation](https://datatracker.ietf.org/doc/html/rfc6901#section-6).
86
+
87
+ ```js
88
+ import { URIFragmentIdentifier } from '@swagger-api/apidom-json-pointer/modern';
89
+
90
+ URIFragmentIdentifier.fromURIReference('https://example.com/path/#/a/b'); // => '/a/b'
91
+ ```
92
+
93
+ ### Validating
94
+
95
+ Validates a JSON Pointer and its tokens.
96
+
97
+ ```js
98
+ import {
99
+ testJSONPointer,
100
+ testReferenceToken,
101
+ testArrayLocation,
102
+ testArrayIndex,
103
+ testArrayDash,
104
+ } from '@swagger-api/apidom-json-pointer/modern';
105
+
106
+ testJSONPointer('/a/b'); // => true
107
+ testReferenceToken('a'); // => true
108
+ testArrayLocation('0'); // => true
109
+ testArrayLocation('-'); // => true
110
+ testArrayIndex('0'); // => true
111
+ testArrayDash('-'); // => true
112
+ ```
113
+
114
+ ### Invalid JSON Pointers
115
+
116
+ `JSONPointerError` is the base class for all JSON Pointer errors.
117
+
118
+ ```js
119
+ import { JSONPointerError } from '@swagger-api/apidom-json-pointer/modern';
120
+ ```
121
+
122
+ If an invalid list of tokens is supplied to `compile` function, `JSONPointerCompileError` is thrown.
123
+
124
+ ```js
125
+ import { JSONPointerCompileError } from '@swagger-api/apidom-json-pointer/modern';
126
+ ```
127
+
128
+ If an invalid JSON Pointer is supplied to `evaluate` function, `JSONPointerEvaluateError` is thrown.
129
+
130
+ ```js
131
+ import { JSONPointerEvaluateError } from '@swagger-api/apidom-json-pointer/modern';
132
+ ```
133
+
134
+ If a valid JSON Pointer is supplied to `evaluate` function and the pointer cannot be evaluated against ApiDOM fragment because it is not an object or an array, `JSONPointerTypeError` is thrown.
135
+
136
+ ```js
137
+ import { JSONPointerTypeError } from '@swagger-api/apidom-json-pointer/modern';
138
+ ```
139
+
140
+ If a valid JSON Pointer is supplied to `evaluate` function and the pointer cannot be evaluated against ApiDOM fragment because the key does not exist in the object, `JSONPointerKeyError` is thrown.
141
+
142
+ ```js
143
+ import { JSONPointerKeyError } from '@swagger-api/apidom-json-pointer/modern';
144
+ ```
145
+
146
+ If a valid JSON Pointer is supplied to `evaluate` function and the pointer cannot be evaluated against ApiDOM fragment because the index does not exist in the array, `JSONPointerIndexError` is thrown.
147
+
148
+ ```js
149
+ import { JSONPointerIndexError } from '@swagger-api/apidom-json-pointer/modern';
150
+ ```
151
+
152
+ If an error occurs in `parse` function, `JSONPointerParseError` is thrown.
153
+
154
+ ```js
155
+ import { JSONPointerParseError } from '@swagger-api/apidom-json-pointer/modern';
156
+ ```
26
157
 
27
158
  ## Legacy API
28
159
 
@@ -52,7 +183,7 @@ const result = evaluate('/a/b', apidom);
52
183
 
53
184
  ### Parsing
54
185
 
55
- Parses JSON Pointer into list of tokens.
186
+ Parses JSON Pointer into a list of tokens.
56
187
 
57
188
  ```js
58
189
  import { parse } from '@swagger-api/apidom-json-pointer';
@@ -62,7 +193,7 @@ const tokens = parse('/a/b'); // => ['a', 'b']
62
193
 
63
194
  ### Compiling
64
195
 
65
- Compiles list of tokens into JSON Pointer.
196
+ Compiles a list of tokens into JSON Pointer.
66
197
 
67
198
  ```js
68
199
  import { compile } from '@swagger-api/apidom-json-pointer';
@@ -93,14 +224,14 @@ uriToPointer('https://example.com/path/#/a/b'); // => '/a/b'
93
224
 
94
225
  ### Invalid JSON Pointers
95
226
 
96
- If invalid JSON Pointer is supplied to `parse` or `evaluate` functions, `InvalidJsonPointerError`
227
+ If an invalid JSON Pointer is supplied to `parse` or `evaluate` functions, `InvalidJsonPointerError`
97
228
  is thrown.
98
229
 
99
230
  ```js
100
231
  import { InvalidJsonPointerError } from '@swagger-api/apidom-json-pointer';
101
232
  ```
102
233
 
103
- If valid JSON Pointer is supplied to `evaluate` function and the pointer cannot be evaluated against
234
+ If a valid JSON Pointer is supplied to `evaluate` function and the pointer cannot be evaluated against
104
235
  ApiDOM fragment, `EvaluationJsonPointerError` is thrown.
105
236
 
106
237
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swagger-api/apidom-json-pointer",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.4",
4
4
  "description": "Evaluate JSON Pointer expressions against ApiDOM.",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -50,8 +50,8 @@
50
50
  "license": "Apache-2.0",
51
51
  "dependencies": {
52
52
  "@babel/runtime-corejs3": "^7.26.10",
53
- "@swagger-api/apidom-core": "^1.0.0-rc.2",
54
- "@swagger-api/apidom-error": "^1.0.0-rc.2",
53
+ "@swagger-api/apidom-core": "^1.0.0-rc.4",
54
+ "@swagger-api/apidom-error": "^1.0.0-rc.4",
55
55
  "@swaggerexpert/json-pointer": "^2.10.1"
56
56
  },
57
57
  "files": [
@@ -64,5 +64,5 @@
64
64
  "README.md",
65
65
  "CHANGELOG.md"
66
66
  ],
67
- "gitHead": "3d141c924360d491cb6dfae1a14c3dcc6ffc708d"
67
+ "gitHead": "ee774281a884eedf1445699d8f2b0092e50db432"
68
68
  }