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

Method requestBodyTemplate

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

Source from the content-addressed store, hash-verified

600 }
601
602 requestBodyTemplate() {
603 if (!this.request_body) {
604 return '';
605 }
606 if (Object.keys(this.request_body).length === 0) {
607 return '';
608 }
609
610 // Variable to store partial HTMLs
611 let reqBodyTypeSelectorHtml = '';
612 let reqBodyFileInputHtml = '';
613 let reqBodyFormHtml = '';
614 let reqBodySchemaHtml = '';
615 let reqBodyExampleHtml = '';
616
617 const requestBodyTypes = [];
618 const { content } = this.request_body;
619 for (const mimeType in content) {
620 requestBodyTypes.push({
621 mimeType,
622 schema: content[mimeType].schema,
623 example: content[mimeType].example,
624 examples: content[mimeType].examples,
625 });
626 if (!this.selectedRequestBodyType) {
627 this.selectedRequestBodyType = mimeType;
628 }
629 }
630 // MIME Type selector
631 reqBodyTypeSelectorHtml = requestBodyTypes.length === 1
632 ? ''
633 : html`
634 <select style="min-width:100px; max-width:100%; margin-bottom:-1px;" @change = '${(e) => this.onMimeTypeChange(e)}'>
635 ${requestBodyTypes.map((reqBody) => html`
636 <option value = '${reqBody.mimeType}' ?selected = '${reqBody.mimeType === this.selectedRequestBodyType}'>
637 ${reqBody.mimeType}
638 </option> `)
639 }
640 </select>
641 `;
642
643 // For Loop - Main
644 requestBodyTypes.forEach((reqBody) => {
645 let schemaAsObj;
646 let reqBodyExamples = [];
647
648 if (this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text') || this.selectedRequestBodyType.includes('jose')) {
649 // Generate Example
650 if (reqBody.mimeType === this.selectedRequestBodyType) {
651 reqBodyExamples = generateExample(
652 reqBody.schema,
653 reqBody.mimeType,
654 standardizeExample(reqBody.examples),
655 standardizeExample(reqBody.example),
656 this.callback === 'true' || this.webhook === 'true' ? true : false, // eslint-disable-line no-unneeded-ternary
657 this.callback === 'true' || this.webhook === 'true' ? false : true, // eslint-disable-line no-unneeded-ternary
658 'text',
659 false,

Callers 1

renderMethod · 0.95

Calls 15

onMimeTypeChangeMethod · 0.95
onSelectExampleMethod · 0.95
getRequestPanelMethod · 0.95
liveCURLSyntaxUpdateMethod · 0.95
onTryClickMethod · 0.95
formDataTemplateMethod · 0.95
generateExampleFunction · 0.90
standardizeExampleFunction · 0.90
schemaInObjectNotationFunction · 0.90
htmlFunction · 0.85
markedFunction · 0.50
keysMethod · 0.45

Tested by

no test coverage detected