MCPcopy
hub / github.com/rapi-doc/RapiDoc / mimeExampleTemplate

Method mimeExampleTemplate

src/components/api-response.js:248–299  ·  view source on GitHub ↗
(mimeRespDetails)

Source from the content-addressed store, hash-verified

246 }
247
248 mimeExampleTemplate(mimeRespDetails) {
249 if (!mimeRespDetails) {
250 return html`
251 <pre style='color:var(--red)' class = '${this.renderStyle === 'read' ? 'read example-panel border pad-8-16' : 'example-panel border-top'}'> No example provided </pre>
252 `;
253 }
254 return html`
255 ${mimeRespDetails.examples.length === 1
256 ? html`
257 ${mimeRespDetails.examples[0].exampleFormat === 'json'
258 ? html`
259 ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? html`<div style="padding: 4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''}
260 ${mimeRespDetails.examples[0].exampleDescription ? html`<div class="m-markdown-small" style="padding: 4px 0"> ${unsafeHTML(marked(mimeRespDetails.examples[0].exampleDescription || ''))} </div>` : ''}
261 <json-tree
262 render-style = '${this.renderStyle}'
263 .data="${mimeRespDetails.examples[0].exampleValue}"
264 class = 'example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}'
265 exportparts = "btn:btn, btn-fill:btn-fill, btn-copy:btn-copy"
266 ></json-tree>`
267 : html`
268 ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? html`<div style="padding: 4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''}
269 ${mimeRespDetails.examples[0].exampleDescription ? html`<div class="m-markdown-small" style="padding: 4px 0"> ${unsafeHTML(marked(mimeRespDetails.examples[0].exampleDescription || ''))} </div>` : ''}
270 <pre class = 'example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}'>${mimeRespDetails.examples[0].exampleValue}</pre>
271 `
272 }`
273 : html`
274 <span class = 'example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}'>
275 <select aria-label='response examples' style="min-width:100px; max-width:100%" @change='${(e) => this.onSelectExample(e)}'>
276 ${mimeRespDetails.examples.map((v) => html`<option value="${v.exampleId}" ?selected=${v.exampleId === mimeRespDetails.selectedExample} >
277 ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary}
278 </option>`)}
279 </select>
280 ${mimeRespDetails.examples.map((v) => html`
281 <div class="example" data-example = '${v.exampleId}' style = "display: ${v.exampleId === mimeRespDetails.selectedExample ? 'block' : 'none'}">
282 ${v.exampleSummary && v.exampleSummary.length > 80 ? html`<div style="padding: 4px 0"> ${v.exampleSummary} </div>` : ''}
283 ${v.exampleDescription ? html`<div class="m-markdown-small" style="padding: 4px 0"> ${unsafeHTML(marked(v.exampleDescription || ''))} </div>` : ''}
284 ${v.exampleFormat === 'json'
285 ? html`
286 <json-tree
287 render-style = '${this.renderStyle}'
288 .data = '${v.exampleValue}'
289 exportparts = "btn:btn, btn-fill:btn-fill, btn-copy:btn-copy"
290 ></json-tree>`
291 : html`<pre>${v.exampleValue}</pre>`
292 }
293 </div>
294 `)}
295 </span>
296 `
297 }
298 `;
299 }
300
301 mimeSchemaTemplate(mimeRespDetails) {
302 if (!mimeRespDetails) {

Callers 1

responseTemplateMethod · 0.95

Calls 4

onSelectExampleMethod · 0.95
htmlFunction · 0.85
markedFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected