function generateExamples(endpoint, method, body = null) { let curlBodyString = ''; let psBodyString = ''; if (body) { const curlJsonString = JSON.stringify(body).replace(/"/g, '\\"'); curlBodyString = ` -d "${curlJsonString}"`; psBodyString = `-Body (ConvertTo-Json ${JSON.stringify(body)})`; } return { cURL: `curl -u user:pass -X ${method.trim()} -k https://localhost:47990${endpoint.trim()}${curlBodyString}`, Python: `import json import requests from requests.auth import HTTPBasicAuth requests.${method.trim().toLowerCase()}( auth=HTTPBasicAuth('user', 'pass'), url='https://localhost:47990${endpoint.trim()}', verify=False,${body ? `\n json=${JSON.stringify(body)},` : ''} ).json()`, JavaScript: `fetch('https://localhost:47990${endpoint.trim()}', { method: '${method.trim()}', headers: { 'Authorization': 'Basic ' + btoa('user:pass'), 'Content-Type': 'application/json', }${body ? `,\n body: JSON.stringify(${JSON.stringify(body)}),` : ''} }) .then(response => response.json()) .then(data => console.log(data));`, PowerShell: `Invoke-RestMethod \` -SkipCertificateCheck \` -Uri 'https://localhost:47990${endpoint.trim()}' \` -Method ${method.trim()} \` -Headers @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes('user:pass'))} ${psBodyString}` }; } function hashString(str) { let hash = 0; for (let i = 0; i < str.length; i++) { const char = str.charCodeAt(i); hash = (hash << 5) - hash + char; hash |= 0; // Convert to 32bit integer } return hash; } function createTabs(examples) { const languages = Object.keys(examples); let tabs = '