@speclynx/apidom-reference 2.13.0 → 3.0.0
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.
- package/CHANGELOG.md +16 -0
- package/README.md +5 -5
- package/dist/apidom-reference.browser.js +577 -337
- package/dist/apidom-reference.browser.min.js +1 -1
- package/package.json +25 -25
- package/src/dereference/strategies/apidom/selectors/element-id.cjs +11 -2
- package/src/dereference/strategies/apidom/selectors/element-id.mjs +12 -3
- package/src/dereference/strategies/arazzo-1/source-descriptions.cjs +2 -2
- package/src/dereference/strategies/arazzo-1/source-descriptions.mjs +3 -3
- package/src/dereference/strategies/arazzo-1/visitor.cjs +2 -2
- package/src/dereference/strategies/arazzo-1/visitor.mjs +2 -2
- package/src/dereference/strategies/asyncapi-2/visitor.cjs +6 -6
- package/src/dereference/strategies/asyncapi-2/visitor.mjs +6 -6
- package/src/dereference/strategies/openapi-2/visitor.cjs +8 -8
- package/src/dereference/strategies/openapi-2/visitor.mjs +8 -8
- package/src/dereference/strategies/openapi-3-0/visitor.cjs +6 -6
- package/src/dereference/strategies/openapi-3-0/visitor.mjs +6 -6
- package/src/dereference/strategies/openapi-3-1/util.cjs +2 -2
- package/src/dereference/strategies/openapi-3-1/util.mjs +2 -2
- package/src/dereference/strategies/openapi-3-1/visitor.cjs +8 -8
- package/src/dereference/strategies/openapi-3-1/visitor.mjs +8 -8
- package/src/parse/parsers/arazzo-json-1/source-descriptions.cjs +2 -2
- package/src/parse/parsers/arazzo-json-1/source-descriptions.mjs +3 -3
- package/src/resolve/resolvers/http-axios/cache/MemoryCache.cjs +0 -3
- package/src/resolve/resolvers/http-axios/cache/MemoryCache.mjs +0 -3
- package/types/apidom-reference.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/types/resolve/resolvers/http-axios/cache/MemoryCache.d.ts +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speclynx/apidom-reference",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Advanced algorithms for semantic ApiDOM manipulations like dereferencing or resolution.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -231,29 +231,29 @@
|
|
|
231
231
|
"license": "Apache-2.0",
|
|
232
232
|
"dependencies": {
|
|
233
233
|
"@babel/runtime-corejs3": "^7.28.4",
|
|
234
|
-
"@speclynx/apidom-core": "
|
|
235
|
-
"@speclynx/apidom-datamodel": "
|
|
236
|
-
"@speclynx/apidom-error": "
|
|
237
|
-
"@speclynx/apidom-json-pointer": "
|
|
238
|
-
"@speclynx/apidom-ns-arazzo-1": "
|
|
239
|
-
"@speclynx/apidom-ns-asyncapi-2": "
|
|
240
|
-
"@speclynx/apidom-ns-json-schema-2020-12": "
|
|
241
|
-
"@speclynx/apidom-ns-openapi-2": "
|
|
242
|
-
"@speclynx/apidom-ns-openapi-3-0": "
|
|
243
|
-
"@speclynx/apidom-ns-openapi-3-1": "
|
|
244
|
-
"@speclynx/apidom-parser-adapter-arazzo-json-1": "
|
|
245
|
-
"@speclynx/apidom-parser-adapter-arazzo-yaml-1": "
|
|
246
|
-
"@speclynx/apidom-parser-adapter-asyncapi-json-2": "
|
|
247
|
-
"@speclynx/apidom-parser-adapter-asyncapi-yaml-2": "
|
|
248
|
-
"@speclynx/apidom-parser-adapter-json": "
|
|
249
|
-
"@speclynx/apidom-parser-adapter-openapi-json-2": "
|
|
250
|
-
"@speclynx/apidom-parser-adapter-openapi-json-3-0": "
|
|
251
|
-
"@speclynx/apidom-parser-adapter-openapi-json-3-1": "
|
|
252
|
-
"@speclynx/apidom-parser-adapter-openapi-yaml-2": "
|
|
253
|
-
"@speclynx/apidom-parser-adapter-openapi-yaml-3-0": "
|
|
254
|
-
"@speclynx/apidom-parser-adapter-openapi-yaml-3-1": "
|
|
255
|
-
"@speclynx/apidom-parser-adapter-yaml-1-2": "
|
|
256
|
-
"@speclynx/apidom-traverse": "
|
|
234
|
+
"@speclynx/apidom-core": "3.0.0",
|
|
235
|
+
"@speclynx/apidom-datamodel": "3.0.0",
|
|
236
|
+
"@speclynx/apidom-error": "3.0.0",
|
|
237
|
+
"@speclynx/apidom-json-pointer": "3.0.0",
|
|
238
|
+
"@speclynx/apidom-ns-arazzo-1": "3.0.0",
|
|
239
|
+
"@speclynx/apidom-ns-asyncapi-2": "3.0.0",
|
|
240
|
+
"@speclynx/apidom-ns-json-schema-2020-12": "3.0.0",
|
|
241
|
+
"@speclynx/apidom-ns-openapi-2": "3.0.0",
|
|
242
|
+
"@speclynx/apidom-ns-openapi-3-0": "3.0.0",
|
|
243
|
+
"@speclynx/apidom-ns-openapi-3-1": "3.0.0",
|
|
244
|
+
"@speclynx/apidom-parser-adapter-arazzo-json-1": "3.0.0",
|
|
245
|
+
"@speclynx/apidom-parser-adapter-arazzo-yaml-1": "3.0.0",
|
|
246
|
+
"@speclynx/apidom-parser-adapter-asyncapi-json-2": "3.0.0",
|
|
247
|
+
"@speclynx/apidom-parser-adapter-asyncapi-yaml-2": "3.0.0",
|
|
248
|
+
"@speclynx/apidom-parser-adapter-json": "3.0.0",
|
|
249
|
+
"@speclynx/apidom-parser-adapter-openapi-json-2": "3.0.0",
|
|
250
|
+
"@speclynx/apidom-parser-adapter-openapi-json-3-0": "3.0.0",
|
|
251
|
+
"@speclynx/apidom-parser-adapter-openapi-json-3-1": "3.0.0",
|
|
252
|
+
"@speclynx/apidom-parser-adapter-openapi-yaml-2": "3.0.0",
|
|
253
|
+
"@speclynx/apidom-parser-adapter-openapi-yaml-3-0": "3.0.0",
|
|
254
|
+
"@speclynx/apidom-parser-adapter-openapi-yaml-3-1": "3.0.0",
|
|
255
|
+
"@speclynx/apidom-parser-adapter-yaml-1-2": "3.0.0",
|
|
256
|
+
"@speclynx/apidom-traverse": "3.0.0",
|
|
257
257
|
"@swaggerexpert/arazzo-runtime-expression": "^2.0.3",
|
|
258
258
|
"axios": "^1.13.5",
|
|
259
259
|
"picomatch": "^4.0.3",
|
|
@@ -275,5 +275,5 @@
|
|
|
275
275
|
"README.md",
|
|
276
276
|
"CHANGELOG.md"
|
|
277
277
|
],
|
|
278
|
-
"gitHead": "
|
|
278
|
+
"gitHead": "cb94ec84ea789d121801065876e7a91799a363d0"
|
|
279
279
|
}
|
|
@@ -9,7 +9,16 @@ var _apidomCore = require("@speclynx/apidom-core");
|
|
|
9
9
|
var _apidomTraverse = require("@speclynx/apidom-traverse");
|
|
10
10
|
var _EvaluationElementIdError = _interopRequireDefault(require("../../../../errors/EvaluationElementIdError.cjs"));
|
|
11
11
|
exports.EvaluationElementIdError = _EvaluationElementIdError.default;
|
|
12
|
-
const
|
|
12
|
+
const getElementID = element => {
|
|
13
|
+
const id = element.meta.get('id');
|
|
14
|
+
// handle both raw string (new format) and StringElement (legacy Refract without __meta_raw__)
|
|
15
|
+
return (0, _apidomDatamodel.isElement)(id) ? (0, _apidomCore.toValue)(id) : id;
|
|
16
|
+
};
|
|
17
|
+
const hasElementID = element => {
|
|
18
|
+
if (!element.hasMetaProperty('id')) return false;
|
|
19
|
+
const id = getElementID(element);
|
|
20
|
+
return typeof id === 'string' && id !== '';
|
|
21
|
+
};
|
|
13
22
|
|
|
14
23
|
/**
|
|
15
24
|
* Evaluates element ID against ApiDOM fragment.
|
|
@@ -27,7 +36,7 @@ const evaluate = (elementID, element) => {
|
|
|
27
36
|
|
|
28
37
|
// search for the matching element
|
|
29
38
|
const result = cache.get(element).find(e => {
|
|
30
|
-
return
|
|
39
|
+
return getElementID(e) === elementID;
|
|
31
40
|
});
|
|
32
41
|
if ((0, _ramdaAdjunct.isUndefined)(result)) {
|
|
33
42
|
throw new _EvaluationElementIdError.default(`Evaluation failed on element ID: "${elementID}"`);
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { isUndefined } from 'ramda-adjunct';
|
|
2
|
-
import {
|
|
2
|
+
import { isElement } from '@speclynx/apidom-datamodel';
|
|
3
3
|
import { toValue } from '@speclynx/apidom-core';
|
|
4
4
|
import { filter } from '@speclynx/apidom-traverse';
|
|
5
5
|
import EvaluationElementIdError from "../../../../errors/EvaluationElementIdError.mjs";
|
|
6
|
-
const
|
|
6
|
+
const getElementID = element => {
|
|
7
|
+
const id = element.meta.get('id');
|
|
8
|
+
// handle both raw string (new format) and StringElement (legacy Refract without __meta_raw__)
|
|
9
|
+
return isElement(id) ? toValue(id) : id;
|
|
10
|
+
};
|
|
11
|
+
const hasElementID = element => {
|
|
12
|
+
if (!element.hasMetaProperty('id')) return false;
|
|
13
|
+
const id = getElementID(element);
|
|
14
|
+
return typeof id === 'string' && id !== '';
|
|
15
|
+
};
|
|
7
16
|
|
|
8
17
|
/**
|
|
9
18
|
* Evaluates element ID against ApiDOM fragment.
|
|
@@ -21,7 +30,7 @@ export const evaluate = (elementID, element) => {
|
|
|
21
30
|
|
|
22
31
|
// search for the matching element
|
|
23
32
|
const result = cache.get(element).find(e => {
|
|
24
|
-
return
|
|
33
|
+
return getElementID(e) === elementID;
|
|
25
34
|
});
|
|
26
35
|
if (isUndefined(result)) {
|
|
27
36
|
throw new EvaluationElementIdError(`Evaluation failed on element ID: "${elementID}"`);
|
|
@@ -27,8 +27,8 @@ async function dereferenceSourceDescription(sourceDescription, ctx) {
|
|
|
27
27
|
|
|
28
28
|
// set class and metadata from source description element
|
|
29
29
|
parseResult.classes.push('source-description');
|
|
30
|
-
if ((0, _apidomDatamodel.isStringElement)(sourceDescription.name)) parseResult.setMetaProperty('name', (0,
|
|
31
|
-
if ((0, _apidomDatamodel.isStringElement)(sourceDescription.type)) parseResult.setMetaProperty('type', (0,
|
|
30
|
+
if ((0, _apidomDatamodel.isStringElement)(sourceDescription.name)) parseResult.setMetaProperty('name', (0, _apidomCore.toValue)(sourceDescription.name));
|
|
31
|
+
if ((0, _apidomDatamodel.isStringElement)(sourceDescription.type)) parseResult.setMetaProperty('type', (0, _apidomCore.toValue)(sourceDescription.type));
|
|
32
32
|
const sourceDescriptionURI = (0, _apidomCore.toValue)(sourceDescription.url);
|
|
33
33
|
if (typeof sourceDescriptionURI !== 'string') {
|
|
34
34
|
const annotation = new _apidomDatamodel.AnnotationElement('Source description URL is missing or not a string. Skipping');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParseResultElement, AnnotationElement, isArrayElement, isStringElement, isParseResultElement
|
|
1
|
+
import { ParseResultElement, AnnotationElement, isArrayElement, isStringElement, isParseResultElement } from '@speclynx/apidom-datamodel';
|
|
2
2
|
import { isArazzoSpecification1Element, isSourceDescriptionElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
3
3
|
import { isSwaggerElement } from '@speclynx/apidom-ns-openapi-2';
|
|
4
4
|
import { isOpenApi3_0Element } from '@speclynx/apidom-ns-openapi-3-0';
|
|
@@ -22,8 +22,8 @@ async function dereferenceSourceDescription(sourceDescription, ctx) {
|
|
|
22
22
|
|
|
23
23
|
// set class and metadata from source description element
|
|
24
24
|
parseResult.classes.push('source-description');
|
|
25
|
-
if (isStringElement(sourceDescription.name)) parseResult.setMetaProperty('name',
|
|
26
|
-
if (isStringElement(sourceDescription.type)) parseResult.setMetaProperty('type',
|
|
25
|
+
if (isStringElement(sourceDescription.name)) parseResult.setMetaProperty('name', toValue(sourceDescription.name));
|
|
26
|
+
if (isStringElement(sourceDescription.type)) parseResult.setMetaProperty('type', toValue(sourceDescription.type));
|
|
27
27
|
const sourceDescriptionURI = toValue(sourceDescription.url);
|
|
28
28
|
if (typeof sourceDescriptionURI !== 'string') {
|
|
29
29
|
const annotation = new AnnotationElement('Source description URL is missing or not a string. Skipping');
|
|
@@ -374,7 +374,7 @@ class Arazzo1DereferenceVisitor {
|
|
|
374
374
|
// annotate referenced element with info about origin
|
|
375
375
|
booleanJsonSchemaElement.meta.set('ref-origin', reference.uri);
|
|
376
376
|
// annotate fragment with info about referencing element
|
|
377
|
-
booleanJsonSchemaElement.meta.set('ref-referencing-element-id',
|
|
377
|
+
booleanJsonSchemaElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
378
378
|
path.replaceWith(booleanJsonSchemaElement);
|
|
379
379
|
return;
|
|
380
380
|
}
|
|
@@ -399,7 +399,7 @@ class Arazzo1DereferenceVisitor {
|
|
|
399
399
|
// annotate fragment with info about origin
|
|
400
400
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
401
401
|
// annotate fragment with info about referencing element
|
|
402
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
402
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
403
403
|
referencedElement = mergedElement;
|
|
404
404
|
}
|
|
405
405
|
/**
|
|
@@ -368,7 +368,7 @@ class Arazzo1DereferenceVisitor {
|
|
|
368
368
|
// annotate referenced element with info about origin
|
|
369
369
|
booleanJsonSchemaElement.meta.set('ref-origin', reference.uri);
|
|
370
370
|
// annotate fragment with info about referencing element
|
|
371
|
-
booleanJsonSchemaElement.meta.set('ref-referencing-element-id',
|
|
371
|
+
booleanJsonSchemaElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
372
372
|
path.replaceWith(booleanJsonSchemaElement);
|
|
373
373
|
return;
|
|
374
374
|
}
|
|
@@ -393,7 +393,7 @@ class Arazzo1DereferenceVisitor {
|
|
|
393
393
|
// annotate fragment with info about origin
|
|
394
394
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
395
395
|
// annotate fragment with info about referencing element
|
|
396
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
396
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
397
397
|
referencedElement = mergedElement;
|
|
398
398
|
}
|
|
399
399
|
/**
|
|
@@ -140,8 +140,8 @@ class AsyncAPI2DereferenceVisitor {
|
|
|
140
140
|
* Applying semantics to a referenced element if semantics are missing.
|
|
141
141
|
*/
|
|
142
142
|
if ((0, _apidomDatamodel.isPrimitiveElement)(referencedElement)) {
|
|
143
|
-
const referencedElementType =
|
|
144
|
-
const cacheKey = `${referencedElementType}-${
|
|
143
|
+
const referencedElementType = referencingElement.meta.get('referenced-element');
|
|
144
|
+
const cacheKey = `${referencedElementType}-${identityManager.identify(referencedElement)}`;
|
|
145
145
|
if (this.refractCache.has(cacheKey)) {
|
|
146
146
|
referencedElement = this.refractCache.get(cacheKey);
|
|
147
147
|
} else if ((0, _apidomNsAsyncapi.isReferenceLikeElement)(referencedElement)) {
|
|
@@ -230,7 +230,7 @@ class AsyncAPI2DereferenceVisitor {
|
|
|
230
230
|
// annotate referenced element with info about origin
|
|
231
231
|
booleanJsonSchemaElement.meta.set('ref-origin', reference.uri);
|
|
232
232
|
// annotate fragment with info about referencing element
|
|
233
|
-
booleanJsonSchemaElement.meta.set('ref-referencing-element-id',
|
|
233
|
+
booleanJsonSchemaElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
234
234
|
path.replaceWith(booleanJsonSchemaElement);
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
@@ -248,7 +248,7 @@ class AsyncAPI2DereferenceVisitor {
|
|
|
248
248
|
// annotate fragment with info about origin
|
|
249
249
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
250
250
|
// annotate fragment with info about referencing element
|
|
251
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
251
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
254
|
* Transclude referencing element with merged referenced element.
|
|
@@ -296,7 +296,7 @@ class AsyncAPI2DereferenceVisitor {
|
|
|
296
296
|
* Applying semantics to a referenced element if semantics are missing.
|
|
297
297
|
*/
|
|
298
298
|
if ((0, _apidomDatamodel.isPrimitiveElement)(referencedElement)) {
|
|
299
|
-
const cacheKey = `channel-item-${
|
|
299
|
+
const cacheKey = `channel-item-${identityManager.identify(referencedElement)}`;
|
|
300
300
|
if (this.refractCache.has(cacheKey)) {
|
|
301
301
|
referencedElement = this.refractCache.get(cacheKey);
|
|
302
302
|
} else {
|
|
@@ -386,7 +386,7 @@ class AsyncAPI2DereferenceVisitor {
|
|
|
386
386
|
// annotate referenced with info about origin
|
|
387
387
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
388
388
|
// annotate fragment with info about referencing element
|
|
389
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
389
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
390
390
|
referencedElement = mergedElement;
|
|
391
391
|
}
|
|
392
392
|
|
|
@@ -134,8 +134,8 @@ class AsyncAPI2DereferenceVisitor {
|
|
|
134
134
|
* Applying semantics to a referenced element if semantics are missing.
|
|
135
135
|
*/
|
|
136
136
|
if (isPrimitiveElement(referencedElement)) {
|
|
137
|
-
const referencedElementType =
|
|
138
|
-
const cacheKey = `${referencedElementType}-${
|
|
137
|
+
const referencedElementType = referencingElement.meta.get('referenced-element');
|
|
138
|
+
const cacheKey = `${referencedElementType}-${identityManager.identify(referencedElement)}`;
|
|
139
139
|
if (this.refractCache.has(cacheKey)) {
|
|
140
140
|
referencedElement = this.refractCache.get(cacheKey);
|
|
141
141
|
} else if (isReferenceLikeElement(referencedElement)) {
|
|
@@ -224,7 +224,7 @@ class AsyncAPI2DereferenceVisitor {
|
|
|
224
224
|
// annotate referenced element with info about origin
|
|
225
225
|
booleanJsonSchemaElement.meta.set('ref-origin', reference.uri);
|
|
226
226
|
// annotate fragment with info about referencing element
|
|
227
|
-
booleanJsonSchemaElement.meta.set('ref-referencing-element-id',
|
|
227
|
+
booleanJsonSchemaElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
228
228
|
path.replaceWith(booleanJsonSchemaElement);
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
@@ -242,7 +242,7 @@ class AsyncAPI2DereferenceVisitor {
|
|
|
242
242
|
// annotate fragment with info about origin
|
|
243
243
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
244
244
|
// annotate fragment with info about referencing element
|
|
245
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
245
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
246
246
|
|
|
247
247
|
/**
|
|
248
248
|
* Transclude referencing element with merged referenced element.
|
|
@@ -290,7 +290,7 @@ class AsyncAPI2DereferenceVisitor {
|
|
|
290
290
|
* Applying semantics to a referenced element if semantics are missing.
|
|
291
291
|
*/
|
|
292
292
|
if (isPrimitiveElement(referencedElement)) {
|
|
293
|
-
const cacheKey = `channel-item-${
|
|
293
|
+
const cacheKey = `channel-item-${identityManager.identify(referencedElement)}`;
|
|
294
294
|
if (this.refractCache.has(cacheKey)) {
|
|
295
295
|
referencedElement = this.refractCache.get(cacheKey);
|
|
296
296
|
} else {
|
|
@@ -380,7 +380,7 @@ class AsyncAPI2DereferenceVisitor {
|
|
|
380
380
|
// annotate referenced with info about origin
|
|
381
381
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
382
382
|
// annotate fragment with info about referencing element
|
|
383
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
383
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
384
384
|
referencedElement = mergedElement;
|
|
385
385
|
}
|
|
386
386
|
|
|
@@ -140,8 +140,8 @@ class OpenAPI2DereferenceVisitor {
|
|
|
140
140
|
* Applying semantics to a referenced element if semantics are missing.
|
|
141
141
|
*/
|
|
142
142
|
if ((0, _apidomDatamodel.isPrimitiveElement)(referencedElement)) {
|
|
143
|
-
const referencedElementType =
|
|
144
|
-
const cacheKey = `${referencedElementType}-${
|
|
143
|
+
const referencedElementType = referencingElement.meta.get('referenced-element');
|
|
144
|
+
const cacheKey = `${referencedElementType}-${identityManager.identify(referencedElement)}`;
|
|
145
145
|
if (this.refractCache.has(cacheKey)) {
|
|
146
146
|
referencedElement = this.refractCache.get(cacheKey);
|
|
147
147
|
} else if ((0, _apidomNsOpenapi.isReferenceLikeElement)(referencedElement)) {
|
|
@@ -232,7 +232,7 @@ class OpenAPI2DereferenceVisitor {
|
|
|
232
232
|
// annotate fragment with info about origin
|
|
233
233
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
234
234
|
// annotate fragment with info about referencing element
|
|
235
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
235
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
236
236
|
|
|
237
237
|
/**
|
|
238
238
|
* Transclude referencing element with merged referenced element.
|
|
@@ -281,7 +281,7 @@ class OpenAPI2DereferenceVisitor {
|
|
|
281
281
|
* Applying semantics to a referenced element if semantics are missing.
|
|
282
282
|
*/
|
|
283
283
|
if ((0, _apidomDatamodel.isPrimitiveElement)(referencedElement)) {
|
|
284
|
-
const cacheKey = `pathItem-${
|
|
284
|
+
const cacheKey = `pathItem-${identityManager.identify(referencedElement)}`;
|
|
285
285
|
if (this.refractCache.has(cacheKey)) {
|
|
286
286
|
referencedElement = this.refractCache.get(cacheKey);
|
|
287
287
|
} else {
|
|
@@ -369,7 +369,7 @@ class OpenAPI2DereferenceVisitor {
|
|
|
369
369
|
// annotate referenced element with info about origin
|
|
370
370
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
371
371
|
// annotate fragment with info about referencing element
|
|
372
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
372
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
373
373
|
referencedElement = mergedElement;
|
|
374
374
|
}
|
|
375
375
|
|
|
@@ -417,8 +417,8 @@ class OpenAPI2DereferenceVisitor {
|
|
|
417
417
|
* Applying semantics to a referenced element if semantics are missing.
|
|
418
418
|
*/
|
|
419
419
|
if ((0, _apidomDatamodel.isPrimitiveElement)(referencedElement)) {
|
|
420
|
-
const referencedElementType =
|
|
421
|
-
const cacheKey = `path-item-${
|
|
420
|
+
const referencedElementType = referencingElement.meta.get('referenced-element');
|
|
421
|
+
const cacheKey = `path-item-${identityManager.identify(referencedElement)}`;
|
|
422
422
|
if (this.refractCache.has(cacheKey)) {
|
|
423
423
|
referencedElement = this.refractCache.get(cacheKey);
|
|
424
424
|
} else if ((0, _apidomNsOpenapi.isJSONReferenceLikeElement)(referencedElement)) {
|
|
@@ -509,7 +509,7 @@ class OpenAPI2DereferenceVisitor {
|
|
|
509
509
|
// annotate fragment with info about origin
|
|
510
510
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
511
511
|
// annotate fragment with info about referencing element
|
|
512
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
512
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
513
513
|
|
|
514
514
|
/**
|
|
515
515
|
* Transclude referencing element with merged referenced element.
|
|
@@ -134,8 +134,8 @@ class OpenAPI2DereferenceVisitor {
|
|
|
134
134
|
* Applying semantics to a referenced element if semantics are missing.
|
|
135
135
|
*/
|
|
136
136
|
if (isPrimitiveElement(referencedElement)) {
|
|
137
|
-
const referencedElementType =
|
|
138
|
-
const cacheKey = `${referencedElementType}-${
|
|
137
|
+
const referencedElementType = referencingElement.meta.get('referenced-element');
|
|
138
|
+
const cacheKey = `${referencedElementType}-${identityManager.identify(referencedElement)}`;
|
|
139
139
|
if (this.refractCache.has(cacheKey)) {
|
|
140
140
|
referencedElement = this.refractCache.get(cacheKey);
|
|
141
141
|
} else if (isReferenceLikeElement(referencedElement)) {
|
|
@@ -226,7 +226,7 @@ class OpenAPI2DereferenceVisitor {
|
|
|
226
226
|
// annotate fragment with info about origin
|
|
227
227
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
228
228
|
// annotate fragment with info about referencing element
|
|
229
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
229
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
232
|
* Transclude referencing element with merged referenced element.
|
|
@@ -275,7 +275,7 @@ class OpenAPI2DereferenceVisitor {
|
|
|
275
275
|
* Applying semantics to a referenced element if semantics are missing.
|
|
276
276
|
*/
|
|
277
277
|
if (isPrimitiveElement(referencedElement)) {
|
|
278
|
-
const cacheKey = `pathItem-${
|
|
278
|
+
const cacheKey = `pathItem-${identityManager.identify(referencedElement)}`;
|
|
279
279
|
if (this.refractCache.has(cacheKey)) {
|
|
280
280
|
referencedElement = this.refractCache.get(cacheKey);
|
|
281
281
|
} else {
|
|
@@ -363,7 +363,7 @@ class OpenAPI2DereferenceVisitor {
|
|
|
363
363
|
// annotate referenced element with info about origin
|
|
364
364
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
365
365
|
// annotate fragment with info about referencing element
|
|
366
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
366
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
367
367
|
referencedElement = mergedElement;
|
|
368
368
|
}
|
|
369
369
|
|
|
@@ -411,8 +411,8 @@ class OpenAPI2DereferenceVisitor {
|
|
|
411
411
|
* Applying semantics to a referenced element if semantics are missing.
|
|
412
412
|
*/
|
|
413
413
|
if (isPrimitiveElement(referencedElement)) {
|
|
414
|
-
const referencedElementType =
|
|
415
|
-
const cacheKey = `path-item-${
|
|
414
|
+
const referencedElementType = referencingElement.meta.get('referenced-element');
|
|
415
|
+
const cacheKey = `path-item-${identityManager.identify(referencedElement)}`;
|
|
416
416
|
if (this.refractCache.has(cacheKey)) {
|
|
417
417
|
referencedElement = this.refractCache.get(cacheKey);
|
|
418
418
|
} else if (isJSONReferenceLikeElement(referencedElement)) {
|
|
@@ -503,7 +503,7 @@ class OpenAPI2DereferenceVisitor {
|
|
|
503
503
|
// annotate fragment with info about origin
|
|
504
504
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
505
505
|
// annotate fragment with info about referencing element
|
|
506
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
506
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
507
507
|
|
|
508
508
|
/**
|
|
509
509
|
* Transclude referencing element with merged referenced element.
|
|
@@ -141,8 +141,8 @@ class OpenAPI3_0DereferenceVisitor {
|
|
|
141
141
|
* Applying semantics to a referenced element if semantics are missing.
|
|
142
142
|
*/
|
|
143
143
|
if ((0, _apidomDatamodel.isPrimitiveElement)(referencedElement)) {
|
|
144
|
-
const referencedElementType =
|
|
145
|
-
const cacheKey = `${referencedElementType}-${
|
|
144
|
+
const referencedElementType = referencingElement.meta.get('referenced-element');
|
|
145
|
+
const cacheKey = `${referencedElementType}-${identityManager.identify(referencedElement)}`;
|
|
146
146
|
if (this.refractCache.has(cacheKey)) {
|
|
147
147
|
referencedElement = this.refractCache.get(cacheKey);
|
|
148
148
|
} else if ((0, _apidomNsOpenapi.isReferenceLikeElement)(referencedElement)) {
|
|
@@ -232,7 +232,7 @@ class OpenAPI3_0DereferenceVisitor {
|
|
|
232
232
|
// annotate fragment with info about origin
|
|
233
233
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
234
234
|
// annotate fragment with info about referencing element
|
|
235
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
235
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
236
236
|
|
|
237
237
|
/**
|
|
238
238
|
* Transclude referencing element with merged referenced element.
|
|
@@ -280,7 +280,7 @@ class OpenAPI3_0DereferenceVisitor {
|
|
|
280
280
|
* Applying semantics to a referenced element if semantics are missing.
|
|
281
281
|
*/
|
|
282
282
|
if (!(0, _apidomNsOpenapi.isPathItemElement)(referencedElement)) {
|
|
283
|
-
const cacheKey = `path-item-${
|
|
283
|
+
const cacheKey = `path-item-${identityManager.identify(referencedElement)}`;
|
|
284
284
|
if (this.refractCache.has(cacheKey)) {
|
|
285
285
|
referencedElement = this.refractCache.get(cacheKey);
|
|
286
286
|
} else {
|
|
@@ -370,7 +370,7 @@ class OpenAPI3_0DereferenceVisitor {
|
|
|
370
370
|
// annotate referenced element with info about origin
|
|
371
371
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
372
372
|
// annotate fragment with info about referencing element
|
|
373
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
373
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
374
374
|
referencedElement = mergedElement;
|
|
375
375
|
}
|
|
376
376
|
|
|
@@ -413,7 +413,7 @@ class OpenAPI3_0DereferenceVisitor {
|
|
|
413
413
|
operationElement = (0, _apidomJsonPointer.evaluate)(reference.value.result, jsonPointer);
|
|
414
414
|
// applying semantics to a referenced element
|
|
415
415
|
if ((0, _apidomDatamodel.isPrimitiveElement)(operationElement)) {
|
|
416
|
-
const cacheKey = `operation-${
|
|
416
|
+
const cacheKey = `operation-${identityManager.identify(operationElement)}`;
|
|
417
417
|
if (this.refractCache.has(cacheKey)) {
|
|
418
418
|
operationElement = this.refractCache.get(cacheKey);
|
|
419
419
|
} else {
|
|
@@ -135,8 +135,8 @@ class OpenAPI3_0DereferenceVisitor {
|
|
|
135
135
|
* Applying semantics to a referenced element if semantics are missing.
|
|
136
136
|
*/
|
|
137
137
|
if (isPrimitiveElement(referencedElement)) {
|
|
138
|
-
const referencedElementType =
|
|
139
|
-
const cacheKey = `${referencedElementType}-${
|
|
138
|
+
const referencedElementType = referencingElement.meta.get('referenced-element');
|
|
139
|
+
const cacheKey = `${referencedElementType}-${identityManager.identify(referencedElement)}`;
|
|
140
140
|
if (this.refractCache.has(cacheKey)) {
|
|
141
141
|
referencedElement = this.refractCache.get(cacheKey);
|
|
142
142
|
} else if (isReferenceLikeElement(referencedElement)) {
|
|
@@ -226,7 +226,7 @@ class OpenAPI3_0DereferenceVisitor {
|
|
|
226
226
|
// annotate fragment with info about origin
|
|
227
227
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
228
228
|
// annotate fragment with info about referencing element
|
|
229
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
229
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
232
|
* Transclude referencing element with merged referenced element.
|
|
@@ -274,7 +274,7 @@ class OpenAPI3_0DereferenceVisitor {
|
|
|
274
274
|
* Applying semantics to a referenced element if semantics are missing.
|
|
275
275
|
*/
|
|
276
276
|
if (!isPathItemElement(referencedElement)) {
|
|
277
|
-
const cacheKey = `path-item-${
|
|
277
|
+
const cacheKey = `path-item-${identityManager.identify(referencedElement)}`;
|
|
278
278
|
if (this.refractCache.has(cacheKey)) {
|
|
279
279
|
referencedElement = this.refractCache.get(cacheKey);
|
|
280
280
|
} else {
|
|
@@ -364,7 +364,7 @@ class OpenAPI3_0DereferenceVisitor {
|
|
|
364
364
|
// annotate referenced element with info about origin
|
|
365
365
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
366
366
|
// annotate fragment with info about referencing element
|
|
367
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
367
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
368
368
|
referencedElement = mergedElement;
|
|
369
369
|
}
|
|
370
370
|
|
|
@@ -407,7 +407,7 @@ class OpenAPI3_0DereferenceVisitor {
|
|
|
407
407
|
operationElement = evaluate(reference.value.result, jsonPointer);
|
|
408
408
|
// applying semantics to a referenced element
|
|
409
409
|
if (isPrimitiveElement(operationElement)) {
|
|
410
|
-
const cacheKey = `operation-${
|
|
410
|
+
const cacheKey = `operation-${identityManager.identify(operationElement)}`;
|
|
411
411
|
if (this.refractCache.has(cacheKey)) {
|
|
412
412
|
operationElement = this.refractCache.get(cacheKey);
|
|
413
413
|
} else {
|
|
@@ -16,7 +16,7 @@ const resolveSchema$refField = (retrievalURI, schemaElement) => {
|
|
|
16
16
|
return undefined;
|
|
17
17
|
}
|
|
18
18
|
const hash = url.getHash((0, _apidomCore.toValue)(schemaElement.$ref));
|
|
19
|
-
const ancestorsSchemaIdentifiers =
|
|
19
|
+
const ancestorsSchemaIdentifiers = schemaElement.meta.get('ancestorsSchemaIdentifiers');
|
|
20
20
|
const $refBaseURI = (0, _ramda.reduce)((acc, uri) => {
|
|
21
21
|
return url.resolve(acc, url.sanitize(url.stripHash(uri)));
|
|
22
22
|
}, retrievalURI, [...ancestorsSchemaIdentifiers, (0, _apidomCore.toValue)(schemaElement.$ref)]);
|
|
@@ -31,7 +31,7 @@ const resolveSchema$idField = (retrievalURI, schemaElement) => {
|
|
|
31
31
|
if (typeof schemaElement.$id === 'undefined') {
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
|
34
|
-
const ancestorsSchemaIdentifiers =
|
|
34
|
+
const ancestorsSchemaIdentifiers = schemaElement.meta.get('ancestorsSchemaIdentifiers');
|
|
35
35
|
return (0, _ramda.reduce)((acc, $id) => {
|
|
36
36
|
return url.resolve(acc, url.sanitize(url.stripHash($id)));
|
|
37
37
|
}, retrievalURI, ancestorsSchemaIdentifiers);
|
|
@@ -11,7 +11,7 @@ export const resolveSchema$refField = (retrievalURI, schemaElement) => {
|
|
|
11
11
|
return undefined;
|
|
12
12
|
}
|
|
13
13
|
const hash = url.getHash(toValue(schemaElement.$ref));
|
|
14
|
-
const ancestorsSchemaIdentifiers =
|
|
14
|
+
const ancestorsSchemaIdentifiers = schemaElement.meta.get('ancestorsSchemaIdentifiers');
|
|
15
15
|
const $refBaseURI = reduce((acc, uri) => {
|
|
16
16
|
return url.resolve(acc, url.sanitize(url.stripHash(uri)));
|
|
17
17
|
}, retrievalURI, [...ancestorsSchemaIdentifiers, toValue(schemaElement.$ref)]);
|
|
@@ -25,7 +25,7 @@ export const resolveSchema$idField = (retrievalURI, schemaElement) => {
|
|
|
25
25
|
if (typeof schemaElement.$id === 'undefined') {
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
28
|
-
const ancestorsSchemaIdentifiers =
|
|
28
|
+
const ancestorsSchemaIdentifiers = schemaElement.meta.get('ancestorsSchemaIdentifiers');
|
|
29
29
|
return reduce((acc, $id) => {
|
|
30
30
|
return url.resolve(acc, url.sanitize(url.stripHash($id)));
|
|
31
31
|
}, retrievalURI, ancestorsSchemaIdentifiers);
|
|
@@ -144,8 +144,8 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
144
144
|
|
|
145
145
|
// applying semantics to a fragment
|
|
146
146
|
if ((0, _apidomDatamodel.isPrimitiveElement)(referencedElement)) {
|
|
147
|
-
const referencedElementType =
|
|
148
|
-
const cacheKey = `${referencedElementType}-${
|
|
147
|
+
const referencedElementType = referencingElement.meta.get('referenced-element');
|
|
148
|
+
const cacheKey = `${referencedElementType}-${identityManager.identify(referencedElement)}`;
|
|
149
149
|
if (this.refractCache.has(cacheKey)) {
|
|
150
150
|
referencedElement = this.refractCache.get(cacheKey);
|
|
151
151
|
} else if ((0, _apidomNsOpenapi.isReferenceLikeElement)(referencedElement)) {
|
|
@@ -239,7 +239,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
239
239
|
// annotate fragment with info about origin
|
|
240
240
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
241
241
|
// annotate fragment with info about referencing element
|
|
242
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
242
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
243
243
|
|
|
244
244
|
// override description and summary (outer has higher priority then inner)
|
|
245
245
|
if ((0, _apidomDatamodel.isObjectElement)(referencedElement) && (0, _apidomDatamodel.isObjectElement)(mergedElement)) {
|
|
@@ -302,7 +302,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
302
302
|
* Applying semantics to a referenced element if semantics are missing.
|
|
303
303
|
*/
|
|
304
304
|
if ((0, _apidomDatamodel.isPrimitiveElement)(referencedElement)) {
|
|
305
|
-
const cacheKey = `path-item-${
|
|
305
|
+
const cacheKey = `path-item-${identityManager.identify(referencedElement)}`;
|
|
306
306
|
if (this.refractCache.has(cacheKey)) {
|
|
307
307
|
referencedElement = this.refractCache.get(cacheKey);
|
|
308
308
|
} else {
|
|
@@ -392,7 +392,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
392
392
|
// annotate referenced element with info about origin
|
|
393
393
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
394
394
|
// annotate fragment with info about referencing element
|
|
395
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
395
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
396
396
|
referencedElement = mergedElement;
|
|
397
397
|
}
|
|
398
398
|
|
|
@@ -435,7 +435,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
435
435
|
operationElement = (0, _apidomJsonPointer.evaluate)(reference.value.result, jsonPointer);
|
|
436
436
|
// applying semantics to a referenced element
|
|
437
437
|
if ((0, _apidomDatamodel.isPrimitiveElement)(operationElement)) {
|
|
438
|
-
const cacheKey = `operation-${
|
|
438
|
+
const cacheKey = `operation-${identityManager.identify(operationElement)}`;
|
|
439
439
|
if (this.refractCache.has(cacheKey)) {
|
|
440
440
|
operationElement = this.refractCache.get(cacheKey);
|
|
441
441
|
} else {
|
|
@@ -716,7 +716,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
716
716
|
// annotate referenced element with info about origin
|
|
717
717
|
booleanJsonSchemaElement.meta.set('ref-origin', reference.uri);
|
|
718
718
|
// annotate fragment with info about referencing element
|
|
719
|
-
booleanJsonSchemaElement.meta.set('ref-referencing-element-id',
|
|
719
|
+
booleanJsonSchemaElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
720
720
|
path.replaceWith(booleanJsonSchemaElement);
|
|
721
721
|
return;
|
|
722
722
|
}
|
|
@@ -741,7 +741,7 @@ class OpenAPI3_1DereferenceVisitor {
|
|
|
741
741
|
// annotate fragment with info about origin
|
|
742
742
|
mergedElement.meta.set('ref-origin', reference.uri);
|
|
743
743
|
// annotate fragment with info about referencing element
|
|
744
|
-
mergedElement.meta.set('ref-referencing-element-id',
|
|
744
|
+
mergedElement.meta.set('ref-referencing-element-id', identityManager.identify(referencingElement));
|
|
745
745
|
referencedElement = mergedElement;
|
|
746
746
|
}
|
|
747
747
|
/**
|