@swagger-api/apidom-ns-api-design-systems 0.76.2 → 0.78.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 +10 -0
- package/cjs/elements/Info.cjs +1 -2
- package/cjs/elements/Main.cjs +1 -2
- package/cjs/elements/Principle.cjs +1 -2
- package/cjs/elements/Requirement.cjs +1 -2
- package/cjs/elements/RequirementLevel.cjs +1 -2
- package/cjs/elements/Scenario.cjs +1 -2
- package/cjs/elements/Standard.cjs +1 -2
- package/cjs/elements/StandardIdentifier.cjs +1 -2
- package/cjs/media-types.cjs +1 -2
- package/cjs/namespace.cjs +1 -2
- package/cjs/predicates.cjs +9 -17
- package/cjs/refractor/index.cjs +1 -2
- package/cjs/refractor/plugins/openapi-3-1/standard-identifier-accessors.cjs +14 -19
- package/cjs/refractor/plugins/openapi-3-1/standard-identifier-selectors.cjs +10 -14
- package/cjs/refractor/specification.cjs +1 -2
- package/cjs/refractor/toolbox.cjs +1 -2
- package/cjs/refractor/visitors/FallbackVisitor.cjs +2 -3
- package/cjs/refractor/visitors/SpecificationVisitor.cjs +7 -4
- package/cjs/refractor/visitors/Visitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/info/DescriptionVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/info/TitleVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/info/index.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/main/PrinciplesVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/main/ScenariosVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/main/StandardsVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/main/VersionVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/main/index.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/principle/DescriptionVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/principle/IriVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/principle/NameVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/principle/index.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/requirement/FollowsVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/requirement/ValuesVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/requirement/index.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/requirement-level/index.cjs +2 -3
- package/cjs/refractor/visitors/api-design-systems/scenario/DescriptionVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/scenario/ThenVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/scenario/index.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/standard/DescriptionVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/standard/IriVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/standard/NameVisitor.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/standard/index.cjs +1 -2
- package/cjs/refractor/visitors/api-design-systems/standard-identifier/index.cjs +1 -2
- package/cjs/refractor/visitors/generics/FixedFieldsVisitor.cjs +6 -7
- package/cjs/traversal/visitor.cjs +2 -3
- package/cjs/validator/openapi-3-1/accessor.cjs +3 -4
- package/cjs/validator/openapi-3-1/selector.cjs +5 -6
- package/cjs/validator/openapi-3-1/validator.cjs +9 -10
- package/dist/apidom-ns-api-design-systems.browser.js +4067 -17645
- package/dist/apidom-ns-api-design-systems.browser.min.js +1 -1
- package/es/refractor/plugins/openapi-3-1/standard-identifier-accessors.mjs +14 -18
- package/es/refractor/plugins/openapi-3-1/standard-identifier-selectors.mjs +9 -12
- package/es/refractor/visitors/FallbackVisitor.mjs +2 -2
- package/es/refractor/visitors/SpecificationVisitor.mjs +8 -4
- package/es/refractor/visitors/api-design-systems/requirement-level/index.mjs +2 -2
- package/es/refractor/visitors/generics/FixedFieldsVisitor.mjs +6 -6
- package/es/validator/openapi-3-1/accessor.mjs +3 -3
- package/es/validator/openapi-3-1/selector.mjs +5 -5
- package/es/validator/openapi-3-1/validator.mjs +9 -9
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StringElement } from '@swagger-api/apidom-core';
|
|
1
|
+
import { StringElement, toValue, cloneDeep } from '@swagger-api/apidom-core';
|
|
2
2
|
import { isStringElement, isArrayElement, isObjectElement } from '@swagger-api/apidom-ns-openapi-3-1';
|
|
3
3
|
const plugin = () => () => {
|
|
4
4
|
return {
|
|
@@ -6,8 +6,8 @@ const plugin = () => () => {
|
|
|
6
6
|
OperationElement(element, ...rest) {
|
|
7
7
|
const [,,, ancestors] = rest;
|
|
8
8
|
const parentPathItem = ancestors[ancestors.length - 2];
|
|
9
|
-
const httpMethod = element.meta.get('http-method')
|
|
10
|
-
httpMethod.content =
|
|
9
|
+
const httpMethod = cloneDeep(element.meta.get('http-method'));
|
|
10
|
+
httpMethod.content = toValue(httpMethod).toLowerCase();
|
|
11
11
|
const standardIdentifiers = [{
|
|
12
12
|
subject: ['http', 'request', 'url'],
|
|
13
13
|
value: parentPathItem.meta.get('path')
|
|
@@ -18,16 +18,14 @@ const plugin = () => () => {
|
|
|
18
18
|
if (typeof parentPathItem.parameters !== 'undefined' && isArrayElement(parentPathItem.parameters)) {
|
|
19
19
|
// @ts-ignore
|
|
20
20
|
parentPathItem.parameters.forEach(parameter => {
|
|
21
|
-
|
|
22
|
-
if (isStringElement(parameter.in) && isStringElement(parameter.name) && ((_parameter$in = parameter.in) === null || _parameter$in === void 0 ? void 0 : _parameter$in.toValue()) === 'header') {
|
|
23
|
-
var _parameter$name, _parameter$name2;
|
|
21
|
+
if (isStringElement(parameter.in) && isStringElement(parameter.name) && toValue(parameter.in) === 'header') {
|
|
24
22
|
standardIdentifiers.push({
|
|
25
23
|
subject: ['http', 'request', 'header'],
|
|
26
|
-
value: (
|
|
24
|
+
value: cloneDeep.safe(parameter.name)
|
|
27
25
|
});
|
|
28
26
|
standardIdentifiers.push({
|
|
29
27
|
subject: ['http', 'message', 'header'],
|
|
30
|
-
value: (
|
|
28
|
+
value: cloneDeep.safe(parameter.name)
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
});
|
|
@@ -35,15 +33,13 @@ const plugin = () => () => {
|
|
|
35
33
|
element.setMetaProperty('ads-a-standard-identifier', standardIdentifiers);
|
|
36
34
|
},
|
|
37
35
|
ParameterElement(element) {
|
|
38
|
-
|
|
39
|
-
if (isStringElement(element.in) && isStringElement(element.name) && ((_element$in = element.in) === null || _element$in === void 0 ? void 0 : _element$in.toValue()) === 'header') {
|
|
40
|
-
var _element$name, _element$name2;
|
|
36
|
+
if (isStringElement(element.in) && isStringElement(element.name) && toValue(element.in) === 'header') {
|
|
41
37
|
element.setMetaProperty('ads-a-standard-identifier', [{
|
|
42
38
|
subject: ['http', 'request', 'header'],
|
|
43
|
-
value: (
|
|
39
|
+
value: cloneDeep.safe(element.name)
|
|
44
40
|
}, {
|
|
45
41
|
subject: ['http', 'message', 'header'],
|
|
46
|
-
value: (
|
|
42
|
+
value: cloneDeep.safe(element.name)
|
|
47
43
|
}]);
|
|
48
44
|
}
|
|
49
45
|
},
|
|
@@ -55,16 +51,16 @@ const plugin = () => () => {
|
|
|
55
51
|
element.contentProp.forEach((mediaType, key) => {
|
|
56
52
|
standardIdentifiers.push({
|
|
57
53
|
subject: ['http', 'request', 'header'],
|
|
58
|
-
value: new StringElement('Content-Type', key.meta
|
|
54
|
+
value: new StringElement('Content-Type', cloneDeep(key.meta))
|
|
59
55
|
}, {
|
|
60
56
|
subject: ['http', 'message', 'header'],
|
|
61
|
-
value: new StringElement('Content-Type', key.meta
|
|
57
|
+
value: new StringElement('Content-Type', cloneDeep(key.meta))
|
|
62
58
|
}, {
|
|
63
59
|
subject: ['http', 'request', 'header', 'Content-Type'],
|
|
64
|
-
value: key
|
|
60
|
+
value: cloneDeep(key)
|
|
65
61
|
}, {
|
|
66
62
|
subject: ['http', 'message', 'header', 'Content-Type'],
|
|
67
|
-
value: key
|
|
63
|
+
value: cloneDeep(key)
|
|
68
64
|
});
|
|
69
65
|
});
|
|
70
66
|
element.setMetaProperty('ads-a-standard-identifier', standardIdentifiers);
|
|
@@ -73,7 +69,7 @@ const plugin = () => () => {
|
|
|
73
69
|
if (!element.meta.hasKey('http-status-code')) return;
|
|
74
70
|
const standardIdentifiers = [{
|
|
75
71
|
subject: ['http', 'response', 'status_code'],
|
|
76
|
-
value: element.meta.get('http-status-code')
|
|
72
|
+
value: cloneDeep(element.meta.get('http-status-code'))
|
|
77
73
|
}];
|
|
78
74
|
element.setMetaProperty('ads-a-standard-identifier', standardIdentifiers);
|
|
79
75
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toValue } from '@swagger-api/apidom-core';
|
|
1
2
|
import { isStringElement, isObjectElement } from '@swagger-api/apidom-ns-openapi-3-1';
|
|
2
3
|
const plugin = () => () => {
|
|
3
4
|
let operationIdentifiers = [];
|
|
@@ -9,15 +10,13 @@ const plugin = () => () => {
|
|
|
9
10
|
var _parentPathItem$param;
|
|
10
11
|
const [,,, ancestors] = rest;
|
|
11
12
|
const parentPathItem = ancestors[ancestors.length - 2];
|
|
12
|
-
operationIdentifiers.push(['http', 'transaction'], ['http', 'request'], ['http', 'request', 'url'], ['http', 'request', 'url', parentPathItem.meta.get('path')
|
|
13
|
+
operationIdentifiers.push(['http', 'transaction'], ['http', 'request'], ['http', 'request', 'url'], ['http', 'request', 'url', toValue(parentPathItem.meta.get('path'))], ['http', 'request', 'method'], ['http', 'request', 'method', toValue(element.meta.get('http-method')).toLowerCase()]);
|
|
13
14
|
|
|
14
15
|
// fold PathItem.parameters to Operation.parameters
|
|
15
16
|
// @ts-ignore
|
|
16
17
|
parentPathItem === null || parentPathItem === void 0 || (_parentPathItem$param = parentPathItem.parameters) === null || _parentPathItem$param === void 0 || _parentPathItem$param.forEach(parameter => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _parameter$name, _parameter$name2;
|
|
20
|
-
operationIdentifiers.push(['http', 'request', 'header'], ['http', 'request', 'header', (_parameter$name = parameter.name) === null || _parameter$name === void 0 ? void 0 : _parameter$name.toValue()], ['http', 'message', 'header'], ['http', 'message', 'header', (_parameter$name2 = parameter.name) === null || _parameter$name2 === void 0 ? void 0 : _parameter$name2.toValue()]);
|
|
18
|
+
if (isStringElement(parameter.in) && isStringElement(parameter.name) && toValue(parameter.in) === 'header') {
|
|
19
|
+
operationIdentifiers.push(['http', 'request', 'header'], ['http', 'request', 'header', toValue(parameter.name)], ['http', 'message', 'header'], ['http', 'message', 'header', toValue(parameter.name)]);
|
|
21
20
|
}
|
|
22
21
|
});
|
|
23
22
|
},
|
|
@@ -27,10 +26,8 @@ const plugin = () => () => {
|
|
|
27
26
|
}
|
|
28
27
|
},
|
|
29
28
|
ParameterElement(element) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _element$name, _element$name2;
|
|
33
|
-
operationIdentifiers.push(['http', 'request', 'header'], ['http', 'request', 'header', (_element$name = element.name) === null || _element$name === void 0 ? void 0 : _element$name.toValue()], ['http', 'message', 'header'], ['http', 'message', 'header', (_element$name2 = element.name) === null || _element$name2 === void 0 ? void 0 : _element$name2.toValue()]);
|
|
29
|
+
if (isStringElement(element.in) && isStringElement(element.name) && toValue(element.in) === 'header') {
|
|
30
|
+
operationIdentifiers.push(['http', 'request', 'header'], ['http', 'request', 'header', toValue(element.name)], ['http', 'message', 'header'], ['http', 'message', 'header', toValue(element.name)]);
|
|
34
31
|
}
|
|
35
32
|
},
|
|
36
33
|
RequestBodyElement(element) {
|
|
@@ -46,20 +43,20 @@ const plugin = () => () => {
|
|
|
46
43
|
enter(element) {
|
|
47
44
|
responseIdentifiers.push(['http', 'response']);
|
|
48
45
|
if (element.meta.hasKey('http-status-code')) {
|
|
49
|
-
const statusCode = String(element.meta.get('http-status-code')
|
|
46
|
+
const statusCode = String(toValue(element.meta.get('http-status-code')));
|
|
50
47
|
const statusCodeAlias = statusCode.startsWith('2') ? 'success' : statusCode.startsWith('3') ? 'redirect' : statusCode.startsWith('4') ? 'client_error' : statusCode.startsWith('5') ? 'sever_error' : 'unknown';
|
|
51
48
|
responseIdentifiers.push(['http', 'response', 'status_code'], ['http', 'response', 'status_code', statusCode], ['http', 'response', 'status_code', statusCodeAlias]);
|
|
52
49
|
}
|
|
53
50
|
if (typeof element.headers !== 'undefined' && isObjectElement(element.headers)) {
|
|
54
51
|
element.headers.forEach((value, key) => {
|
|
55
|
-
const headerName =
|
|
52
|
+
const headerName = toValue(key);
|
|
56
53
|
responseIdentifiers.push(['http', 'response', 'header'], ['http', 'response', 'header', headerName], ['http', 'message', 'header', headerName]);
|
|
57
54
|
});
|
|
58
55
|
}
|
|
59
56
|
if (typeof element.contentProp !== 'undefined' && isObjectElement(element.contentProp)) {
|
|
60
57
|
responseIdentifiers.push(['http', 'response', 'body'], ['http', 'message', 'body']);
|
|
61
58
|
element.contentProp.forEach((value, key) => {
|
|
62
|
-
const headerName =
|
|
59
|
+
const headerName = toValue(key);
|
|
63
60
|
responseIdentifiers.push(['http', 'response', 'header'], ['http', 'response', 'header', headerName], ['http', 'message', 'header', headerName]);
|
|
64
61
|
});
|
|
65
62
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import stampit from 'stampit';
|
|
2
|
-
import { BREAK } from '@swagger-api/apidom-core';
|
|
2
|
+
import { BREAK, cloneDeep } from '@swagger-api/apidom-core';
|
|
3
3
|
import Visitor from "./Visitor.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* This visitor is responsible for falling back to current traversed element
|
|
@@ -10,7 +10,7 @@ import Visitor from "./Visitor.mjs";
|
|
|
10
10
|
const FallbackVisitor = stampit(Visitor, {
|
|
11
11
|
methods: {
|
|
12
12
|
enter(element) {
|
|
13
|
-
this.element = element
|
|
13
|
+
this.element = cloneDeep(element);
|
|
14
14
|
return BREAK;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import stampit from 'stampit';
|
|
2
|
-
import { pathSatisfies, path, pick
|
|
2
|
+
import { pathSatisfies, path, pick } from 'ramda';
|
|
3
3
|
import { isFunction, isUndefined } from 'ramda-adjunct';
|
|
4
|
-
import { visit } from '@swagger-api/apidom-core';
|
|
4
|
+
import { visit, cloneDeep } from '@swagger-api/apidom-core';
|
|
5
5
|
import { keyMap, getNodeType } from "../../traversal/visitor.mjs";
|
|
6
6
|
import Visitor from "./Visitor.mjs";
|
|
7
7
|
/**
|
|
@@ -23,7 +23,11 @@ const SpecificationVisitor = stampit(Visitor, {
|
|
|
23
23
|
return pick(['namespace', 'specObj'], this);
|
|
24
24
|
},
|
|
25
25
|
retrieveFixedFields(specPath) {
|
|
26
|
-
|
|
26
|
+
const fixedFields = path(['visitors', ...specPath, 'fixedFields'], this.specObj);
|
|
27
|
+
if (typeof fixedFields === 'object' && fixedFields !== null) {
|
|
28
|
+
return Object.keys(fixedFields);
|
|
29
|
+
}
|
|
30
|
+
return [];
|
|
27
31
|
},
|
|
28
32
|
retrieveVisitor(specPath) {
|
|
29
33
|
if (pathSatisfies(isFunction, ['visitors', ...specPath], this.specObj)) {
|
|
@@ -53,7 +57,7 @@ const SpecificationVisitor = stampit(Visitor, {
|
|
|
53
57
|
this.fallbackVisitorPrototype = Object.getPrototypeOf(this.retrieveVisitorInstance(['value']));
|
|
54
58
|
}
|
|
55
59
|
if (this.fallbackVisitorPrototype === visitorPrototype) {
|
|
56
|
-
return element
|
|
60
|
+
return cloneDeep(element);
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
// standard processing continues
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import stampit from 'stampit';
|
|
2
|
-
import { BREAK } from '@swagger-api/apidom-core';
|
|
2
|
+
import { BREAK, toValue } from '@swagger-api/apidom-core';
|
|
3
3
|
import FallbackVisitor from "../../FallbackVisitor.mjs";
|
|
4
4
|
import SpecificationVisitor from "../../SpecificationVisitor.mjs";
|
|
5
5
|
import RequirementLevelElement from "../../../../elements/RequirementLevel.mjs";
|
|
6
6
|
const RequirementLevelVisitor = stampit(SpecificationVisitor, FallbackVisitor, {
|
|
7
7
|
methods: {
|
|
8
8
|
StringElement(stringElement) {
|
|
9
|
-
const requirementLevelElement = new RequirementLevelElement(
|
|
9
|
+
const requirementLevelElement = new RequirementLevelElement(toValue(stringElement));
|
|
10
10
|
this.copyMetaAndAttributes(stringElement, requirementLevelElement);
|
|
11
11
|
this.element = requirementLevelElement;
|
|
12
12
|
return BREAK;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import stampit from 'stampit';
|
|
2
2
|
import { noop } from 'ramda-adjunct';
|
|
3
|
-
import { BREAK, isStringElement, MemberElement } from '@swagger-api/apidom-core';
|
|
3
|
+
import { BREAK, isStringElement, MemberElement, cloneDeep, toValue } from '@swagger-api/apidom-core';
|
|
4
4
|
import SpecificationVisitor from "../SpecificationVisitor.mjs";
|
|
5
5
|
const FixedFieldsVisitor = stampit(SpecificationVisitor, {
|
|
6
6
|
props: {
|
|
@@ -21,14 +21,14 @@ const FixedFieldsVisitor = stampit(SpecificationVisitor, {
|
|
|
21
21
|
const specPath = this.specPath(objectElement);
|
|
22
22
|
const fields = this.retrieveFixedFields(specPath);
|
|
23
23
|
objectElement.forEach((value, key, memberElement) => {
|
|
24
|
-
if (isStringElement(key) && fields.includes(
|
|
25
|
-
const fixedFieldElement = this.toRefractedElement([...specPath, 'fixedFields',
|
|
26
|
-
const newMemberElement = new MemberElement(key
|
|
24
|
+
if (isStringElement(key) && fields.includes(toValue(key)) && !this.ignoredFields.includes(toValue(key))) {
|
|
25
|
+
const fixedFieldElement = this.toRefractedElement([...specPath, 'fixedFields', toValue(key)], value);
|
|
26
|
+
const newMemberElement = new MemberElement(cloneDeep(key), fixedFieldElement);
|
|
27
27
|
newMemberElement.classes.push('fixed-field');
|
|
28
28
|
this.copyMetaAndAttributes(memberElement, newMemberElement);
|
|
29
29
|
this.element.content.push(newMemberElement);
|
|
30
|
-
} else if (!this.ignoredFields.includes(
|
|
31
|
-
this.element.content.push(memberElement
|
|
30
|
+
} else if (!this.ignoredFields.includes(toValue(key))) {
|
|
31
|
+
this.element.content.push(cloneDeep(memberElement));
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
this.copyMetaAndAttributes(objectElement, this.element);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { visit, ArrayElement } from '@swagger-api/apidom-core';
|
|
1
|
+
import { visit, ArrayElement, toValue } from '@swagger-api/apidom-core';
|
|
2
2
|
import { getNodeType, keyMap } from '@swagger-api/apidom-ns-openapi-3-1';
|
|
3
3
|
/**
|
|
4
4
|
* This file contains logic for translating Standard Identifier to value.
|
|
@@ -9,13 +9,13 @@ const visitorOptions = {
|
|
|
9
9
|
nodeTypeGetter: getNodeType
|
|
10
10
|
};
|
|
11
11
|
const access = (selected, standardIdentifier) => {
|
|
12
|
-
const strStandardIdentifier = String(
|
|
12
|
+
const strStandardIdentifier = String(toValue(standardIdentifier));
|
|
13
13
|
const values = new ArrayElement();
|
|
14
14
|
const visitor = {
|
|
15
15
|
enter(element) {
|
|
16
16
|
if (!element.meta.hasKey('ads-a-standard-identifier')) return;
|
|
17
17
|
element.meta.get('ads-a-standard-identifier').content.filter(accessorMapping => {
|
|
18
|
-
return String(accessorMapping.get('subject')
|
|
18
|
+
return String(toValue(accessorMapping.get('subject'))) === strStandardIdentifier;
|
|
19
19
|
}).forEach(accessorMapping => {
|
|
20
20
|
values.push(accessorMapping.get('value'));
|
|
21
21
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { includes } from 'ramda';
|
|
2
|
-
import { visit } from '@swagger-api/apidom-core';
|
|
2
|
+
import { visit, toValue } from '@swagger-api/apidom-core';
|
|
3
3
|
import { getNodeType, keyMap } from '@swagger-api/apidom-ns-openapi-3-1';
|
|
4
4
|
/**
|
|
5
5
|
* This file contains logic for translating Standard Identifier to list of Operation Elements.
|
|
@@ -14,15 +14,15 @@ const select = (openAPIElement, standardIdentifier) => {
|
|
|
14
14
|
const visitor = {
|
|
15
15
|
OperationElement(element) {
|
|
16
16
|
if (!element.meta.hasKey('ads-s-standard-identifier')) return;
|
|
17
|
-
const standardIdentifiers = element.meta.get('ads-s-standard-identifier')
|
|
18
|
-
if (includes(
|
|
17
|
+
const standardIdentifiers = toValue(element.meta.get('ads-s-standard-identifier'));
|
|
18
|
+
if (includes(toValue(standardIdentifier), standardIdentifiers)) {
|
|
19
19
|
selected.push(element);
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
ResponseElement(element) {
|
|
23
23
|
if (!element.meta.hasKey('ads-s-standard-identifier')) return;
|
|
24
|
-
const standardIdentifiers = element.meta.get('ads-s-standard-identifier')
|
|
25
|
-
if (includes(
|
|
24
|
+
const standardIdentifiers = toValue(element.meta.get('ads-s-standard-identifier'));
|
|
25
|
+
if (includes(toValue(standardIdentifier), standardIdentifiers)) {
|
|
26
26
|
selected.push(element);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { AnnotationElement, isArrayElement } from '@swagger-api/apidom-core';
|
|
1
|
+
import { AnnotationElement, isArrayElement, toValue, cloneDeep } from '@swagger-api/apidom-core';
|
|
2
2
|
import { NotImplementedError } from '@swagger-api/apidom-error';
|
|
3
3
|
import select from "./selector.mjs";
|
|
4
4
|
import access from "./accessor.mjs";
|
|
5
5
|
import { may } from "./requirement-level.mjs";
|
|
6
6
|
const makeMessage = (value, requirementLevel, standardIdentifier) => {
|
|
7
|
-
const primitiveValue =
|
|
8
|
-
const primitiveStandardIdentifier = JSON.stringify(
|
|
9
|
-
if (
|
|
7
|
+
const primitiveValue = toValue(value);
|
|
8
|
+
const primitiveStandardIdentifier = JSON.stringify(toValue(standardIdentifier));
|
|
9
|
+
if (toValue(requirementLevel) === 'may') {
|
|
10
10
|
return `"${primitiveValue}" not allowed for subject ${primitiveStandardIdentifier}`;
|
|
11
11
|
}
|
|
12
|
-
throw new NotImplementedError('[Requirement levels] other than "may" are
|
|
12
|
+
throw new NotImplementedError('[Requirement levels] other than "may" are not yet implemented.');
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
const makeAnnotation = (message, value, level, standardIdentifier) => {
|
|
17
17
|
const annotation = new AnnotationElement(message);
|
|
18
18
|
annotation.classes.push(level);
|
|
19
|
-
annotation.attributes.set('value', value
|
|
20
|
-
annotation.attributes.set('standardIdentifier', standardIdentifier
|
|
19
|
+
annotation.attributes.set('value', cloneDeep(value));
|
|
20
|
+
annotation.attributes.set('standardIdentifier', cloneDeep(standardIdentifier));
|
|
21
21
|
return annotation;
|
|
22
22
|
};
|
|
23
23
|
const validateValue = (value, requirement) => {
|
|
@@ -26,8 +26,8 @@ const validateValue = (value, requirement) => {
|
|
|
26
26
|
subject
|
|
27
27
|
} = requirement;
|
|
28
28
|
if (typeof requirement.values === 'undefined') return annotations;
|
|
29
|
-
if (requirement.level
|
|
30
|
-
const isValid = may(
|
|
29
|
+
if (toValue(requirement.level) === 'may') {
|
|
30
|
+
const isValid = may(toValue(value), toValue(requirement.values));
|
|
31
31
|
if (!isValid) {
|
|
32
32
|
const message = makeMessage(value, requirement.level, subject);
|
|
33
33
|
const annotation = makeAnnotation(message, value, 'error', subject);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swagger-api/apidom-ns-api-design-systems",
|
|
3
3
|
"description": "API Design Systems 2021-05-07 namespace for ApiDOM.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.78.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org"
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"license": "Apache-2.0",
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/runtime-corejs3": "^7.20.7",
|
|
45
|
-
"@swagger-api/apidom-core": "^0.
|
|
46
|
-
"@swagger-api/apidom-error": "^0.
|
|
47
|
-
"@swagger-api/apidom-ns-openapi-3-1": "^0.
|
|
48
|
-
"@types/ramda": "~0.29.
|
|
45
|
+
"@swagger-api/apidom-core": "^0.78.0",
|
|
46
|
+
"@swagger-api/apidom-error": "^0.78.0",
|
|
47
|
+
"@swagger-api/apidom-ns-openapi-3-1": "^0.78.0",
|
|
48
|
+
"@types/ramda": "~0.29.6",
|
|
49
49
|
"ramda": "~0.29.0",
|
|
50
50
|
"ramda-adjunct": "^4.1.1",
|
|
51
51
|
"stampit": "^4.3.2"
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"README.md",
|
|
61
61
|
"CHANGELOG.md"
|
|
62
62
|
],
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "d6587217f8a7bec5bbc49ca4dabff8d3d66e0913"
|
|
64
64
|
}
|