MCPcopy Index your code
hub / github.com/rapi-doc/RapiDoc / apiResponseTabTemplate

Method apiResponseTabTemplate

src/components/api-request.js:1033–1096  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1031 }
1032
1033 apiResponseTabTemplate() {
1034 let responseFormat = '';
1035 let responseContent = '';
1036 if (!this.responseIsBlob) {
1037 if (this.responseHeaders.includes('application/x-ndjson')) {
1038 responseFormat = 'json';
1039 const prismLines = this.responseText.split('\n').map((q) => Prism.highlight(q, Prism.languages[responseFormat], responseFormat)).join('\n');
1040 responseContent = html`<code>${unsafeHTML(prismLines)}</code>`;
1041 } else if (this.responseHeaders.includes('json')) {
1042 responseFormat = 'json';
1043 responseContent = html`<code>${unsafeHTML(Prism.highlight(this.responseText, Prism.languages[responseFormat], responseFormat))}</code>`;
1044 } else if (this.responseHeaders.includes('html') || this.responseHeaders.includes('xml')) {
1045 responseFormat = 'html';
1046 responseContent = html`<code>${unsafeHTML(Prism.highlight(this.responseText, Prism.languages[responseFormat], responseFormat))}</code>`;
1047 } else {
1048 responseFormat = 'text';
1049 responseContent = html`<code>${this.responseText}</code>`;
1050 }
1051 }
1052 return html`
1053 <div class="row" style="font-size:var(--font-size-small); margin:5px 0">
1054 <div class="response-message ${this.responseStatus}">Response Status: ${this.responseMessage}</div>
1055 <div style="flex:1"></div>
1056 <button class="m-btn" part="btn btn-outline btn-clear-response" @click="${this.clearResponseData}">CLEAR RESPONSE</button>
1057 </div>
1058 <div part="tab-panel" class="tab-panel col" style="border-width:0 0 1px 0;">
1059 <div id="tab_buttons" part="tab-btn-row" class="tab-buttons row" @click="${(e) => {
1060 if (e.target.classList.contains('tab-btn') === false) { return; }
1061 this.activeResponseTab = e.target.dataset.tab;
1062 }}">
1063 <button part="tab-btn" class="tab-btn ${this.activeResponseTab === 'response' ? 'active' : ''}" data-tab = 'response' > RESPONSE</button>
1064 <button part="tab-btn" class="tab-btn ${this.activeResponseTab === 'headers' ? 'active' : ''}" data-tab = 'headers' > RESPONSE HEADERS</button>
1065 ${this.showCurlBeforeTry === 'true'
1066 ? ''
1067 : html`<button part="tab-btn" class="tab-btn ${this.activeResponseTab === 'curl' ? 'active' : ''}" data-tab = 'curl'>CURL</button>`}
1068 </div>
1069 ${this.responseIsBlob
1070 ? html`
1071 <div part="tab-content" class="tab-content col" style="flex:1; display:${this.activeResponseTab === 'response' ? 'flex' : 'none'};">
1072 ${this.responseBlobType === 'image'
1073 ? html`<img style="max-height:var(--resp-area-height, 400px); object-fit:contain;" class="mar-top-8" src="${ifDefined(this.responseBlobUrl)}"></img>`
1074 : ''
1075 }
1076 <button class="m-btn thin-border mar-top-8" style="width:135px" @click='${(e) => { downloadResource(this.responseBlobUrl, this.respContentDisposition, e); }}' part="btn btn-outline">
1077 DOWNLOAD
1078 </button>
1079 ${this.responseBlobType === 'view' || this.responseBlobType === 'image'
1080 ? html`<button class="m-btn thin-border mar-top-8" style="width:135px" @click='${(e) => { viewResource(this.responseBlobUrl, e); }}' part="btn btn-outline">VIEW (NEW TAB)</button>`
1081 : ''
1082 }
1083 </div>`
1084 : html`
1085 <div part="tab-content" class="tab-content col m-markdown" style="flex:1; display:${this.activeResponseTab === 'response' ? 'flex' : 'none'};" >
1086 <button class="toolbar-btn" style="position:absolute; top:12px; right:8px" @click='${(e) => { copyToClipboard(this.responseText, e); }}' part="btn btn-fill"> Copy </button>
1087 <pre style="white-space:pre; min-height:50px; height:var(--resp-area-height, 400px); resize:vertical; overflow:auto">${responseContent}</pre>
1088 </div>`
1089 }
1090 <div part="tab-content" class="tab-content col m-markdown" style="flex:1; display:${this.activeResponseTab === 'headers' ? 'flex' : 'none'};" >

Callers 1

apiCallTemplateMethod · 0.95

Calls 8

curlSyntaxTemplateMethod · 0.95
downloadResourceFunction · 0.90
viewResourceFunction · 0.90
copyToClipboardFunction · 0.90
htmlFunction · 0.85
includesMethod · 0.45
mapMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected