@@ -169,7 +169,45 @@ export default class RapiDoc extends LitElement {
169
169
}
170
170
171
171
</ style >
172
- ${ this . showHeader === 'false' ? '' : html `
172
+ ${ this . showHeader === 'false' ? '' : this . headerTemplate ( ) }
173
+
174
+ < div class ="body-container regular-font ">
175
+ < slot > </ slot >
176
+ ${ this . loading === true ? html `< div style ="text-align: center;margin: 16px; "> Loading ... </ div > ` : '' }
177
+ ${ this . loadFailed === true ? html `< div style ="text-align: center;margin: 16px; "> Unable to load the Spec</ div > ` : '' }
178
+ ${ ( this . showInfo === 'false' || ! this . resolvedSpec || ! this . resolvedSpec . info ) ? '' : html `
179
+ < div class ="section-gap ">
180
+ < div class ="title ">
181
+ ${ this . resolvedSpec . info . title }
182
+ ${ ! this . resolvedSpec . info . version ? '' : html `
183
+ < span style ="font-size:var(--small-font-size);font-weight:bold ">
184
+ ${ this . resolvedSpec . info . version }
185
+ </ span > `
186
+ }
187
+ </ div >
188
+
189
+ ${ this . resolvedSpec . info . description
190
+ ? html `${ unsafeHTML ( `<div class='m-markdown regular-font'>${ marked ( this . resolvedSpec . info . description ) } </div>` ) } `
191
+ : ''
192
+ }
193
+ ${ this . resolvedSpec . info . termsOfService
194
+ ? html `${ unsafeHTML ( `<div class='tiny-title' style="margin-top:8px"> Terms: </div> <span class='m-markdown regular-font'>${ marked ( this . resolvedSpec . info . termsOfService ) } </span>` ) } `
195
+ : ''
196
+ }
197
+ ${ this . resolvedSpec . info . contact ? this . contactInfoTemplate ( ) : '' }
198
+ </ div > `
199
+ }
200
+
201
+ ${ ( this . allowTry === 'false' || ! this . resolvedSpec ) ? '' : this . apiServerListTemplate ( ) }
202
+ ${ ( this . allowAuthentication === 'false' || ! this . resolvedSpec || ! this . resolvedSpec . securitySchemes ) ? '' : this . securitySchemeTemplate ( ) }
203
+ ${ this . resolvedSpec && this . resolvedSpec . tags ? this . endpointsGroupedByTagTemplate ( ) : '' }
204
+
205
+ < slot name ="footer "> </ slot >
206
+ </ div > ` ;
207
+ }
208
+
209
+ headerTemplate ( ) {
210
+ return html `
173
211
< div class ="row header regular-font " style ="padding:8px 4px 8px 4px;min-height:48px;position:sticky;top:0;flex:1 ">
174
212
< div class ="only-large-screen-flex " style ="align-items: center; ">
175
213
< slot name ="logo " class ="logo ">
@@ -178,7 +216,6 @@ export default class RapiDoc extends LitElement {
178
216
< div class ="header-title "> ${ this . headingText } </ div >
179
217
</ div >
180
218
< div style ="margin: 0px 8px;display:flex;flex:1 ">
181
-
182
219
${ ( this . allowSpecUrlLoad === 'false' ) ? '' : html `
183
220
< input id ="spec-url " type ="text " class ="header-input " placeholder ="Spec URL " value ="${ this . specUrl ? this . specUrl : '' } " @change ="${ this . onSepcUrlChange } " spellcheck ="false " >
184
221
< div style ="margin: 6px 5px 0 -24px; font-size:var(--title-font-size); cursor:pointer; "> ⏎</ div >
@@ -194,111 +231,98 @@ export default class RapiDoc extends LitElement {
194
231
< div style ="margin: 6px 5px 0 -24px; font-size:var(--title-font-size); cursor:pointer; "> ⏎</ div >
195
232
` }
196
233
</ div >
197
- </ div > ` }
198
-
199
- < div class ="body-container regular-font ">
200
- < slot > </ slot >
201
- ${ this . loading === true ? html `< div style ="text-align: center;margin: 16px; "> Loading ... </ div > ` : '' }
202
- ${ this . loadFailed === true ? html `< div style ="text-align: center;margin: 16px; "> Unable to load the Spec</ div > ` : '' }
203
- ${ ( this . showInfo === 'false' || ! this . resolvedSpec || ! this . resolvedSpec . info ) ? '' : html `
204
- < div class ="section-gap ">
205
- < div class ="title ">
206
- ${ this . resolvedSpec . info . title }
207
- ${ ! this . resolvedSpec . info . version ? '' : html `
208
- < span style ="font-size:var(--small-font-size);font-weight:bold ">
209
- ${ this . resolvedSpec . info . version }
210
- </ span > `
211
- }
212
- </ div >
213
- ${ this . resolvedSpec . info . description ? html `
214
- ${ unsafeHTML ( `<div class='m-markdown regular-font'>${ marked ( this . resolvedSpec . info . description ) } </div>` ) }
215
- ` : '' }
216
- ${ this . resolvedSpec . info . termsOfService ? html `
217
- ${ unsafeHTML ( `<div class='tiny-title' style="margin-top:8px"> Terms: </div> <span class='m-markdown regular-font'>${ marked ( this . resolvedSpec . info . termsOfService ) } </span>` ) }
218
- ` : '' }
219
-
220
- ${ this . resolvedSpec . info . contact ? html `
221
- < div style ="font-size:13px; margin-top:8px; line-height: 18px; ">
222
- ${ this . resolvedSpec . info . contact . email ? html `
223
- < div >
224
- < span class ='tiny-title ' style ="display:inline-block; width:50px "> Email: </ span >
225
- < span class ='regular-font '> ${ this . resolvedSpec . info . contact . email } </ span >
226
- </ div >
227
- ` : '' }
228
- ${ this . resolvedSpec . info . contact . name ? html `
229
- < div >
230
- < span class ='tiny-title ' style ="display:inline-block; width:50px "> Name: </ span >
231
- < span class ='regular-font '> ${ this . resolvedSpec . info . contact . name } </ span >
232
- </ div >
233
- ` : '' }
234
- ${ this . resolvedSpec . info . contact . url ? html `
235
- < div >
236
- < span class ='tiny-title ' style ="display:inline-block; width:50px "> URL: </ span >
237
- < span class ='regular-font '> ${ this . resolvedSpec . info . contact . url } </ span >
238
- </ div >
239
- ` : '' }
240
- </ div >
241
- ` : '' }
242
-
234
+ </ div > ` ;
235
+ }
243
236
244
- </ div > `
245
- }
237
+ contactInfoTemplate ( ) {
238
+ return html `
239
+ < div style ="font-size:13px; margin-top:8px; line-height: 18px; ">
240
+ ${ this . resolvedSpec . info . contact . email
241
+ ? html `
242
+ < div >
243
+ < span class ='tiny-title ' style ="display:inline-block; width:50px "> Email: </ span >
244
+ < span class ='regular-font '> ${ this . resolvedSpec . info . contact . email } </ span >
245
+ </ div > `
246
+ : ''
247
+ }
248
+ ${ this . resolvedSpec . info . contact . name
249
+ ? html `
250
+ < div >
251
+ < span class ='tiny-title ' style ="display:inline-block; width:50px "> Name: </ span >
252
+ < span class ='regular-font '> ${ this . resolvedSpec . info . contact . name } </ span >
253
+ </ div > `
254
+ : ''
255
+ }
256
+ ${ this . resolvedSpec . info . contact . url
257
+ ? html `
258
+ < div >
259
+ < span class ='tiny-title ' style ="display:inline-block; width:50px "> URL: </ span >
260
+ < span class ='regular-font '> ${ this . resolvedSpec . info . contact . url } </ span >
261
+ </ div > `
262
+ : ''
263
+ }
264
+ </ div > ` ;
265
+ }
246
266
247
- ${ ( this . allowTry === 'false' || ! this . resolvedSpec ) ? '' : html `
248
- < div class ="sub-title regular-font section-gap ">
249
- < a id ="api_server_options "> API SERVER: </ a >
250
- < div class ="mono-font " style ="margin: 12px 0; font-size:calc(var(--small-font-size) + 1px); ">
251
- ${ ! this . resolvedSpec . servers || ( this . resolvedSpec . servers . length === 0 ) ? '' : html `
252
- ${ this . resolvedSpec . servers . map ( ( server ) => html `
253
- < input type ='radio ' name ='api_server ' value ='${ server . url } ' @change ="${ this . onApiServerChange } " checked style ='margin:2px 0 5px 8px '/>
254
- ${ server . url }
255
- ${ server . description ? html `- ${ server . description } ` : '' }
256
- < br />
257
- ` ) }
258
- ` }
267
+ apiServerListTemplate ( ) {
268
+ return html `
269
+ < div class ="sub-title regular-font section-gap ">
270
+ < a id ="api_server_options "> API SERVER: </ a >
271
+ < div class ="mono-font " style ="margin: 12px 0; font-size:calc(var(--small-font-size) + 1px); ">
272
+ ${ ! this . resolvedSpec . servers || ( this . resolvedSpec . servers . length === 0 )
273
+ ? ''
274
+ : html `
275
+ ${ this . resolvedSpec . servers . map ( ( server ) => html `
276
+ < input type ='radio ' name ='api_server ' value ='${ server . url } ' @change ="${ this . onApiServerChange } " checked style ='margin:2px 0 5px 8px '/>
277
+ ${ server . url }
278
+ ${ server . description ? html `- ${ server . description } ` : '' }
279
+ < br />
280
+ ` ) }
281
+ ` }
259
282
260
- ${ ( this . serverUrl ) ? html `
261
- < input type ='radio ' name ='api_server ' value ='${ this . serverUrl } ' @change ="${ this . onApiServerChange } " checked style ='margin:2px 0 5px 8px '/>
262
- ${ this . serverUrl } < br />
263
- ` : ''
264
- }
265
- </ div >
266
- </ div >
267
- ` }
283
+ ${ ( this . serverUrl ) ? html `
284
+ < input type ='radio ' name ='api_server ' value ='${ this . serverUrl } ' @change ="${ this . onApiServerChange } " checked style ='margin:2px 0 5px 8px '/>
285
+ ${ this . serverUrl } < br />
286
+ ` : ''
287
+ }
288
+ </ div >
289
+ </ div > ` ;
290
+ }
268
291
292
+ securitySchemeTemplate ( ) {
293
+ return html `
294
+ < div class ="sub-title regular-font section-gap ">
295
+ < security-schemes
296
+ .schemes ="${ this . resolvedSpec . securitySchemes } "
297
+ selected-api-key-name = "${ this . apiKeyName ? this . apiKeyName : '' } "
298
+ selected-api-key-value = "${ this . apiKeyValue ? this . apiKeyValue : '' } "
299
+ @change ="${ this . onSecurityChange } "
300
+ > </ security-schemes >
301
+ </ div > ` ;
302
+ }
269
303
270
- ${ ( this . allowAuthentication === 'false' || ! this . resolvedSpec || ! this . resolvedSpec . securitySchemes ) ? '' : html `
271
- < div class ="sub-title regular-font section-gap ">
272
- < security-schemes
273
- .schemes ="${ this . resolvedSpec . securitySchemes } "
274
- selected-api-key-name = "${ this . apiKeyName ? this . apiKeyName : '' } "
275
- selected-api-key-value = "${ this . apiKeyValue ? this . apiKeyValue : '' } "
276
- @change ="${ this . onSecurityChange } "
277
- > </ security-schemes >
304
+ endpointsGroupedByTagTemplate ( ) {
305
+ return html `
306
+ ${ this . resolvedSpec . tags . map ( ( tag ) => html `
307
+ < div class ="sub-title tag regular-font section-gap "> ${ tag . name } </ div >
308
+ < div style ="margin:4px 20px ">
309
+ ${ unsafeHTML ( `<div class='m-markdown regular-font'>${ marked ( tag . description ? tag . description : '' ) } </div>` ) }
278
310
</ div >
279
- ` }
280
-
281
- ${ this . resolvedSpec && this . resolvedSpec . tags ? html `
282
- ${ this . resolvedSpec . tags . map ( ( tag ) => html `
283
- < div class ="sub-title tag regular-font section-gap "> ${ tag . name } </ div >
284
- < div style ="margin:4px 20px ">
285
- ${ unsafeHTML ( `<div class='m-markdown regular-font'>${ marked ( tag . description ? tag . description : '' ) } </div>` ) }
286
- </ div >
287
- < end-points
288
- selected-server = "${ this . selectedServer ? this . selectedServer : '' } "
289
- api-key-name = "${ this . apiKeyName ? this . apiKeyName : '' } "
290
- api-key-value = "${ this . apiKeyValue ? this . apiKeyValue : '' } "
291
- api-key-location = "${ this . apiKeyLocation ? this . apiKeyLocation : '' } "
292
- layout = "${ this . layout ? this . layout : 'row' } "
293
- .paths = "${ tag . paths } "
294
- allow-try = "${ this . allowTry ? this . allowTry : 'true' } "
295
- match-paths = "${ this . matchPaths } "
296
- > </ end-points >
297
- ` ) } `
298
- : '' }
299
- < slot name ="footer "> </ slot >
300
- </ div > ` ;
311
+ < end-points
312
+ selected-server = "${ this . selectedServer ? this . selectedServer : '' } "
313
+ api-key-name = "${ this . apiKeyName ? this . apiKeyName : '' } "
314
+ api-key-value = "${ this . apiKeyValue ? this . apiKeyValue : '' } "
315
+ api-key-location = "${ this . apiKeyLocation ? this . apiKeyLocation : '' } "
316
+ layout = "${ this . layout ? this . layout : 'row' } "
317
+ .paths = "${ tag . paths } "
318
+ allow-try = "${ this . allowTry ? this . allowTry : 'true' } "
319
+ match-paths = "${ this . matchPaths } "
320
+ > </ end-points >
321
+ ` )
322
+ } `;
301
323
}
324
+
325
+
302
326
/* eslint-enable indent */
303
327
304
328
static get properties ( ) {
@@ -325,6 +349,8 @@ export default class RapiDoc extends LitElement {
325
349
apiKeyName : { type : String , attribute : 'api-key-name' } ,
326
350
apiKeyValue : { type : String , attribute : 'api-key-value' } ,
327
351
apiKeyLocation : { type : String , attribute : 'api-key-location' } ,
352
+ groupByTags : { type : String , attribute : 'group-by-tags' } ,
353
+
328
354
} ;
329
355
}
330
356
@@ -346,7 +372,7 @@ export default class RapiDoc extends LitElement {
346
372
this . setAttribute ( 'spec-file' , this . shadowRoot . getElementById ( 'spec-file' ) . value ) ;
347
373
const specFile = e . target . files [ 0 ] ;
348
374
const reader = new FileReader ( ) ;
349
- reader . onload = function ( ) {
375
+ reader . onload = ( ) => {
350
376
try {
351
377
const specObj = JSON . parse ( reader . result ) ;
352
378
me . loadSpec ( specObj ) ;
0 commit comments