@api-components/api-type-document 4.2.15 → 4.2.18
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.js +62 -48
- package/src/PropertyDocumentMixin.d.ts +11 -0
- package/src/PropertyDocumentMixin.js +13 -2
- package/src/PropertyShapeDocument.js +8 -3
- package/src/TypeStyles.js +11 -0
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.18",
|
|
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.js
CHANGED
|
@@ -652,59 +652,73 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
652
652
|
);
|
|
653
653
|
}
|
|
654
654
|
|
|
655
|
+
_arrayPropertyTemplate(label, value, title) {
|
|
656
|
+
return html`
|
|
657
|
+
<div class="property-attribute" part="property-attribute">
|
|
658
|
+
<span class="attribute-label" part="attribute-label">${label}</span>
|
|
659
|
+
<span class="attribute-value" part="attribute-value" title=${title}>${value}</span>
|
|
660
|
+
</div>
|
|
661
|
+
`
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
_arrayPropertiesTemplate() {
|
|
665
|
+
const minCount = this._getValue(this._resolvedType, this.ns.w3.shacl.minCount)
|
|
666
|
+
const maxCount = this._getValue(this._resolvedType, this.ns.w3.shacl.maxCount)
|
|
667
|
+
|
|
668
|
+
return html`
|
|
669
|
+
${minCount !== undefined ? this._arrayPropertyTemplate('Minimum array length:', minCount, 'Minimum amount of items in array') : ''}
|
|
670
|
+
${maxCount !== undefined ? this._arrayPropertyTemplate('Maximum array length:', maxCount, 'Maximum amount of items in array') : ''}
|
|
671
|
+
`
|
|
672
|
+
}
|
|
673
|
+
|
|
655
674
|
/**
|
|
656
675
|
* @return {TemplateResult} Templates for object properties
|
|
657
676
|
*/
|
|
658
|
-
|
|
677
|
+
_arrayTemplate() {
|
|
659
678
|
const items = this._computeArrayProperties(this._resolvedType) || [];
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
679
|
+
const documents = items.map(
|
|
680
|
+
(item) => html`
|
|
681
|
+
${item.isShape
|
|
682
|
+
? html`<property-shape-document
|
|
683
|
+
class="array-document"
|
|
684
|
+
.amf="${this.amf}"
|
|
685
|
+
.shape="${item}"
|
|
686
|
+
parentTypeName="${this._computeArrayParentName(this.parentTypeName)}"
|
|
687
|
+
?narrow="${this.narrow}"
|
|
688
|
+
?noExamplesActions="${this.noExamplesActions}"
|
|
689
|
+
?compatibility="${this.compatibility}"
|
|
690
|
+
.mediaType="${this.mediaType}"
|
|
691
|
+
?graph="${this.graph}"
|
|
692
|
+
></property-shape-document>`
|
|
693
|
+
: ''}
|
|
694
|
+
${item.isType
|
|
695
|
+
? html`<api-type-document
|
|
696
|
+
class="union-document"
|
|
697
|
+
.amf="${this.amf}"
|
|
698
|
+
.parentTypeName="${this.parentTypeName}"
|
|
699
|
+
.type="${item}"
|
|
700
|
+
?narrow="${this.narrow}"
|
|
701
|
+
?noExamplesActions="${this.noExamplesActions}"
|
|
702
|
+
?noMainExample="${this._renderMainExample}"
|
|
703
|
+
?compatibility="${this.compatibility}"
|
|
704
|
+
.mediaType="${this.mediaType}"
|
|
705
|
+
?graph="${this.graph}"
|
|
706
|
+
></api-type-document>`
|
|
707
|
+
: ''}
|
|
708
|
+
`
|
|
709
|
+
);
|
|
674
710
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
?compatibility="${this.compatibility}"
|
|
687
|
-
.mediaType="${this.mediaType}"
|
|
688
|
-
?graph="${this.graph}"
|
|
689
|
-
></property-shape-document>`
|
|
690
|
-
: ''}
|
|
691
|
-
${item.isType
|
|
692
|
-
? html`<api-type-document
|
|
693
|
-
class="union-document"
|
|
694
|
-
.amf="${this.amf}"
|
|
695
|
-
.parentTypeName="${this.parentTypeName}"
|
|
696
|
-
.type="${item}"
|
|
697
|
-
?narrow="${this.narrow}"
|
|
698
|
-
?noExamplesActions="${this.noExamplesActions}"
|
|
699
|
-
?noMainExample="${this._renderMainExample}"
|
|
700
|
-
?compatibility="${this.compatibility}"
|
|
701
|
-
.mediaType="${this.mediaType}"
|
|
702
|
-
?graph="${this.graph}"
|
|
703
|
-
></api-type-document>`
|
|
704
|
-
: ''}
|
|
705
|
-
`
|
|
706
|
-
)}
|
|
707
|
-
</div>
|
|
711
|
+
return html`
|
|
712
|
+
${!this.hasParentType ?
|
|
713
|
+
html`
|
|
714
|
+
<span>Array of:</span>
|
|
715
|
+
<div class="array-children">
|
|
716
|
+
${documents}
|
|
717
|
+
</div>`
|
|
718
|
+
: html`${documents}`
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
${this._arrayPropertiesTemplate()}
|
|
708
722
|
`;
|
|
709
723
|
}
|
|
710
724
|
|
|
@@ -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() {
|
package/src/TypeStyles.js
CHANGED
|
@@ -85,4 +85,15 @@ export default css`
|
|
|
85
85
|
.union-type-selector {
|
|
86
86
|
margin: 12px 0;
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
.property-attribute {
|
|
90
|
+
margin: 4px 0;
|
|
91
|
+
padding: 0;
|
|
92
|
+
color: var(--api-type-document-type-attribute-color, #616161);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.attribute-label {
|
|
96
|
+
font-weight: var(--api-type-document-property-range-attribute-label-font-weight, 500);
|
|
97
|
+
margin-right: 12px;
|
|
98
|
+
}
|
|
88
99
|
`;
|