ResponseCard
Domain · API DocCollapsible card for a single API response showing the status code, description, and response body schema.
200 Token issued
Schema rendered here
<%- include('modules/domain/api-doc/ResponseCard', {
response: {
responseId: 'r-200',
statusCode: '200',
description: 'Token issued',
content: { 'application/json': { schema: { type: 'object' } } }
}
}) %>
<%
var _response = locals.response || {};
var _defaultOpen = locals.defaultOpen === true;
var code = String(_response.statusCode || '');
var n = parseInt(code, 10);
var statusVariant;
if (n >= 200 && n < 300) statusVariant = 'success';
else if (n >= 300 && n < 400) statusVariant = 'info';
else if (n >= 400 && n < 500) statusVariant = 'warning';
else if (n >= 500) statusVariant = 'error';
else statusVariant = 'neutral';
var contentEntries = _response.content ? Object.entries(_response.content) : [];
var headers = _response.headers ? Object.entries(_response.headers) : [];
%>
>
<%- include('../../ui/Badge', { variant: statusVariant, size: 'md', children: code }) %>
<%= _response.description || '' %>
<% if (contentEntries.length > 0) { %>
<%= contentEntries[0][0] %>
<% } %>
<% if (headers.length > 0) { %>
Headers
<% headers.forEach(function(entry) {
var hKey = entry[0];
var hdr = entry[1];
%>
<%= hKey %>
<% if (hdr.schema && hdr.schema.type) { %>
<%- include('../../ui/Badge', { variant: 'neutral', size: 'sm', children: hdr.schema.type }) %>
<% } %>
<% if (hdr.description) { %><%= hdr.description %><% } %>
<% }); %>
<% } %>
<% if (contentEntries.length > 0) { %>
<% contentEntries.forEach(function(entry) {
var mime = entry[0];
var obj = entry[1];
%>
<%= mime %>
<% if (obj.schema) { %>
<%- include('./SchemaViewer', { schema: obj.schema }) %>
<% } %>
<% }); %>
<% } else { %>
No response body.
<% } %>