@snap-api-docs/view
v1.0.0
Published
Librería UI agnóstica para visualizar documentación de Snap Docs (Swagger UI Wrapper).
Readme
Snap API Docs UI 🎨
Renderizador agnóstico para documentación OpenAPI. Parte del ecosistema Snap API Docs.
Esta librería genera el HTML necesario para visualizar tu documentación Swagger/OpenAPI sin depender de ningún framework.
📦 Instalación
npm install @snap-api-docs/ui🎛️ Uso
La función getHtml retorna un string con el HTML completo (incluye CSS, JS y estructura base de Swagger UI).
Firma
getHtml(
specUrl: string,
options?: {
title?: string,
customCss?: string
}
): string🟦 Ejemplo (Node.js Nativo)
import http from 'http';
import { getHtml } from '@snap-api-docs/ui';
http.createServer((req, res) => {
if (req.url === '/docs') {
const html = getHtml('/docs.json', { title: 'Mi API' });
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(html);
}
}).listen(3000);🎨 Personalización CSS
Podés inyectar estilos propios para ajustar la UI:
getHtml('/docs.json', {
title: 'Mi API',
customCss: '.swagger-ui .info { margin: 0; }'
});