@@ -257,6 +311,17 @@
Deprecated - this endpoint may be removed in a future version
`;
}
+ if (endpoint.security && endpoint.security.length > 0) {
+ html += ``;
+ if (endpoint.security && endpoint.security.length > 0) {
+ const satisfied = endpoint.security.some((id) => credentialIsSet(authCredentials[id]));
+ html += `
+
+ ${satisfied ? "Credentials will be sent with this request" : "This endpoint requires authorization"}
+
+
`;
+ }
+
+ if (mockServerAvailable()) {
+ html += `
`;
+ }
+
const pathParams = endpoint.parameters.filter((p) => p.in === "path");
const queryParams = endpoint.parameters.filter((p) => p.in === "query");
const headerParams = endpoint.parameters.filter((p) => p.in === "header");
@@ -443,16 +537,13 @@
html += `
`;
html += `
`; // tryTabBody
- html += `No requests sent yet for this endpoint.
Responses you send will appear here.
`;
+ }
+
+ let html = "";
+ for (const item of items) {
+ const cls = item.status && item.status < 300 ? "status-2xx" : item.status && item.status < 500 ? "status-4xx" : "status-5xx";
+ html += `
+
+ ${item.status || "ERR"}
+ ${escapeHtml(item.time)}
+
+
${escapeHtml(item.method)} ${escapeHtml(item.url)}
+
`;
+ }
+ return html;
+ }
+
+ function bindHistoryTabEvents(endpoint) {
+ const root = document.getElementById("tryTabHistory");
+ if (!root) return;
+ root.querySelectorAll("[data-history-id]").forEach((node) => {
+ node.addEventListener("click", () => {
+ const item = requestHistory.find((h) => h.id === node.dataset.historyId);
+ if (!item) return;
+ activeTryTab = "body";
+ renderTry({ name: "" }, endpoint);
+ showResponsePanelFromHistory(item);
+ });
+ });
+ }
+
+ function showResponsePanelFromHistory(item) {
+ const panel = document.getElementById("responsePanel");
+ if (!panel || !item.response) return;
+ renderResponsePanel(panel, item.response);
+ }
+
+ // Builds a language-agnostic description of the request: url, headers, body.
+ // Shared by every code-snippet generator and by the auth-aware "Send" flow.
+ function buildRequestPlan(endpoint) {
const base = (spec.servers && spec.servers[0]) || "";
- let path = endpoint.path;
- // replace path params with placeholder tokens for readability
- const lines = [];
- lines.push(`