@api-components/api-type-document 4.2.14 → 4.2.17
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/README.md +8 -10
- package/package.json +18 -18
- package/src/ApiTypeDocument.d.ts +1 -1
- package/src/ApiTypeDocument.js +46 -53
- package/src/PropertyDocumentMixin.d.ts +11 -0
- package/src/PropertyDocumentMixin.js +13 -2
- package/src/PropertyShapeDocument.js +8 -3
package/README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
# DEPRECATED
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+
This component is being deprecated. The code base has been moved to [api-documentation](https://github.com/advanced-rest-client/api-documentation) module. This module will be archived when [PR 37](https://github.com/advanced-rest-client/api-documentation/pull/37) is merged.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## <api-type-document>
|
|
5
|
+
-----
|
|
8
6
|
|
|
9
7
|
A documentation table for RAML type / OAS schema properties. Works with AMF data model.
|
|
10
8
|
|
|
@@ -19,7 +17,7 @@ For compatibility with previous model version use `3.x.x` version of the compone
|
|
|
19
17
|
|
|
20
18
|
Custom property | Description | Default
|
|
21
19
|
----------------|-------------|----------
|
|
22
|
-
`--api-type-document` | Mixin applied to this
|
|
20
|
+
`--api-type-document` | Mixin applied to this element | `{}`
|
|
23
21
|
`--api-type-document-union-button-background-color` | Background color of union selector button | `#fff`
|
|
24
22
|
`--api-type-document-union-button-color` | Color of union selector button | `#000`
|
|
25
23
|
`--api-type-document-union-button-active-background-color` | Background color of active union selector button | `#CDDC39`
|
|
@@ -29,7 +27,7 @@ From `property-shape-document`
|
|
|
29
27
|
|
|
30
28
|
Custom property | Description | Default
|
|
31
29
|
----------------|-------------|----------
|
|
32
|
-
`--property-shape-document` | Mixin applied each
|
|
30
|
+
`--property-shape-document` | Mixin applied each property element | `{}`
|
|
33
31
|
`--property-shape-document-array-color` | Property border color when type is an array | `#8BC34A`
|
|
34
32
|
`--property-shape-document-object-color` | Property border color when type is an object | `#FF9800`
|
|
35
33
|
`--property-shape-document-union-color` | Property border color when type is an union | `#FFEB3B`
|
|
@@ -41,17 +39,17 @@ Custom property | Description | Default
|
|
|
41
39
|
`--api-type-document-type-color` | Color of the "type" trait | `white`
|
|
42
40
|
`--api-type-document-type-background-color` | Background color of the "type" trait | `#2196F3`
|
|
43
41
|
`--api-type-document-trait-background-color` | Background color to main range trait (type, required, enum) | `#EEEEEE`,
|
|
44
|
-
`--api-type-document-trait-border-radius` | Border
|
|
42
|
+
`--api-type-document-trait-border-radius` | Border radius of a main property traits like type, required, enum | `3px`
|
|
45
43
|
|
|
46
44
|
From `property-range-document`
|
|
47
45
|
|
|
48
46
|
Custom property | Description | Default
|
|
49
47
|
----------------|-------------|----------
|
|
50
|
-
`--property-range-document` | Mixin applied to this
|
|
48
|
+
`--property-range-document` | Mixin applied to this element | `{}`
|
|
51
49
|
`--api-type-document-type-attribute-color` | Color of each attribute that describes a property | `#616161`
|
|
52
50
|
`--api-type-document-examples-title-color` | Color of examples section title | ``
|
|
53
51
|
`--api-type-document-examples-border-color` | Example section border color | `transparent`
|
|
54
|
-
`--code-background-color` | Background color of the examples section
|
|
52
|
+
`--code-background-color` | Background color of the examples section |``
|
|
55
53
|
`--arc-font-body1` | Mixin applied to an example name label | `{}`
|
|
56
54
|
`--arc-font-body2` | Mixin applied to the examples section title | `{}`
|
|
57
55
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-components/api-type-document",
|
|
3
3
|
"description": "A documentation table for type (resource) properties. Works with AMF data model",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.17",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "index.js",
|
|
@@ -27,31 +27,31 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@advanced-rest-client/arc-marked": "^1.1.0",
|
|
29
29
|
"@advanced-rest-client/markdown-styles": "^3.1.4",
|
|
30
|
-
"@anypoint-web-components/anypoint-button": "^1.2.
|
|
31
|
-
"@api-components/amf-helper-mixin": "^4.
|
|
30
|
+
"@anypoint-web-components/anypoint-button": "^1.2.3",
|
|
31
|
+
"@api-components/amf-helper-mixin": "^4.5.6",
|
|
32
32
|
"@api-components/api-annotation-document": "^4.1.0",
|
|
33
|
-
"@api-components/api-resource-example-document": "^4.
|
|
33
|
+
"@api-components/api-resource-example-document": "^4.3.3",
|
|
34
34
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
35
35
|
"lit-element": "^2.4.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@advanced-rest-client/arc-demo-helper": "^
|
|
39
|
-
"@anypoint-web-components/anypoint-checkbox": "^1.
|
|
40
|
-
"@anypoint-web-components/anypoint-styles": "^1.0.
|
|
41
|
-
"@api-components/api-model-generator": "^0.2.
|
|
42
|
-
"@commitlint/cli": "^
|
|
43
|
-
"@commitlint/config-conventional": "^
|
|
38
|
+
"@advanced-rest-client/arc-demo-helper": "^3.0.3",
|
|
39
|
+
"@anypoint-web-components/anypoint-checkbox": "^1.2.2",
|
|
40
|
+
"@anypoint-web-components/anypoint-styles": "^1.0.2",
|
|
41
|
+
"@api-components/api-model-generator": "^0.2.14",
|
|
42
|
+
"@commitlint/cli": "^13.2.0",
|
|
43
|
+
"@commitlint/config-conventional": "^13.2.0",
|
|
44
44
|
"@open-wc/eslint-config": "^4.2.0",
|
|
45
45
|
"@open-wc/testing": "^2.5.15",
|
|
46
|
-
"@web/dev-server": "^0.1.
|
|
47
|
-
"@web/test-runner": "^0.
|
|
48
|
-
"@web/test-runner-playwright": "^0.8.
|
|
49
|
-
"eslint": "^7.
|
|
46
|
+
"@web/dev-server": "^0.1.24",
|
|
47
|
+
"@web/test-runner": "^0.13.18",
|
|
48
|
+
"@web/test-runner-playwright": "^0.8.8",
|
|
49
|
+
"eslint": "^7.32.0",
|
|
50
50
|
"eslint-config-prettier": "^8.1.0",
|
|
51
|
-
"husky": "^
|
|
52
|
-
"lint-staged": "^
|
|
53
|
-
"sinon": "^
|
|
54
|
-
"typescript": "^4.3
|
|
51
|
+
"husky": "^7.0.2",
|
|
52
|
+
"lint-staged": "^11.1.2",
|
|
53
|
+
"sinon": "^11.1.2",
|
|
54
|
+
"typescript": "^4.4.3",
|
|
55
55
|
"typescript-lit-html-plugin": "^0.9.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
package/src/ApiTypeDocument.d.ts
CHANGED
|
@@ -180,7 +180,7 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
180
180
|
|
|
181
181
|
connectedCallback(): void;
|
|
182
182
|
|
|
183
|
-
_computeRenderMainExample(noMainExample: boolean, hasExamples: boolean): boolean;
|
|
183
|
+
_computeRenderMainExample(noMainExample: boolean, hasExamples: boolean, isScalar: boolean): boolean;
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
186
|
* Called when resolved type or amf changed.
|
package/src/ApiTypeDocument.js
CHANGED
|
@@ -289,9 +289,11 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
289
289
|
}
|
|
290
290
|
this.__hasExamples = value;
|
|
291
291
|
this.requestUpdate('_hasExamples', old);
|
|
292
|
+
const scalarType = this._hasType(this.type, this.ns.aml.vocabularies.shapes.ScalarShape);
|
|
292
293
|
this._renderMainExample = this._computeRenderMainExample(
|
|
293
294
|
this.noMainExample,
|
|
294
|
-
value
|
|
295
|
+
value,
|
|
296
|
+
scalarType
|
|
295
297
|
);
|
|
296
298
|
}
|
|
297
299
|
|
|
@@ -337,8 +339,8 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
337
339
|
}
|
|
338
340
|
}
|
|
339
341
|
|
|
340
|
-
_computeRenderMainExample(noMainExample, hasExamples) {
|
|
341
|
-
return !!(!noMainExample && hasExamples);
|
|
342
|
+
_computeRenderMainExample(noMainExample, hasExamples, isScalar = false) {
|
|
343
|
+
return isScalar ? false : !!(!noMainExample && hasExamples);
|
|
342
344
|
}
|
|
343
345
|
|
|
344
346
|
/**
|
|
@@ -653,57 +655,48 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
653
655
|
/**
|
|
654
656
|
* @return {TemplateResult} Templates for object properties
|
|
655
657
|
*/
|
|
656
|
-
|
|
658
|
+
_arrayTemplate() {
|
|
657
659
|
const items = this._computeArrayProperties(this._resolvedType) || [];
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
?compatibility="${this.compatibility}"
|
|
699
|
-
.mediaType="${this.mediaType}"
|
|
700
|
-
?graph="${this.graph}"
|
|
701
|
-
></api-type-document>`
|
|
702
|
-
: ''}
|
|
703
|
-
`
|
|
704
|
-
)}
|
|
705
|
-
</div>
|
|
706
|
-
`;
|
|
660
|
+
const documents = items.map(
|
|
661
|
+
(item) => html`
|
|
662
|
+
${item.isShape
|
|
663
|
+
? html`<property-shape-document
|
|
664
|
+
class="array-document"
|
|
665
|
+
.amf="${this.amf}"
|
|
666
|
+
.shape="${item}"
|
|
667
|
+
parentTypeName="${this._computeArrayParentName(this.parentTypeName)}"
|
|
668
|
+
?narrow="${this.narrow}"
|
|
669
|
+
?noExamplesActions="${this.noExamplesActions}"
|
|
670
|
+
?compatibility="${this.compatibility}"
|
|
671
|
+
.mediaType="${this.mediaType}"
|
|
672
|
+
?graph="${this.graph}"
|
|
673
|
+
></property-shape-document>`
|
|
674
|
+
: ''}
|
|
675
|
+
${item.isType
|
|
676
|
+
? html`<api-type-document
|
|
677
|
+
class="union-document"
|
|
678
|
+
.amf="${this.amf}"
|
|
679
|
+
.parentTypeName="${this.parentTypeName}"
|
|
680
|
+
.type="${item}"
|
|
681
|
+
?narrow="${this.narrow}"
|
|
682
|
+
?noExamplesActions="${this.noExamplesActions}"
|
|
683
|
+
?noMainExample="${this._renderMainExample}"
|
|
684
|
+
?compatibility="${this.compatibility}"
|
|
685
|
+
.mediaType="${this.mediaType}"
|
|
686
|
+
?graph="${this.graph}"
|
|
687
|
+
></api-type-document>`
|
|
688
|
+
: ''}
|
|
689
|
+
`
|
|
690
|
+
);
|
|
691
|
+
if (!this.hasParentType) {
|
|
692
|
+
return html`
|
|
693
|
+
<span>Array of:</span>
|
|
694
|
+
<div class="array-children">
|
|
695
|
+
${documents}
|
|
696
|
+
</div>
|
|
697
|
+
`;
|
|
698
|
+
}
|
|
699
|
+
return html`${documents}`;
|
|
707
700
|
}
|
|
708
701
|
|
|
709
702
|
/**
|
|
@@ -115,6 +115,17 @@ interface PropertyDocumentMixin extends AmfHelperMixin {
|
|
|
115
115
|
*/
|
|
116
116
|
_computeIsAnyOf(range: Object): boolean
|
|
117
117
|
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Computes value for `isAllOf` property.
|
|
121
|
+
* AllOf type is identified as `http://www.w3.org/ns/shacl#and`
|
|
122
|
+
* Returns true if `and` property is present in shape. Otherwise returns false.
|
|
123
|
+
*
|
|
124
|
+
* @param {Object} range Range object of current shape.
|
|
125
|
+
* @returns {boolean}
|
|
126
|
+
*/
|
|
127
|
+
_computeIsAllOf(range: Object): boolean
|
|
128
|
+
|
|
118
129
|
/**
|
|
119
130
|
* Computes list of type labels to render.
|
|
120
131
|
*
|
|
@@ -190,10 +190,9 @@ const mxFunction = (base) => {
|
|
|
190
190
|
return 'Boolean';
|
|
191
191
|
case this._getAmfKey(sc.dateTime):
|
|
192
192
|
case sc.dateTime:
|
|
193
|
-
return 'DateTime';
|
|
194
193
|
case this._getAmfKey(rs.dateTimeOnly):
|
|
195
194
|
case rs.dateTimeOnly:
|
|
196
|
-
return '
|
|
195
|
+
return 'DateTime';
|
|
197
196
|
case this._getAmfKey(sc.time):
|
|
198
197
|
case sc.time:
|
|
199
198
|
return 'Time';
|
|
@@ -345,6 +344,18 @@ const mxFunction = (base) => {
|
|
|
345
344
|
return this._hasProperty(range, this.ns.w3.shacl.or);
|
|
346
345
|
}
|
|
347
346
|
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Computes value for `isAllOf` property.
|
|
350
|
+
* Returns true if `and` property is present in shape. Otherwise returns false.
|
|
351
|
+
*
|
|
352
|
+
* @param {Object} range Range object of current shape.
|
|
353
|
+
* @returns {boolean}
|
|
354
|
+
*/
|
|
355
|
+
_computeIsAllOf(range) {
|
|
356
|
+
return this._hasProperty(range, this.ns.w3.shacl.and);
|
|
357
|
+
}
|
|
358
|
+
|
|
348
359
|
/**
|
|
349
360
|
* Computes list of type labels to render.
|
|
350
361
|
*
|
|
@@ -272,12 +272,14 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
272
272
|
this.isReadOnly = this._isReadOnly(range);
|
|
273
273
|
this.isAnyOf = this._computeIsAnyOf(range);
|
|
274
274
|
this.isOneOf = this._computeIsOneOf(range);
|
|
275
|
+
this.isAllOf = this._computeIsAllOf(range);
|
|
275
276
|
this.isComplex = this._computeIsComplex(
|
|
276
277
|
this.isUnion,
|
|
277
278
|
this.isObject,
|
|
278
279
|
this.isArray,
|
|
279
280
|
this.isAnyOf,
|
|
280
|
-
this.isOneOf
|
|
281
|
+
this.isOneOf,
|
|
282
|
+
this.isAllOf
|
|
281
283
|
);
|
|
282
284
|
this.isScalarArray = this.isArray
|
|
283
285
|
? this._computeIsScalarArray(range)
|
|
@@ -465,10 +467,13 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
465
467
|
* @param {boolean} isUnion
|
|
466
468
|
* @param {boolean} isObject
|
|
467
469
|
* @param {boolean} isArray
|
|
470
|
+
* @param {boolean} isAnyOf
|
|
471
|
+
* @param {boolean} isOneOf
|
|
472
|
+
* @param {boolean} isAllOf
|
|
468
473
|
* @return {boolean}
|
|
469
474
|
*/
|
|
470
|
-
_computeIsComplex(isUnion, isObject, isArray, isAnyOf, isOneOf) {
|
|
471
|
-
return isUnion || isObject || isArray || isAnyOf || isOneOf;
|
|
475
|
+
_computeIsComplex(isUnion, isObject, isArray, isAnyOf, isOneOf, isAllOf) {
|
|
476
|
+
return isUnion || isObject || isArray || isAnyOf || isOneOf || isAllOf;
|
|
472
477
|
}
|
|
473
478
|
|
|
474
479
|
_evaluateGraph() {
|