@swagger-api/apidom-ns-api-design-systems 0.68.1
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 +292 -0
- package/LICENSES/Apache-2.0.txt +202 -0
- package/LICENSES/MIT.txt +9 -0
- package/NOTICE +57 -0
- package/README.md +324 -0
- package/cjs/elements/Info.cjs +25 -0
- package/cjs/elements/Main.cjs +44 -0
- package/cjs/elements/Principle.cjs +37 -0
- package/cjs/elements/Requirement.cjs +37 -0
- package/cjs/elements/RequirementLevel.cjs +13 -0
- package/cjs/elements/Scenario.cjs +31 -0
- package/cjs/elements/Standard.cjs +37 -0
- package/cjs/elements/StandardIdentifier.cjs +13 -0
- package/cjs/index.cjs +50 -0
- package/cjs/media-types.cjs +24 -0
- package/cjs/namespace.cjs +39 -0
- package/cjs/predicates.cjs +78 -0
- package/cjs/refractor/index.cjs +48 -0
- package/cjs/refractor/plugins/openapi-3-1/standard-identifier-accessors.cjs +88 -0
- package/cjs/refractor/plugins/openapi-3-1/standard-identifier-selectors.cjs +80 -0
- package/cjs/refractor/registration.cjs +36 -0
- package/cjs/refractor/specification.cjs +122 -0
- package/cjs/refractor/toolbox.cjs +23 -0
- package/cjs/refractor/visitors/FallbackVisitor.cjs +24 -0
- package/cjs/refractor/visitors/SpecificationVisitor.cjs +75 -0
- package/cjs/refractor/visitors/Visitor.cjs +22 -0
- package/cjs/refractor/visitors/api-design-systems/info/DescriptionVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/info/TitleVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/info/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/main/PrinciplesVisitor.cjs +28 -0
- package/cjs/refractor/visitors/api-design-systems/main/ScenariosVisitor.cjs +28 -0
- package/cjs/refractor/visitors/api-design-systems/main/StandardsVisitor.cjs +28 -0
- package/cjs/refractor/visitors/api-design-systems/main/VersionVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/main/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/principle/DescriptionVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/principle/IriVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/principle/NameVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/principle/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/requirement/FollowsVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/requirement/ValuesVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/requirement/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/requirement-level/index.cjs +22 -0
- package/cjs/refractor/visitors/api-design-systems/scenario/DescriptionVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/scenario/ThenVisitor.cjs +28 -0
- package/cjs/refractor/visitors/api-design-systems/scenario/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/standard/DescriptionVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/standard/IriVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/standard/NameVisitor.cjs +9 -0
- package/cjs/refractor/visitors/api-design-systems/standard/index.cjs +20 -0
- package/cjs/refractor/visitors/api-design-systems/standard-identifier/index.cjs +28 -0
- package/cjs/refractor/visitors/generics/FixedFieldsVisitor.cjs +45 -0
- package/cjs/traversal/visitor.cjs +28 -0
- package/cjs/validator/openapi-3-1/accessor.cjs +32 -0
- package/cjs/validator/openapi-3-1/requirement-level.cjs +13 -0
- package/cjs/validator/openapi-3-1/selector.cjs +38 -0
- package/cjs/validator/openapi-3-1/validator.cjs +86 -0
- package/dist/apidom-ns-api-design-systems.browser.js +30558 -0
- package/dist/apidom-ns-api-design-systems.browser.min.js +1 -0
- package/es/elements/Info.js +20 -0
- package/es/elements/Main.js +39 -0
- package/es/elements/Principle.js +32 -0
- package/es/elements/Requirement.js +32 -0
- package/es/elements/RequirementLevel.js +8 -0
- package/es/elements/Scenario.js +26 -0
- package/es/elements/Standard.js +32 -0
- package/es/elements/StandardIdentifier.js +8 -0
- package/es/index.js +12 -0
- package/es/media-types.js +18 -0
- package/es/namespace.js +32 -0
- package/es/predicates.js +65 -0
- package/es/refractor/index.js +43 -0
- package/es/refractor/plugins/openapi-3-1/standard-identifier-accessors.js +83 -0
- package/es/refractor/plugins/openapi-3-1/standard-identifier-selectors.js +75 -0
- package/es/refractor/registration.js +24 -0
- package/es/refractor/specification.js +115 -0
- package/es/refractor/toolbox.js +17 -0
- package/es/refractor/visitors/FallbackVisitor.js +18 -0
- package/es/refractor/visitors/SpecificationVisitor.js +69 -0
- package/es/refractor/visitors/Visitor.js +16 -0
- package/es/refractor/visitors/api-design-systems/info/DescriptionVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/info/TitleVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/info/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/main/PrinciplesVisitor.js +22 -0
- package/es/refractor/visitors/api-design-systems/main/ScenariosVisitor.js +22 -0
- package/es/refractor/visitors/api-design-systems/main/StandardsVisitor.js +22 -0
- package/es/refractor/visitors/api-design-systems/main/VersionVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/main/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/principle/DescriptionVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/principle/IriVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/principle/NameVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/principle/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/requirement/FollowsVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/requirement/ValuesVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/requirement/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/requirement-level/index.js +16 -0
- package/es/refractor/visitors/api-design-systems/scenario/DescriptionVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/scenario/ThenVisitor.js +22 -0
- package/es/refractor/visitors/api-design-systems/scenario/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/standard/DescriptionVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/standard/IriVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/standard/NameVisitor.js +3 -0
- package/es/refractor/visitors/api-design-systems/standard/index.js +14 -0
- package/es/refractor/visitors/api-design-systems/standard-identifier/index.js +22 -0
- package/es/refractor/visitors/generics/FixedFieldsVisitor.js +39 -0
- package/es/traversal/visitor.js +25 -0
- package/es/validator/openapi-3-1/accessor.js +27 -0
- package/es/validator/openapi-3-1/requirement-level.js +7 -0
- package/es/validator/openapi-3-1/selector.js +33 -0
- package/es/validator/openapi-3-1/validator.js +80 -0
- package/package.json +63 -0
- package/types/dist.d.ts +158 -0
package/README.md
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# @swagger-api/apidom-ns-api-design-systems
|
|
2
|
+
|
|
3
|
+
`@swagger-api/apidom-ns-api-design-systems` contains ApiDOM namespace specific to [API Design System Specification](https://apidesign.systems/specification/).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can install this package via [npm CLI](https://docs.npmjs.com/cli) by running the following command:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
$ npm install @swagger-api/apidom-ns-api-design-systems
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## API Design Systems 2021-05-07 namespace
|
|
14
|
+
|
|
15
|
+
API Design Systems 2021-05-07 namespace consists of [number of elements](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-api-design-systems/src/elements) implemented on top
|
|
16
|
+
of [primitive ones](https://github.com/refractproject/minim/tree/master/lib/primitives).
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { createNamespace } from '@swagger-api/apidom-core';
|
|
20
|
+
import apiDesignSystemsNamespace from '@swagger-api/apidom-ns-api-design-systems';
|
|
21
|
+
|
|
22
|
+
const namespace = createNamespace(apiDesignSystemsNamespace);
|
|
23
|
+
|
|
24
|
+
const objectElement = new namespace.elements.Object();
|
|
25
|
+
const mainElement = new namespace.elements.Main();
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
When namespace instance is created in this way, it will extend the base namespace
|
|
29
|
+
with the namespace provided as an argument.
|
|
30
|
+
|
|
31
|
+
Elements from the namespace can also be used directly by importing them.
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { MainElement, InfoElement } from '@swagger-api/apidom-ns-api-design-systems';
|
|
35
|
+
|
|
36
|
+
const infoElement = new InfoElement();
|
|
37
|
+
const mainElement = new MainElement();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Predicates
|
|
41
|
+
|
|
42
|
+
This package exposes [predicates](https://github.com/swagger-api/apidom/blob/main/packages/apidom-ns-api-design-systems/src/predicates.ts)
|
|
43
|
+
for all higher order elements that are part of this namespace.
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import { isMainElement, MainElement } from '@swagger-api/apidom-ns-api-design-systems';
|
|
47
|
+
|
|
48
|
+
const mainElement = new MainElement();
|
|
49
|
+
|
|
50
|
+
isMainElement(mainElement); // => true
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Traversal
|
|
54
|
+
|
|
55
|
+
Traversing ApiDOM in this namespace is possible by using `visit` function from `apidom` package.
|
|
56
|
+
This package comes with its own [keyMap](https://github.com/swagger-api/apidom/blob/main/packages/apidom-ns-api-design-systems/src/traversal/visitor.ts) and and [nodeTypeGetter](https://github.com/swagger-api/apidom/blob/main/packages/apidom-ns-api-design-systems/src/traversal/visitor.ts).
|
|
57
|
+
To learn more about these `visit` configuration options please refer to [@swagger-api/apidom-ast documentation](https://github.com/swagger-api/apidom/blob/main/packages/apidom-ast/README.md#visit).
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
import { visit } from '@swagger-api/apidom-core';
|
|
61
|
+
import { MainElement, keyMap, getNodeType } from '@swagger-api/apidom-ns-api-design-systems';
|
|
62
|
+
|
|
63
|
+
const element = new MainElement();
|
|
64
|
+
|
|
65
|
+
const visitor = {
|
|
66
|
+
MainElement(mainElement) {
|
|
67
|
+
console.dir(mainElement);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
visit(element, visitor, { keyMap, nodeTypeGetter: getNodeType });
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Refractors
|
|
75
|
+
|
|
76
|
+
Refractor is a special layer inside the namespace that can transform either JavaScript structures
|
|
77
|
+
or generic ApiDOM structures into structures built from elements of this namespace.
|
|
78
|
+
|
|
79
|
+
**Refracting JavaScript structures**:
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
import { InfoElement } from '@swagger-api/apidom-ns-api-design-systems';
|
|
83
|
+
|
|
84
|
+
const object = {
|
|
85
|
+
title: 'my title',
|
|
86
|
+
description: 'my description',
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
InfoElement.refract(object); // => InfoElement({ title, description })
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Refracting generic ApiDOM structures**:
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
import { ObjectElement } from '@swagger-api/apidom-core';
|
|
96
|
+
import { InfoElement } from '@swagger-api/apidom-ns-api-design-systems';
|
|
97
|
+
|
|
98
|
+
const objectElement = new ObjectElement({
|
|
99
|
+
title: 'my title',
|
|
100
|
+
description: 'my description',
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
InfoElement.refract(objectElement); // => InfoElement({ title = 'my title', description = 'my description' })
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Refractor plugins
|
|
107
|
+
|
|
108
|
+
Refractors can accept plugins as a second argument of refract static method.
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
import { ObjectElement } from '@swagger-api/apidom-core';
|
|
112
|
+
import { InfoElement } from '@swagger-api/apidom-ns-api-design-systems';
|
|
113
|
+
|
|
114
|
+
const objectElement = new ObjectElement({
|
|
115
|
+
title: 'my title',
|
|
116
|
+
description: 'my description',
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const plugin = ({ predicates, namespace }) => ({
|
|
120
|
+
name: 'plugin',
|
|
121
|
+
pre() {
|
|
122
|
+
console.dir('runs before traversal');
|
|
123
|
+
},
|
|
124
|
+
visitor: {
|
|
125
|
+
InfoElement(infoElement) {
|
|
126
|
+
infoElement.title = 'new title';
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
post() {
|
|
130
|
+
console.dir('runs after traversal');
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
InfoElement.refract(objectElement, { plugins: [plugin] }); // => InfoElement({ title = 'new title', description = 'my description' })
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
You can define as many plugins as needed to enhance the resulting namespaced ApiDOM structure.
|
|
138
|
+
If multiple plugins with the same visitor method are defined, they run in parallel (just like in Babel).
|
|
139
|
+
|
|
140
|
+
#### OpenAPI 3.1 Standard Identifier plugins
|
|
141
|
+
|
|
142
|
+
This namespace comes with two refractor plugins specific to OpenAPI 3.1 specification and decorates significant
|
|
143
|
+
OpenAPI 3.1 elements with [Standard Identifiers](https://apidesign.systems/standards/).
|
|
144
|
+
|
|
145
|
+
```js
|
|
146
|
+
import { parse } from '@swagger-api/apidom-parser-adapter-json';
|
|
147
|
+
import {
|
|
148
|
+
refractPluginOpenApi3_1StandardIdentifierSelectors,
|
|
149
|
+
refractPluginOpenApi3_1StandardIdentifierAccessors,
|
|
150
|
+
} from '@swagger-api/apidom-ns-api-design-systems';
|
|
151
|
+
import { OpenApi3_1Element } from '@swagger-api/apidom-ns-openapi-3-1';
|
|
152
|
+
|
|
153
|
+
const jsonDefinition = `
|
|
154
|
+
{
|
|
155
|
+
"openapi": "3.1.0",
|
|
156
|
+
"paths": {
|
|
157
|
+
"/path1": {
|
|
158
|
+
"get": {},
|
|
159
|
+
"put": {
|
|
160
|
+
"parameters": [
|
|
161
|
+
{
|
|
162
|
+
"name": "X-Header",
|
|
163
|
+
"in": "header",
|
|
164
|
+
"description": "parameter3 description",
|
|
165
|
+
"required": false,
|
|
166
|
+
"deprecated": false,
|
|
167
|
+
"allowEmptyValue": true
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
"requestBody": {
|
|
171
|
+
"content": {
|
|
172
|
+
"application/json": {
|
|
173
|
+
"schema": {
|
|
174
|
+
"type": "object"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
"required": true
|
|
179
|
+
},
|
|
180
|
+
"responses": {
|
|
181
|
+
"201": {
|
|
182
|
+
"content": {
|
|
183
|
+
"application/json": {}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"parameters": [
|
|
189
|
+
{
|
|
190
|
+
"name": "X-Header2",
|
|
191
|
+
"in": "header",
|
|
192
|
+
"description": "parameter1 description",
|
|
193
|
+
"allowEmptyValue": true
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
`;
|
|
200
|
+
const apiDOM = await parse(jsonDefinition, { sourceMap: true });
|
|
201
|
+
const openApiElement = OpenApi3_1Element.refract(apiDOM.result, {
|
|
202
|
+
plugins: [
|
|
203
|
+
refractPluginOpenApi3_1StandardIdentifierSelectors(),
|
|
204
|
+
refractPluginOpenApi3_1StandardIdentifierAccessors(),
|
|
205
|
+
],
|
|
206
|
+
});
|
|
207
|
+
// => OperationElement now contains [['http', 'transaction']] under `ads-s-standard-identifier` key
|
|
208
|
+
// => OperationElement now contains followign structure under `ads-a-standard-identifier` key
|
|
209
|
+
// [
|
|
210
|
+
// {
|
|
211
|
+
// subject: ['http', 'request', 'method'],
|
|
212
|
+
// value: 'get',
|
|
213
|
+
// },
|
|
214
|
+
// ]
|
|
215
|
+
//
|
|
216
|
+
// other elements are decorated by different metadata as well
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Validation
|
|
220
|
+
|
|
221
|
+
This package supports validation API Design Systems definition against OpenAPI 3.1 definition.
|
|
222
|
+
Validator is in POC phase and there is limited support for `Scenario` objects. Validation
|
|
223
|
+
produces list of `Annotation` elements.
|
|
224
|
+
|
|
225
|
+
**API Design Systems definition**:
|
|
226
|
+
|
|
227
|
+
```yaml
|
|
228
|
+
version: "2021-05-07"
|
|
229
|
+
info:
|
|
230
|
+
title: SmartBear API Guidelines
|
|
231
|
+
description: |
|
|
232
|
+
A machine and human readable version of the SmartBear API Style Guide aimed at promoting living API Style Governance across various tools and teams, leading to improved API quality.
|
|
233
|
+
See the [SmartBear Standards and Guidelines](https://github.com/SmartBear/api-standards-and-guidelines) repo for a traditional view of the static guidelines.
|
|
234
|
+
principles:
|
|
235
|
+
- iri: urn:apidesign.systems:principle:robustness
|
|
236
|
+
level: must
|
|
237
|
+
- iri: urn:apidesign.systems:principle:rmm:level2
|
|
238
|
+
level: must
|
|
239
|
+
- iri: urn:apidesign.systems:principle:rmm:level3
|
|
240
|
+
level: should
|
|
241
|
+
standards:
|
|
242
|
+
- iri: urn:ietf:rfc:6648
|
|
243
|
+
level: must
|
|
244
|
+
- iri: urn:ietf:rfc:7807
|
|
245
|
+
level: must
|
|
246
|
+
- iri: urn:ietf:rfc:7231
|
|
247
|
+
level: should
|
|
248
|
+
- iri: urn:ietf:rfc:6585
|
|
249
|
+
level: may
|
|
250
|
+
- iri: urn:ietf:rfc:5788
|
|
251
|
+
level: may
|
|
252
|
+
- iri: urn:ietf:draft:http-semantics
|
|
253
|
+
level: may
|
|
254
|
+
scenarios:
|
|
255
|
+
- description: SB-API-010 - Only apply standard HTTP methods
|
|
256
|
+
when: [http, transaction]
|
|
257
|
+
then:
|
|
258
|
+
- subject: [http, request, method]
|
|
259
|
+
level: may
|
|
260
|
+
values:
|
|
261
|
+
- get
|
|
262
|
+
- post
|
|
263
|
+
- put
|
|
264
|
+
- patch
|
|
265
|
+
- delete
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**OpenAPI 3.1 definition**:
|
|
269
|
+
|
|
270
|
+
```json
|
|
271
|
+
{
|
|
272
|
+
"openapi": "3.1.0",
|
|
273
|
+
"paths": {
|
|
274
|
+
"/path1": {
|
|
275
|
+
"get": {},
|
|
276
|
+
"put": {},
|
|
277
|
+
"trace": {},
|
|
278
|
+
"options": {}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Validation**:
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
import { parse as parseJSON } from '@swagger-api/apidom-parser-adapter-json';
|
|
288
|
+
import { parse as parseYAML } from '@swagger-api/apidom-parser-adapter-yaml-1-2';
|
|
289
|
+
import { OpenApi3_1Element } from '@swagger-api/apidom-ns-openapi-3-1';
|
|
290
|
+
import {
|
|
291
|
+
refractPluginOpenApi3_1StandardIdentifierSelectors,
|
|
292
|
+
refractPluginOpenApi3_1StandardIdentifierAccessors,
|
|
293
|
+
MainElement,
|
|
294
|
+
validateOpenAPI3_1,
|
|
295
|
+
} from '@swagger-api/apidom-ns-api-design-systems';
|
|
296
|
+
|
|
297
|
+
const apiDesignSystemsParseResult = await parseYAML(apiDesignSystemsDefinition);
|
|
298
|
+
const openAPIParseResult = await parseJSON(openAPIDefinition, { sourceMap: true });
|
|
299
|
+
const mainElement = MainElement.refract(apiDesignSystemsParseResult.result);
|
|
300
|
+
const openapiElement = OpenApi3_1Element.refract(openAPIParseResult.result, {
|
|
301
|
+
plugins: [
|
|
302
|
+
refractPluginOpenApi3_1StandardIdentifierSelectors(),
|
|
303
|
+
refractPluginOpenApi3_1StandardIdentifierAccessors(),
|
|
304
|
+
],
|
|
305
|
+
});
|
|
306
|
+
const annotations = validateOpenAPI3_1(mainElement, openapiElement);
|
|
307
|
+
// [
|
|
308
|
+
// Annotation('"trace" not allowed for subject ["http","request","method"] on line 6, column 6', class=error),
|
|
309
|
+
// Annotation('"options" not allowed for subject ["http","request","method"] on line 7, column 6', class=error),
|
|
310
|
+
// ]
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Implementation progress
|
|
314
|
+
|
|
315
|
+
Only fully implemented specification objects should be checked here.
|
|
316
|
+
|
|
317
|
+
- [x] [Main](https://apidesign.systems/specification/#main)
|
|
318
|
+
- [x] [Info](https://apidesign.systems/specification/#info-object)
|
|
319
|
+
- [x] [Principle](https://apidesign.systems/specification/#principle)
|
|
320
|
+
- [x] [Standard](https://apidesign.systems/specification/#standard)
|
|
321
|
+
- [x] [Scenario](https://apidesign.systems/specification/#scenario)
|
|
322
|
+
- [x] [Requirement](https://apidesign.systems/specification/#requirement)
|
|
323
|
+
- [x] [Standard Identifier](https://apidesign.systems/specification/#standard-identifier-arraystring)
|
|
324
|
+
- [x] [Requirement Level](https://apidesign.systems/specification/#requirement-level-enum)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
6
|
+
class Info extends _apidomCore.ObjectElement {
|
|
7
|
+
constructor(content, meta, attributes) {
|
|
8
|
+
super(content, meta, attributes);
|
|
9
|
+
this.element = 'info';
|
|
10
|
+
}
|
|
11
|
+
get title() {
|
|
12
|
+
return this.get('title');
|
|
13
|
+
}
|
|
14
|
+
set title(title) {
|
|
15
|
+
this.set('title', title);
|
|
16
|
+
}
|
|
17
|
+
get description() {
|
|
18
|
+
return this.get('description');
|
|
19
|
+
}
|
|
20
|
+
set description(description) {
|
|
21
|
+
this.set('description', description);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
var _default = Info;
|
|
25
|
+
exports.default = _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
6
|
+
class Main extends _apidomCore.ObjectElement {
|
|
7
|
+
constructor(content, meta, attributes) {
|
|
8
|
+
super(content, meta, attributes);
|
|
9
|
+
this.element = 'main';
|
|
10
|
+
this.classes.push('api');
|
|
11
|
+
}
|
|
12
|
+
get version() {
|
|
13
|
+
return this.get('version');
|
|
14
|
+
}
|
|
15
|
+
set version(version) {
|
|
16
|
+
this.set('version', version);
|
|
17
|
+
}
|
|
18
|
+
get info() {
|
|
19
|
+
return this.get('info');
|
|
20
|
+
}
|
|
21
|
+
set info(info) {
|
|
22
|
+
this.set('info', info);
|
|
23
|
+
}
|
|
24
|
+
get principles() {
|
|
25
|
+
return this.get('principles');
|
|
26
|
+
}
|
|
27
|
+
set principles(principles) {
|
|
28
|
+
this.set('principles', principles);
|
|
29
|
+
}
|
|
30
|
+
get standards() {
|
|
31
|
+
return this.get('standards');
|
|
32
|
+
}
|
|
33
|
+
set standards(standards) {
|
|
34
|
+
this.set('standards', standards);
|
|
35
|
+
}
|
|
36
|
+
get scenarios() {
|
|
37
|
+
return this.get('scenarios');
|
|
38
|
+
}
|
|
39
|
+
set scenarios(scenarios) {
|
|
40
|
+
this.set('scenarios', scenarios);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
var _default = Main;
|
|
44
|
+
exports.default = _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
6
|
+
class Principle extends _apidomCore.ObjectElement {
|
|
7
|
+
constructor(content, meta, attributes) {
|
|
8
|
+
super(content, meta, attributes);
|
|
9
|
+
this.element = 'principle';
|
|
10
|
+
}
|
|
11
|
+
get name() {
|
|
12
|
+
return this.get('name');
|
|
13
|
+
}
|
|
14
|
+
set name(name) {
|
|
15
|
+
this.set('name', name);
|
|
16
|
+
}
|
|
17
|
+
get description() {
|
|
18
|
+
return this.get('description');
|
|
19
|
+
}
|
|
20
|
+
set description(description) {
|
|
21
|
+
this.set('description', description);
|
|
22
|
+
}
|
|
23
|
+
get iri() {
|
|
24
|
+
return this.get('iri');
|
|
25
|
+
}
|
|
26
|
+
set iri(iri) {
|
|
27
|
+
this.set('iri', iri);
|
|
28
|
+
}
|
|
29
|
+
get level() {
|
|
30
|
+
return this.get('level');
|
|
31
|
+
}
|
|
32
|
+
set level(level) {
|
|
33
|
+
this.set('level', level);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var _default = Principle;
|
|
37
|
+
exports.default = _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
6
|
+
class Requirement extends _apidomCore.ObjectElement {
|
|
7
|
+
constructor(content, meta, attributes) {
|
|
8
|
+
super(content, meta, attributes);
|
|
9
|
+
this.element = 'requirement';
|
|
10
|
+
}
|
|
11
|
+
get subject() {
|
|
12
|
+
return this.get('subject');
|
|
13
|
+
}
|
|
14
|
+
set subject(subject) {
|
|
15
|
+
this.set('subject', subject);
|
|
16
|
+
}
|
|
17
|
+
get level() {
|
|
18
|
+
return this.get('level');
|
|
19
|
+
}
|
|
20
|
+
set level(level) {
|
|
21
|
+
this.set('level', level);
|
|
22
|
+
}
|
|
23
|
+
get values() {
|
|
24
|
+
return this.get('values');
|
|
25
|
+
}
|
|
26
|
+
set values(values) {
|
|
27
|
+
this.set('values', values);
|
|
28
|
+
}
|
|
29
|
+
get follows() {
|
|
30
|
+
return this.get('follows');
|
|
31
|
+
}
|
|
32
|
+
set follows(follows) {
|
|
33
|
+
this.set('follows', follows);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var _default = Requirement;
|
|
37
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
6
|
+
class RequirementLevel extends _apidomCore.StringElement {
|
|
7
|
+
constructor(content, meta, attributes) {
|
|
8
|
+
super(content, meta, attributes);
|
|
9
|
+
this.element = 'requirementLevel';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
var _default = RequirementLevel;
|
|
13
|
+
exports.default = _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
6
|
+
class Scenario extends _apidomCore.ObjectElement {
|
|
7
|
+
constructor(content, meta, attributes) {
|
|
8
|
+
super(content, meta, attributes);
|
|
9
|
+
this.element = 'scenario';
|
|
10
|
+
}
|
|
11
|
+
get description() {
|
|
12
|
+
return this.get('description');
|
|
13
|
+
}
|
|
14
|
+
set description(description) {
|
|
15
|
+
this.set('description', description);
|
|
16
|
+
}
|
|
17
|
+
get when() {
|
|
18
|
+
return this.get('when');
|
|
19
|
+
}
|
|
20
|
+
set when(when) {
|
|
21
|
+
this.set('when', when);
|
|
22
|
+
}
|
|
23
|
+
get then() {
|
|
24
|
+
return this.get('then');
|
|
25
|
+
}
|
|
26
|
+
set then(then) {
|
|
27
|
+
this.set('then', then);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
var _default = Scenario;
|
|
31
|
+
exports.default = _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
6
|
+
class Standard extends _apidomCore.ObjectElement {
|
|
7
|
+
constructor(content, meta, attributes) {
|
|
8
|
+
super(content, meta, attributes);
|
|
9
|
+
this.element = 'standard';
|
|
10
|
+
}
|
|
11
|
+
get name() {
|
|
12
|
+
return this.get('name');
|
|
13
|
+
}
|
|
14
|
+
set name(name) {
|
|
15
|
+
this.set('name', name);
|
|
16
|
+
}
|
|
17
|
+
get description() {
|
|
18
|
+
return this.get('description');
|
|
19
|
+
}
|
|
20
|
+
set description(description) {
|
|
21
|
+
this.set('description', description);
|
|
22
|
+
}
|
|
23
|
+
get iri() {
|
|
24
|
+
return this.get('iri');
|
|
25
|
+
}
|
|
26
|
+
set iri(iri) {
|
|
27
|
+
this.set('iri', iri);
|
|
28
|
+
}
|
|
29
|
+
get level() {
|
|
30
|
+
return this.get('level');
|
|
31
|
+
}
|
|
32
|
+
set level(level) {
|
|
33
|
+
this.set('level', level);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var _default = Standard;
|
|
37
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
6
|
+
class StandardIdentifier extends _apidomCore.ArrayElement {
|
|
7
|
+
constructor(content, meta, attributes) {
|
|
8
|
+
super(content, meta, attributes);
|
|
9
|
+
this.element = 'standardIdentifier';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
var _default = StandardIdentifier;
|
|
13
|
+
exports.default = _default;
|
package/cjs/index.cjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.validateOpenAPI3_1 = exports.refractPluginOpenApi3_1StandardIdentifierSelectors = exports.refractPluginOpenApi3_1StandardIdentifierAccessors = exports.mediaTypes = exports.keyMap = exports.isStringElement = exports.isStandardIdentifierElement = exports.isStandardElement = exports.isScenarioElement = exports.isRequirementLevelElement = exports.isRequirementElement = exports.isRefElement = exports.isPrincipleElement = exports.isObjectElement = exports.isNumberElement = exports.isNullElement = exports.isMemberElement = exports.isMainElement = exports.isLinkElement = exports.isInfoElement = exports.isElement = exports.isBooleanElement = exports.isArrayElement = exports.getNodeType = exports.default = exports.StandardIdentifierElement = exports.StandardElement = exports.ScenarioElement = exports.RequirementLevelElement = exports.RequirementElement = exports.PrincipleElement = exports.MainElement = exports.InfoElement = exports.ApiDesignSystemsMediaTypes = void 0;
|
|
6
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
7
|
+
exports.isRefElement = _apidomCore.isRefElement;
|
|
8
|
+
exports.isLinkElement = _apidomCore.isLinkElement;
|
|
9
|
+
exports.isMemberElement = _apidomCore.isMemberElement;
|
|
10
|
+
exports.isObjectElement = _apidomCore.isObjectElement;
|
|
11
|
+
exports.isArrayElement = _apidomCore.isArrayElement;
|
|
12
|
+
exports.isBooleanElement = _apidomCore.isBooleanElement;
|
|
13
|
+
exports.isNullElement = _apidomCore.isNullElement;
|
|
14
|
+
exports.isElement = _apidomCore.isElement;
|
|
15
|
+
exports.isNumberElement = _apidomCore.isNumberElement;
|
|
16
|
+
exports.isStringElement = _apidomCore.isStringElement;
|
|
17
|
+
var _mediaTypes = _interopRequireWildcard(require("./media-types.cjs"));
|
|
18
|
+
exports.mediaTypes = _mediaTypes.default;
|
|
19
|
+
exports.ApiDesignSystemsMediaTypes = _mediaTypes.ApiDesignSystemsMediaTypes;
|
|
20
|
+
var _namespace = _interopRequireDefault(require("./namespace.cjs"));
|
|
21
|
+
exports.default = _namespace.default;
|
|
22
|
+
var _standardIdentifierSelectors = _interopRequireDefault(require("./refractor/plugins/openapi-3-1/standard-identifier-selectors.cjs"));
|
|
23
|
+
exports.refractPluginOpenApi3_1StandardIdentifierSelectors = _standardIdentifierSelectors.default;
|
|
24
|
+
var _standardIdentifierAccessors = _interopRequireDefault(require("./refractor/plugins/openapi-3-1/standard-identifier-accessors.cjs"));
|
|
25
|
+
exports.refractPluginOpenApi3_1StandardIdentifierAccessors = _standardIdentifierAccessors.default;
|
|
26
|
+
var _validator = _interopRequireDefault(require("./validator/openapi-3-1/validator.cjs"));
|
|
27
|
+
exports.validateOpenAPI3_1 = _validator.default;
|
|
28
|
+
var _predicates = require("./predicates.cjs");
|
|
29
|
+
exports.isInfoElement = _predicates.isInfoElement;
|
|
30
|
+
exports.isMainElement = _predicates.isMainElement;
|
|
31
|
+
exports.isPrincipleElement = _predicates.isPrincipleElement;
|
|
32
|
+
exports.isRequirementElement = _predicates.isRequirementElement;
|
|
33
|
+
exports.isRequirementLevelElement = _predicates.isRequirementLevelElement;
|
|
34
|
+
exports.isScenarioElement = _predicates.isScenarioElement;
|
|
35
|
+
exports.isStandardElement = _predicates.isStandardElement;
|
|
36
|
+
exports.isStandardIdentifierElement = _predicates.isStandardIdentifierElement;
|
|
37
|
+
var _visitor = require("./traversal/visitor.cjs");
|
|
38
|
+
exports.keyMap = _visitor.keyMap;
|
|
39
|
+
exports.getNodeType = _visitor.getNodeType;
|
|
40
|
+
var _registration = require("./refractor/registration.cjs");
|
|
41
|
+
exports.MainElement = _registration.MainElement;
|
|
42
|
+
exports.InfoElement = _registration.InfoElement;
|
|
43
|
+
exports.PrincipleElement = _registration.PrincipleElement;
|
|
44
|
+
exports.RequirementElement = _registration.RequirementElement;
|
|
45
|
+
exports.RequirementLevelElement = _registration.RequirementLevelElement;
|
|
46
|
+
exports.ScenarioElement = _registration.ScenarioElement;
|
|
47
|
+
exports.StandardElement = _registration.StandardElement;
|
|
48
|
+
exports.StandardIdentifierElement = _registration.StandardIdentifierElement;
|
|
49
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
50
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = exports.ApiDesignSystemsMediaTypes = void 0;
|
|
5
|
+
var _ramda = require("ramda");
|
|
6
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
7
|
+
class ApiDesignSystemsMediaTypes extends _apidomCore.MediaTypes {
|
|
8
|
+
filterByFormat(format = 'generic') {
|
|
9
|
+
const effectiveFormat = format === 'generic' ? 'apidesignsystems;version' : format;
|
|
10
|
+
return this.filter(mediaType => mediaType.includes(effectiveFormat));
|
|
11
|
+
}
|
|
12
|
+
findBy(version = '2021-05-07', format = 'generic') {
|
|
13
|
+
const search = format === 'generic' ? `apidesignsystems;version=${version}` : `apidesignsystems+${format};version=${version}`;
|
|
14
|
+
const found = this.find(mediaType => mediaType.includes(search));
|
|
15
|
+
return found || this.unknownMediaType;
|
|
16
|
+
}
|
|
17
|
+
latest(format = 'generic') {
|
|
18
|
+
return (0, _ramda.last)(this.filterByFormat(format));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ApiDesignSystemsMediaTypes = ApiDesignSystemsMediaTypes;
|
|
22
|
+
const mediaTypes = new ApiDesignSystemsMediaTypes('application/vnd.aai.apidesignsystems;version=2021-05-07', 'application/vnd.aai.apidesignsystems+json;version=2021-05-07', 'application/vnd.aai.apidesignsystems+yaml;version=2021-05-07');
|
|
23
|
+
var _default = mediaTypes;
|
|
24
|
+
exports.default = _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _Info = _interopRequireDefault(require("./elements/Info.cjs"));
|
|
7
|
+
var _Main = _interopRequireDefault(require("./elements/Main.cjs"));
|
|
8
|
+
var _Principle = _interopRequireDefault(require("./elements/Principle.cjs"));
|
|
9
|
+
var _Requirement = _interopRequireDefault(require("./elements/Requirement.cjs"));
|
|
10
|
+
var _RequirementLevel = _interopRequireDefault(require("./elements/RequirementLevel.cjs"));
|
|
11
|
+
var _Scenario = _interopRequireDefault(require("./elements/Scenario.cjs"));
|
|
12
|
+
var _Standard = _interopRequireDefault(require("./elements/Standard.cjs"));
|
|
13
|
+
var _StandardIdentifier = _interopRequireDefault(require("./elements/StandardIdentifier.cjs"));
|
|
14
|
+
/**
|
|
15
|
+
* API Design Systems 2021-05-07 specification elements.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const apiDesignSystems = {
|
|
19
|
+
namespace: options => {
|
|
20
|
+
const {
|
|
21
|
+
base
|
|
22
|
+
} = options;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* API Design Systems 2021-05-07 specification elements.
|
|
26
|
+
*/
|
|
27
|
+
base.register('info', _Info.default);
|
|
28
|
+
base.register('main', _Main.default);
|
|
29
|
+
base.register('principle', _Principle.default);
|
|
30
|
+
base.register('requirement', _Requirement.default);
|
|
31
|
+
base.register('requirementLevel', _RequirementLevel.default);
|
|
32
|
+
base.register('scenario', _Scenario.default);
|
|
33
|
+
base.register('standard', _Standard.default);
|
|
34
|
+
base.register('standardIdentifier', _StandardIdentifier.default);
|
|
35
|
+
return base;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var _default = apiDesignSystems;
|
|
39
|
+
exports.default = _default;
|