Skip to content

Commit e5021d9

Browse files
committed
add 2 attributes schema-expand-level and schema-description-expanded
1 parent 5057611 commit e5021d9

File tree

9 files changed

+214
-144
lines changed

9 files changed

+214
-144
lines changed

docs/api.html

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,27 @@ <h2> Attributes</h2>
119119
<table class="m-table">
120120
<tr>
121121
<td class=" attr-col mono-bold right">nav-bg-color </td>
122-
<td class="gray"> <span class='bold dark-gray'>Navigation bar's background color</span></span> </td>
122+
<td class="gray"> Navigation bar's background color </td>
123123
<td class='default-col'></td>
124124
</tr>
125125
<tr>
126126
<td class=" attr-col mono-bold right">nav-text-color </td>
127-
<td class="gray"> <span class='bold dark-gray'>Navigation bar's Text color</span></span> </td>
127+
<td class="gray"> Navigation bar's Text color </td>
128128
<td class='default-col'></td>
129129
</tr>
130130
<tr>
131131
<td class=" attr-col mono-bold right">nav-hover-bg-color </td>
132-
<td class="gray"> <span class='bold dark-gray'>background color of the navigation item on mouse-over</span></span> </td>
132+
<td class="gray">background color of the navigation item on mouse-over </td>
133133
<td class='default-col'></td>
134134
</tr>
135135
<tr>
136136
<td class=" attr-col mono-bold right">nav-hover-text-color </td>
137-
<td class="gray"> <span class='bold dark-gray'>text color of the navigation item on mouse-over</span></span> </td>
137+
<td class="gray"> text color of the navigation item on mouse-over </td>
138138
<td class='default-col'></td>
139139
</tr>
140140
<tr>
141141
<td class=" attr-col mono-bold right">nav-accent-color </td>
142-
<td class="gray"> <span class='bold dark-gray'>Current selected item indicator</span></span> </td>
142+
<td class="gray"> Current selected item indicator</td>
143143
<td class='default-col'></td>
144144
</tr>
145145
</table>
@@ -155,25 +155,36 @@ <h2> Attributes</h2>
155155
</td>
156156
<td class='default-col'>row</td>
157157
</tr>
158-
<tr>
159-
<td class="mono-bold right">schema-style </td>
160-
<td class="gray"> <span class='bold dark-gray'>Allowed:<span class='blue'> tree, table</span></span> - Two different ways to display object-schemas in the responses and request bodies </td>
161-
<td>tree</td>
162-
</tr>
163158
<tr>
164159
<td class="mono-bold right">render-style </td>
165-
<td class="gray"><span class='bold dark-gray'>Allowed:<span class='blue'> read, view</span></span> - determines display of api-docs. Currently there are two modes supported.
166-
'read' - more suitable for reading and 'view' more frendly for quick exploring </td>
160+
<td class="gray"><span class='bold dark-gray'>Allowed:<span class='blue'> read, view</span></span> -
161+
determines display of api-docs. Currently there are two modes supported.
162+
'read' - more suitable for reading and 'view' more frendly for quick exploring
163+
</td>
167164
<td>view</td>
168165
</tr>
169166
<tr>
170-
<td class="mono-bold right">api-list-style</td>
167+
<td class="mono-bold right">schema-style </td>
168+
<td class="gray"> <span class='bold dark-gray'>Allowed:<span class='blue'> tree, table</span></span> -
169+
Two different ways to display object-schemas in the responses and request bodies
170+
</td>
171+
<td>tree</td>
172+
</tr>
173+
<tr>
174+
<td class="mono-bold right">schema-expand-level </td>
171175
<td class="gray">
172-
<span class='bold dark-gray'>Allowed:<span class='blue'> group-by-tag, group-by-path</span></span> -
173-
This controls how the API litings are grouped. this can be changed from the UI too (applied only in view mode)
176+
Schema's are expanded by default, use this attribute to controll how many levels in the schema should be expanded
174177
</td>
175-
<td>group-by-tag</td>
178+
<td>999</td>
176179
</tr>
180+
<tr>
181+
<td class="mono-bold right">schema-description-expanded </td>
182+
<td class="gray"> <span class='bold dark-gray'>Allowed:<span class='blue'> true, false</span></span> -
183+
Constraint and descriptions information of fields in the schema are collapsed to show only the first line.
184+
Set it to true if you want them to fully expanded
185+
</td>
186+
<td>false</td>
187+
</tr>
177188
<tr>
178189
<td class="mono-bold right">default-schema-tab</td>
179190
<td class="gray">
@@ -183,6 +194,14 @@ <h2> Attributes</h2>
183194
</td>
184195
<td>model</td>
185196
</tr>
197+
<tr>
198+
<td class="mono-bold right">api-list-style</td>
199+
<td class="gray">
200+
<span class='bold dark-gray'>Allowed:<span class='blue'> group-by-tag, group-by-path</span></span> -
201+
This controls how the API litings are grouped. this can be changed from the UI too (applied only in view mode)
202+
</td>
203+
<td>group-by-tag</td>
204+
</tr>
186205
</table>
187206

188207
<div class='table-title'> Hide/Show Sections </div>

src/components/api-request.js

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,44 @@ import '@/components/schema-tree';
1515
import '@/components/tag-input';
1616

1717
export default class ApiRequest extends LitElement {
18+
constructor() {
19+
super();
20+
this.responseMessage = '';
21+
this.responseStatus = 'success';
22+
this.responseHeaders = '';
23+
this.responseText = '';
24+
this.responseUrl = '';
25+
this.curlSyntax = '';
26+
this.activeResponseTab = 'response'; // allowed values: response, headers, curl
27+
}
28+
29+
static get properties() {
30+
return {
31+
apiKeyName: { type: String, attribute: 'api-key-name' },
32+
apiKeyValue: { type: String, attribute: 'api-key-value' },
33+
apiKeyLocation: { type: String, attribute: 'api-key-location' },
34+
selectedServer: { type: String, attribute: 'selected-server' },
35+
method: { type: String },
36+
path: { type: String },
37+
parameters: { type: Array },
38+
request_body: { type: Object },
39+
parser: { type: Object },
40+
accept: { type: String },
41+
responseMessage: { type: String, attribute: false },
42+
responseText: { type: String, attribute: false },
43+
responseHeaders: { type: String, attribute: false },
44+
responseStatus: { type: String, attribute: false },
45+
responseUrl: { type: String, attribute: false },
46+
allowTry: { type: String, attribute: 'allow-try' },
47+
renderStyle: { type: String, attribute: 'render-style' },
48+
schemaStyle: { type: String, attribute: 'schema-style' },
49+
activeSchemaTab: { type: String, attribute: 'active-schema-tab' },
50+
schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
51+
schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
52+
activeResponseTab: { type: String }, // internal tracking of response-tab not exposed as a attribute
53+
};
54+
}
55+
1856
render() {
1957
return html`
2058
${TableStyles}
@@ -87,42 +125,6 @@ export default class ApiRequest extends LitElement {
87125
`;
88126
}
89127

90-
constructor() {
91-
super();
92-
this.responseMessage = '';
93-
this.responseStatus = 'success';
94-
this.responseHeaders = '';
95-
this.responseText = '';
96-
this.responseUrl = '';
97-
this.curlSyntax = '';
98-
this.activeResponseTab = 'response'; // allowed values: response, headers, curl
99-
}
100-
101-
static get properties() {
102-
return {
103-
apiKeyName: { type: String, attribute: 'api-key-name' },
104-
apiKeyValue: { type: String, attribute: 'api-key-value' },
105-
apiKeyLocation: { type: String, attribute: 'api-key-location' },
106-
selectedServer: { type: String, attribute: 'selected-server' },
107-
method: { type: String },
108-
path: { type: String },
109-
parameters: { type: Array },
110-
request_body: { type: Object },
111-
parser: { type: Object },
112-
accept: { type: String },
113-
responseMessage: { type: String, attribute: false },
114-
responseText: { type: String, attribute: false },
115-
responseHeaders: { type: String, attribute: false },
116-
responseStatus: { type: String, attribute: false },
117-
responseUrl: { type: String, attribute: false },
118-
allowTry: { type: String, attribute: 'allow-try' },
119-
renderStyle: { type: String, attribute: 'render-style' },
120-
schemaStyle: { type: String, attribute: 'schema-style' },
121-
activeSchemaTab: { type: String, attribute: 'active-schema-tab' },
122-
activeResponseTab: { type: String }, // internal tracking of response-tab not exposed as a attribute
123-
};
124-
}
125-
126128
/* eslint-disable indent */
127129
inputParametersTemplate(paramType) {
128130
let title = '';
@@ -438,13 +440,17 @@ export default class ApiRequest extends LitElement {
438440
style = 'display: ${(shortMimeTypes[k] === 'json' ? 'block' : 'none')};'
439441
render-style = '${this.renderStyle}'
440442
.data = '${reqSchemaTree[shortMimeTypes[k]]}'
443+
schema-expand-level = "${this.schemaExpandLevel}"
444+
schema-description-expanded = "${this.schemaDescriptionExpanded}"
441445
> </schema-table>`
442446
: html`
443447
<schema-tree
444448
class = '${shortMimeTypes[k]}'
445449
style = 'display: ${(shortMimeTypes[k] === 'json' ? 'block' : 'none')};'
446450
render-style = '${this.renderStyle}'
447451
.data = '${reqSchemaTree[shortMimeTypes[k]]}'
452+
schema-expand-level = "${this.schemaExpandLevel}"
453+
schema-description-expanded = "${this.schemaDescriptionExpanded}"
448454
> </schema-tree>`
449455
}
450456
`)}

src/components/api-response.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ export default class ApiResponse extends LitElement {
1919
this.activeSchemaTab = 'model';
2020
}
2121

22+
static get properties() {
23+
return {
24+
responses: { type: Object },
25+
parser: { type: Object },
26+
schemaStyle: { type: String, attribute: 'schema-style' },
27+
renderStyle: { type: String, attribute: 'render-style' },
28+
selectedStatus: { type: String },
29+
selectedMimeType: { type: String },
30+
activeSchemaTab: { type: String, attribute: 'active-schema-tab' },
31+
schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
32+
schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
33+
};
34+
}
35+
2236
render() {
2337
return html`
2438
${FontStyles}
@@ -72,18 +86,6 @@ export default class ApiResponse extends LitElement {
7286
`;
7387
}
7488

75-
static get properties() {
76-
return {
77-
responses: { type: Object },
78-
parser: { type: Object },
79-
schemaStyle: { type: String, attribute: 'schema-style' },
80-
renderStyle: { type: String, attribute: 'render-style' },
81-
selectedStatus: { type: String },
82-
selectedMimeType: { type: String },
83-
activeSchemaTab: { type: String, attribute: 'active-schema-tab' },
84-
};
85-
}
86-
8789
/* eslint-disable indent */
8890
responseTemplate() {
8991
if (!this.responses) { return ''; }
@@ -233,12 +235,16 @@ export default class ApiResponse extends LitElement {
233235
class = 'border'
234236
render-style = '${this.renderStyle}'
235237
.data = '${mimeRespDetails.schemaTree}'
238+
schema-expand-level = "${this.schemaExpandLevel}"
239+
schema-description-expanded = "${this.schemaDescriptionExpanded}"
236240
> </schema-tree> `
237241
: html`
238242
<schema-tree
239243
class = 'border'
240244
render-style = '${this.renderStyle}'
241245
.data = '${mimeRespDetails.schemaTree}'
246+
schema-expand-level = "${this.schemaExpandLevel}"
247+
schema-description-expanded = "${this.schemaDescriptionExpanded}"
242248
> </schema-tree>`
243249
}`;
244250
}

src/components/end-point.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ import '@/components/api-request';
66
import '@/components/api-response';
77

88
export default class EndPoint extends LitElement {
9+
constructor() {
10+
super();
11+
this.accept = '';
12+
}
13+
14+
static get properties() {
15+
return {
16+
apiKeyName: { type: String, attribute: 'api-key-name' },
17+
apiKeyValue: { type: String, attribute: 'api-key-value' },
18+
apiKeyLocation: { type: String, attribute: 'api-key-location' },
19+
selectedServer: { type: String, attribute: 'selected-server' },
20+
layout: { type: String },
21+
path: { type: Object },
22+
allowTry: { type: String, attribute: 'allow-try' },
23+
renderStyle: { type: String, attribute: 'render-style' },
24+
schemaStyle: { type: String, attribute: 'schema-style' },
25+
defaultSchemaTab: { type: String, attribute: 'default-schema-tab' },
26+
schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
27+
schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
28+
};
29+
}
30+
931
/* eslint-disable indent */
1032
render() {
1133
return html`
@@ -81,39 +103,23 @@ export default class EndPoint extends LitElement {
81103
allow-try = "${this.allowTry}"
82104
accept = "${this.accept}"
83105
schema-style = "${this.schemaStyle}"
106+
schema-expand-level = "${this.schemaExpandLevel}"
107+
schema-description-expanded = "${this.schemaDescriptionExpanded}"
84108
> </api-request>
85109
86110
<api-response
87111
class="response"
88112
active-schema-tab = "${this.defaultSchemaTab}"
89113
schema-style="${this.schemaStyle}"
90114
.responses="${this.path.responses}"
115+
schema-expand-level = "${this.schemaExpandLevel}"
116+
schema-description-expanded = "${this.schemaDescriptionExpanded}"
91117
> </api-response>
92118
</div>
93119
</div>`;
94120
}
95121
/* eslint-enable indent */
96122

97-
constructor() {
98-
super();
99-
this.accept = '';
100-
}
101-
102-
static get properties() {
103-
return {
104-
apiKeyName: { type: String, attribute: 'api-key-name' },
105-
apiKeyValue: { type: String, attribute: 'api-key-value' },
106-
apiKeyLocation: { type: String, attribute: 'api-key-location' },
107-
selectedServer: { type: String, attribute: 'selected-server' },
108-
layout: { type: String },
109-
path: { type: Object },
110-
allowTry: { type: String, attribute: 'allow-try' },
111-
renderStyle: { type: String, attribute: 'render-style' },
112-
schemaStyle: { type: String, attribute: 'schema-style' },
113-
defaultSchemaTab: { type: String, attribute: 'default-schema-tab' },
114-
};
115-
}
116-
117123
toggleExpand() {
118124
if (this.path.expanded) {
119125
this.path.expanded = false; // collapse

src/components/end-points-expanded.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ import '@/components/api-response';
66
import FontStyles from '@/styles/font-styles';
77

88
export default class EndPointsExpanded extends LitElement {
9+
static get properties() {
10+
return {
11+
apiKeyName: { type: String, attribute: 'api-key-name' },
12+
apiKeyValue: { type: String, attribute: 'api-key-value' },
13+
apiKeyLocation: { type: String, attribute: 'api-key-location' },
14+
selectedServer: { type: String, attribute: 'selected-server' },
15+
layout: { type: String },
16+
paths: { type: Object },
17+
matchPaths: { type: String, attribute: 'match-paths' },
18+
allowTry: { type: String, attribute: 'allow-try' },
19+
renderStyle: { type: String, attribute: 'render-style' },
20+
schemaStyle: { type: String, attribute: 'schema-style' },
21+
defaultSchemaTab: { type: String, attribute: 'default-schema-tab' },
22+
schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
23+
schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
24+
};
25+
}
26+
927
/* eslint-disable indent */
1028
render() {
1129
return html`
@@ -66,13 +84,17 @@ export default class EndPointsExpanded extends LitElement {
6684
render-style="${this.renderStyle}"
6785
schema-style = "${this.schemaStyle}"
6886
active-schema-tab = "${this.defaultSchemaTab}"
87+
schema-expand-level = "${this.schemaExpandLevel}"
88+
schema-description-expanded = "${this.schemaDescriptionExpanded}"
6989
> </api-request>
7090
<api-response
7191
class = 'response-panel'
7292
schema-style="${this.schemaStyle}"
7393
render-style="${this.renderStyle}"
74-
active-schema-tab = "${this.defaultSchemaTab}"
94+
active-schema-tab = "${this.defaultSchemaTab}"
7595
.responses="${path.responses}"
96+
schema-expand-level = "${this.schemaExpandLevel}"
97+
schema-description-expanded = "${this.schemaDescriptionExpanded}"
7698
> </api-response>
7799
</div>
78100
</div>
@@ -89,23 +111,6 @@ export default class EndPointsExpanded extends LitElement {
89111
});
90112
this.dispatchEvent(added);
91113
}
92-
93-
94-
static get properties() {
95-
return {
96-
apiKeyName: { type: String, attribute: 'api-key-name' },
97-
apiKeyValue: { type: String, attribute: 'api-key-value' },
98-
apiKeyLocation: { type: String, attribute: 'api-key-location' },
99-
selectedServer: { type: String, attribute: 'selected-server' },
100-
layout: { type: String },
101-
paths: { type: Object },
102-
matchPaths: { type: String, attribute: 'match-paths' },
103-
allowTry: { type: String, attribute: 'allow-try' },
104-
renderStyle: { type: String, attribute: 'render-style' },
105-
schemaStyle: { type: String, attribute: 'schema-style' },
106-
defaultSchemaTab: { type: String, attribute: 'default-schema-tab' },
107-
};
108-
}
109114
}
110115
// Register the element with the browser
111116
customElements.define('end-points-expanded', EndPointsExpanded);

0 commit comments

Comments
 (0)